| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Skip::UnlessExistsExecutable; |
|
2
|
5
|
|
|
5
|
|
3037
|
use strict; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
205
|
|
|
3
|
5
|
|
|
5
|
|
27
|
use warnings; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
249
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.041'; |
|
5
|
5
|
|
|
5
|
|
30
|
use base 'Test::Builder::Module'; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
622
|
|
|
6
|
5
|
|
|
5
|
|
155
|
use 5.008000; |
|
|
5
|
|
|
|
|
33
|
|
|
|
5
|
|
|
|
|
327
|
|
|
7
|
5
|
|
|
5
|
|
31
|
use File::Spec; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
175
|
|
|
8
|
5
|
|
|
5
|
|
4760
|
use File::Which qw(which); |
|
|
5
|
|
|
|
|
5749
|
|
|
|
5
|
|
|
|
|
447
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
31
|
use constant WIN32 => $^O eq 'MSWin32'; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
397
|
|
|
11
|
|
|
|
|
|
|
my $quote = WIN32 ? q/"/ : q/'/; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub import { |
|
14
|
5
|
|
|
5
|
|
42
|
my $class = shift; |
|
15
|
5
|
|
|
|
|
14
|
my $caller = caller(0); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# export methods |
|
18
|
|
|
|
|
|
|
{ |
|
19
|
5
|
|
|
5
|
|
27
|
no strict 'refs'; |
|
|
5
|
|
|
|
|
12
|
|
|
|
5
|
|
|
|
|
2959
|
|
|
|
5
|
|
|
|
|
10
|
|
|
20
|
5
|
|
|
|
|
14
|
*{"$caller\::skip_all_unless_exists"} = \&skip_all_unless_exists; |
|
|
5
|
|
|
|
|
62
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
5
|
|
|
|
|
3616
|
for my $executable (@_) { |
|
25
|
2
|
|
|
|
|
7
|
skip_all_unless_exists($executable); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub skip_all_unless_exists { |
|
30
|
5
|
|
|
5
|
0
|
23
|
my $executable = shift; |
|
31
|
5
|
|
|
|
|
15
|
my $found = can_execute($executable); |
|
32
|
|
|
|
|
|
|
|
|
33
|
5
|
100
|
|
|
|
2139
|
unless ($found) { |
|
34
|
|
|
|
|
|
|
my $skip_all = sub { |
|
35
|
2
|
|
|
2
|
|
29
|
my $builder = __PACKAGE__->builder; |
|
36
|
|
|
|
|
|
|
|
|
37
|
2
|
50
|
|
|
|
12
|
if ( not defined $builder->has_plan ) { |
|
|
|
50
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
$builder->skip_all(@_); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
elsif ( $builder->has_plan eq 'no_plan' ) { |
|
41
|
0
|
|
|
|
|
0
|
$builder->skip(@_); |
|
42
|
0
|
0
|
0
|
|
|
0
|
if ( $builder->can('parent') && $builder->parent ) { |
|
43
|
0
|
|
|
|
|
0
|
die bless {} => 'Test::Builder::Exception'; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
0
|
|
|
|
|
0
|
exit 0; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
else { |
|
48
|
2
|
|
|
|
|
9
|
for ( 1 .. $builder->has_plan ) { |
|
49
|
20
|
|
|
|
|
76
|
$builder->skip(@_); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
2
|
50
|
33
|
|
|
39
|
if ( $builder->can('parent') && $builder->parent ) { |
|
52
|
0
|
|
|
|
|
0
|
die bless {} => 'Test::Builder::Exception'; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
2
|
|
|
|
|
1512
|
exit 0; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
2
|
|
|
|
|
17
|
}; |
|
57
|
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
11
|
$skip_all->("The test requires '$executable' in PATH"); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub can_execute { |
|
63
|
5
|
|
|
5
|
0
|
9
|
my $path = shift; |
|
64
|
|
|
|
|
|
|
|
|
65
|
5
|
100
|
|
|
|
17
|
if ( is_file_path($path) ) { |
|
66
|
4
|
|
|
|
|
13
|
return can_execute_path($path); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
else { |
|
70
|
1
|
|
|
|
|
4
|
return which($path); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub can_execute_path { |
|
75
|
4
|
|
|
4
|
0
|
10
|
my $path = shift; |
|
76
|
4
|
100
|
|
|
|
137
|
if ( -x $path ) { |
|
77
|
2
|
50
|
33
|
|
|
15
|
if ( $path =~ /\s/ && $path !~ /^$quote/ ) { |
|
78
|
0
|
|
|
|
|
0
|
$path = "$quote$path$quote"; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
2
|
|
|
|
|
9
|
return $path; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
else { |
|
83
|
2
|
|
|
|
|
7
|
return; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub is_file_path { |
|
88
|
5
|
|
|
5
|
0
|
8
|
my $path = shift; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# hmm |
|
91
|
5
|
|
|
|
|
11
|
my $dsep = "\/"; |
|
92
|
5
|
100
|
|
|
|
84
|
return 1 if $path =~ /$dsep/; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |