| line |
stmt |
bran |
path |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
package Test::Mock::Cmd::TestUtils; |
|
2
|
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
|
7
|
|
190984
|
use strict; |
|
|
7
|
|
|
|
|
|
23
|
|
|
|
7
|
|
|
|
|
|
314
|
|
|
4
|
7
|
|
|
|
7
|
|
41
|
use warnings; |
|
|
7
|
|
|
|
|
|
12
|
|
|
|
7
|
|
|
|
|
|
2065
|
|
|
5
|
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
sub do_in_fork { |
|
7
|
34
|
|
|
|
34
|
0
|
479
|
my ( $code, @args ) = @_; |
|
8
|
34
|
|
|
|
|
|
34170
|
my $pid = fork(); |
|
9
|
34
|
50
|
|
|
|
|
1947
|
if ( not defined $pid ) { |
|
|
|
100
|
|
|
|
|
|
|
|
10
|
0
|
|
|
|
|
|
0
|
die "Could not fork: $!"; |
|
11
|
|
|
|
|
|
|
|
} |
|
12
|
|
|
|
|
|
|
|
elsif ( $pid == 0 ) { |
|
13
|
4
|
|
|
|
|
|
1036
|
$code->(@args); |
|
14
|
0
|
|
|
|
|
|
0
|
exit 1; |
|
15
|
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
else { |
|
17
|
30
|
|
|
|
|
|
5519373
|
waitpid( $pid, 0 ); # parent |
|
18
|
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
sub test_more_is_like_return_42 { |
|
22
|
24
|
|
|
|
24
|
0
|
3731
|
my ( $got, $expected, $name ) = @_; |
|
23
|
24
|
50
|
|
|
|
|
156
|
ref($expected) eq 'Regexp' ? Test::More::like( $got, $expected, $name ) : Test::More::is( $got, $expected, $name ); |
|
24
|
24
|
|
|
|
|
|
10822
|
return 42; |
|
25
|
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
# use Test::Output; # rt 72976 |
|
28
|
|
|
|
|
|
|
|
# The Perl::Critic test failures will go away when this temp workaround goes away |
|
29
|
|
|
|
|
|
|
|
sub tmp_stdout_like_rt_72976 { |
|
30
|
42
|
|
|
|
42
|
0
|
59428
|
my ( $func, $regex, $name ) = @_; |
|
31
|
42
|
|
|
|
|
|
111
|
my $output = ''; |
|
32
|
|
|
|
|
|
|
|
{ |
|
33
|
42
|
|
|
|
|
|
81
|
unlink "tmp.$$.tmp"; |
|
|
42
|
|
|
|
|
|
1650
|
|
|
34
|
|
|
|
|
|
|
|
|
|
35
|
7
|
|
|
|
7
|
|
53
|
no warnings 'once'; |
|
|
7
|
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
|
2106
|
|
|
36
|
42
|
50
|
|
|
|
|
842
|
open OLDOUT, '>&STDOUT' or die "Could not dup STDOUT: $!"; ## no critic |
|
37
|
42
|
|
|
|
|
|
153
|
close STDOUT; |
|
38
|
|
|
|
|
|
|
|
|
|
39
|
42
|
50
|
|
|
|
|
4853
|
open STDOUT, '>', "tmp.$$.tmp" or die "Could not redirect STDOUT: $!"; |
|
40
|
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
# \$output does not capture system() |
|
42
|
|
|
|
|
|
|
|
# open STDOUT, '>', \$output or die "Could not redirect STDOUT: $!"; |
|
43
|
|
|
|
|
|
|
|
|
|
44
|
42
|
|
|
|
|
|
244
|
$func->(); |
|
45
|
38
|
50
|
|
|
|
|
12346
|
open STDOUT, '>&OLDOUT' or die "Could not restore STDOUT: $!"; ## no critic |
|
46
|
|
|
|
|
|
|
|
|
|
47
|
38
|
50
|
|
|
|
|
4012
|
open my $fh, '<', "tmp.$$.tmp" or die "Could not open temp file: $!"; |
|
48
|
38
|
|
|
|
|
|
1885
|
while ( my $line = <$fh> ) { |
|
49
|
38
|
|
|
|
|
|
642
|
$output .= $line; |
|
50
|
|
|
|
|
|
|
|
} |
|
51
|
38
|
|
|
|
|
|
664
|
close $fh; |
|
52
|
|
|
|
|
|
|
|
|
|
53
|
38
|
|
|
|
|
|
4861
|
unlink "tmp.$$.tmp"; |
|
54
|
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
# use Data::Dumper;diag(Dumper([$output,$regex,$name])); |
|
57
|
38
|
|
|
|
|
|
628
|
Test::More::like( $output, $regex, $name ); |
|
58
|
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
1; |
|
61
|
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
__END__ |