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