| 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
|
|
767904
|
use 5.010001; |
|
|
11
|
|
|
|
|
141
|
|
|
21
|
11
|
|
|
11
|
|
57
|
use strict; |
|
|
11
|
|
|
|
|
18
|
|
|
|
11
|
|
|
|
|
259
|
|
|
22
|
11
|
|
|
11
|
|
50
|
use warnings; |
|
|
11
|
|
|
|
|
36
|
|
|
|
11
|
|
|
|
|
352
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
11
|
|
|
11
|
|
75
|
use Test::More; |
|
|
11
|
|
|
|
|
20
|
|
|
|
11
|
|
|
|
|
59
|
|
|
25
|
11
|
|
|
11
|
|
2693
|
use English qw( -no_match_vars ); |
|
|
11
|
|
|
|
|
26
|
|
|
|
11
|
|
|
|
|
128
|
|
|
26
|
11
|
|
|
11
|
|
4766
|
use File::Spec; |
|
|
11
|
|
|
|
|
19
|
|
|
|
11
|
|
|
|
|
389
|
|
|
27
|
11
|
|
|
11
|
|
4298
|
use Fatal qw(unlink open close); |
|
|
11
|
|
|
|
|
87516
|
|
|
|
11
|
|
|
|
|
81
|
|
|
28
|
11
|
|
|
11
|
|
17422
|
use Carp; |
|
|
11
|
|
|
|
|
23
|
|
|
|
11
|
|
|
|
|
709
|
|
|
29
|
11
|
|
|
11
|
|
5963
|
use CPAN::Version; |
|
|
11
|
|
|
|
|
13632
|
|
|
|
11
|
|
|
|
|
333
|
|
|
30
|
11
|
|
|
11
|
|
69
|
use Cwd; |
|
|
11
|
|
|
|
|
22
|
|
|
|
11
|
|
|
|
|
4740
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub is_win32 { |
|
33
|
65
|
|
|
65
|
0
|
545
|
return $OSNAME =~ /Win32/xms; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub quotearg { |
|
37
|
65
|
|
|
65
|
0
|
163
|
my ($arg) = @_; |
|
38
|
65
|
50
|
|
|
|
159
|
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
|
43838
|
my (@args) = @_; |
|
46
|
|
|
|
|
|
|
|
|
47
|
15
|
|
|
|
|
64
|
my $blib = $ENV{MARPA_TEST_BLIB}; |
|
48
|
15
|
|
|
|
|
189
|
my $current_wd = Cwd::getcwd(); |
|
49
|
15
|
|
33
|
|
|
270
|
$blib //= $current_wd; |
|
50
|
15
|
|
|
|
|
124
|
my $blib_arg = '-Mblib=' . quotearg($blib); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# my $command = join q{ }, $EXECUTABLE_NAME, $blib_arg, map { quotearg($_) } @args; |
|
53
|
15
|
|
|
|
|
87
|
my $command = join q{ }, $EXECUTABLE_NAME, map { quotearg($_) } @args; |
|
|
50
|
|
|
|
|
120
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
## no critic (InputOutput::ProhibitBacktickOperators) |
|
56
|
15
|
|
|
|
|
4835432
|
my $stdout = `$command`; |
|
57
|
|
|
|
|
|
|
## use critic |
|
58
|
|
|
|
|
|
|
|
|
59
|
15
|
|
|
|
|
837
|
my ( $sig, $core, $rc ) = ( |
|
60
|
|
|
|
|
|
|
( $CHILD_ERROR & 127 ), |
|
61
|
|
|
|
|
|
|
( $CHILD_ERROR & 128 ), |
|
62
|
|
|
|
|
|
|
( $CHILD_ERROR >> 8 ), |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
15
|
|
|
|
|
1235
|
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
|
548
|
my ($module_name) = @_; |
|
72
|
|
|
|
|
|
|
## no critic(BuiltinFunctions::ProhibitStringyEval) |
|
73
|
12
|
|
|
|
|
785
|
my $eval_result = eval "require $module_name; '$module_name'->import; 1"; |
|
74
|
12
|
50
|
|
|
|
110
|
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
|
|
86
|
use lib 'config'; |
|
|
11
|
|
|
|
|
38
|
|
|
|
11
|
|
|
|
|
83
|
|
|
82
|
12
|
|
|
|
|
25
|
$eval_result = eval { require Marpa::R2::Config; 1 }; |
|
|
12
|
|
|
|
|
5364
|
|
|
|
12
|
|
|
|
|
40
|
|
|
83
|
12
|
50
|
|
|
|
36
|
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
|
|
|
|
|
28
|
my $version_wanted = $Marpa::R2::VERSION_FOR_CONFIG{$module_name}; |
|
90
|
12
|
50
|
|
|
|
31
|
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
|
|
|
|
|
632
|
my $module_version = eval q{$} . $module_name . '::VERSION'; |
|
96
|
12
|
50
|
|
|
|
133
|
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: |