line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2022 Jeffrey Kegler |
2
|
|
|
|
|
|
|
# This file is part of Marpa::R2. Marpa::R2 is free software: you can |
3
|
|
|
|
|
|
|
# redistribute it and/or modify it under the terms of the GNU Lesser |
4
|
|
|
|
|
|
|
# General Public License as published by the Free Software Foundation, |
5
|
|
|
|
|
|
|
# either version 3 of the License, or (at your option) any later version. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Marpa::R2 is distributed in the hope that it will be useful, |
8
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
10
|
|
|
|
|
|
|
# Lesser General Public License for more details. |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# You should have received a copy of the GNU Lesser |
13
|
|
|
|
|
|
|
# General Public License along with Marpa::R2. If not, see |
14
|
|
|
|
|
|
|
# http://www.gnu.org/licenses/. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Marpa::R2::HTML::Test::Util; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# This code was based on study of the test suite in Andy Lester's Ack package |
19
|
|
|
|
|
|
|
|
20
|
11
|
|
|
11
|
|
766504
|
use 5.010001; |
|
11
|
|
|
|
|
132
|
|
21
|
11
|
|
|
11
|
|
60
|
use strict; |
|
11
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
252
|
|
22
|
11
|
|
|
11
|
|
52
|
use warnings; |
|
11
|
|
|
|
|
48
|
|
|
11
|
|
|
|
|
368
|
|
23
|
|
|
|
|
|
|
|
24
|
11
|
|
|
11
|
|
85
|
use Test::More; |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
58
|
|
25
|
11
|
|
|
11
|
|
2707
|
use English qw( -no_match_vars ); |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
95
|
|
26
|
11
|
|
|
11
|
|
4623
|
use File::Spec; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
367
|
|
27
|
11
|
|
|
11
|
|
4359
|
use Fatal qw(unlink open close); |
|
11
|
|
|
|
|
88023
|
|
|
11
|
|
|
|
|
78
|
|
28
|
11
|
|
|
11
|
|
17684
|
use Carp; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
679
|
|
29
|
11
|
|
|
11
|
|
5823
|
use CPAN::Version; |
|
11
|
|
|
|
|
13858
|
|
|
11
|
|
|
|
|
341
|
|
30
|
11
|
|
|
11
|
|
73
|
use Cwd; |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
4667
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub is_win32 { |
33
|
65
|
|
|
65
|
0
|
499
|
return $OSNAME =~ /Win32/xms; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub quotearg { |
37
|
65
|
|
|
65
|
0
|
119
|
my ($arg) = @_; |
38
|
65
|
50
|
|
|
|
175
|
return quotemeta $arg if not is_win32(); |
39
|
0
|
|
|
|
|
0
|
$arg =~ s/(\\+)$/$1$1/xms; # Double all trailing backslashes |
40
|
0
|
|
|
|
|
0
|
$arg =~ s/"/\\"/gxms; # Backslash all quotes |
41
|
0
|
|
|
|
|
0
|
return qq{"$arg"}; |
42
|
|
|
|
|
|
|
} ## end sub quotearg |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub run_command { |
45
|
15
|
|
|
15
|
0
|
36702
|
my (@args) = @_; |
46
|
|
|
|
|
|
|
|
47
|
15
|
|
|
|
|
68
|
my $blib = $ENV{MARPA_TEST_BLIB}; |
48
|
15
|
|
|
|
|
174
|
my $current_wd = Cwd::getcwd(); |
49
|
15
|
|
33
|
|
|
183
|
$blib //= $current_wd; |
50
|
15
|
|
|
|
|
82
|
my $blib_arg = '-Mblib=' . quotearg($blib); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# my $command = join q{ }, $EXECUTABLE_NAME, $blib_arg, map { quotearg($_) } @args; |
53
|
15
|
|
|
|
|
69
|
my $command = join q{ }, $EXECUTABLE_NAME, map { quotearg($_) } @args; |
|
50
|
|
|
|
|
105
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
## no critic (InputOutput::ProhibitBacktickOperators) |
56
|
15
|
|
|
|
|
4702647
|
my $stdout = `$command`; |
57
|
|
|
|
|
|
|
## use critic |
58
|
|
|
|
|
|
|
|
59
|
15
|
|
|
|
|
628
|
my ( $sig, $core, $rc ) = ( |
60
|
|
|
|
|
|
|
( $CHILD_ERROR & 127 ), |
61
|
|
|
|
|
|
|
( $CHILD_ERROR & 128 ), |
62
|
|
|
|
|
|
|
( $CHILD_ERROR >> 8 ), |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
15
|
|
|
|
|
966
|
return $stdout; |
66
|
|
|
|
|
|
|
} ## end sub run_command |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# This method must be called *BEFORE* any test plan is |
69
|
|
|
|
|
|
|
# written -- it creates its own test plan |
70
|
|
|
|
|
|
|
sub load_or_skip_all { |
71
|
12
|
|
|
12
|
0
|
503
|
my ($module_name) = @_; |
72
|
|
|
|
|
|
|
## no critic(BuiltinFunctions::ProhibitStringyEval) |
73
|
12
|
|
|
|
|
734
|
my $eval_result = eval "require $module_name; '$module_name'->import; 1"; |
74
|
12
|
50
|
|
|
|
84
|
if ( !$eval_result ) { |
75
|
0
|
|
|
|
|
0
|
my $eval_error = $EVAL_ERROR; |
76
|
0
|
|
|
|
|
0
|
$eval_error =~ s/^/# /gxms; |
77
|
0
|
0
|
|
|
|
0
|
print "1..0 # Skip Could not load $module_name\n", $eval_error |
78
|
|
|
|
|
|
|
or Carp::croak("say failed: $ERRNO"); |
79
|
0
|
|
|
|
|
0
|
exit 0; |
80
|
|
|
|
|
|
|
} ## end if ( !$eval_result ) |
81
|
11
|
|
|
11
|
|
89
|
use lib 'config'; |
|
11
|
|
|
|
|
39
|
|
|
11
|
|
|
|
|
90
|
|
82
|
12
|
|
|
|
|
24
|
$eval_result = eval { require Marpa::R2::Config; 1 }; |
|
12
|
|
|
|
|
5276
|
|
|
12
|
|
|
|
|
39
|
|
83
|
12
|
50
|
|
|
|
34
|
if ( !$eval_result ) { |
84
|
0
|
|
|
|
|
0
|
Test::More::plan tests => 1; |
85
|
0
|
|
|
|
|
0
|
Test::More::diag($EVAL_ERROR); |
86
|
0
|
|
|
|
|
0
|
Test::More::fail("Could not load Marpa::R2::Config\n"); |
87
|
0
|
|
|
|
|
0
|
exit 0; |
88
|
|
|
|
|
|
|
} ## end if ( !$eval_result ) |
89
|
12
|
|
|
|
|
26
|
my $version_wanted = $Marpa::R2::VERSION_FOR_CONFIG{$module_name}; |
90
|
12
|
50
|
|
|
|
28
|
if ( not defined $version_wanted ) { |
91
|
0
|
|
|
|
|
0
|
Test::More::plan tests => 1; |
92
|
0
|
|
|
|
|
0
|
Test::More::fail("$module_name is not known to Marpa::R2"); |
93
|
0
|
|
|
|
|
0
|
exit 0; |
94
|
|
|
|
|
|
|
} |
95
|
12
|
|
|
|
|
633
|
my $module_version = eval q{$} . $module_name . '::VERSION'; |
96
|
12
|
50
|
|
|
|
94
|
if ( CPAN::Version->vlt( $module_version, $version_wanted ) ) { |
97
|
0
|
0
|
|
|
|
|
say |
98
|
|
|
|
|
|
|
"1..0 # Skip $module_name version is $module_version; we wanted $version_wanted" |
99
|
|
|
|
|
|
|
or Carp::croak("say failed: $ERRNO"); |
100
|
0
|
|
|
|
|
|
exit 0; |
101
|
|
|
|
|
|
|
} ## end if ( vlt( $module_version, $version_wanted ) ) |
102
|
|
|
|
|
|
|
} ## end sub load_or_skip_all |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# vim: set expandtab shiftwidth=4: |