line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl |
2
|
|
|
|
|
|
|
package Test::OnlySome::RerunFailed; |
3
|
10
|
|
|
10
|
|
806209
|
use 5.012; |
|
10
|
|
|
|
|
119
|
|
4
|
10
|
|
|
10
|
|
62
|
use strict; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
200
|
|
5
|
10
|
|
|
10
|
|
47
|
use warnings; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
338
|
|
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
56
|
use Carp qw(croak); |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
511
|
|
8
|
10
|
|
|
10
|
|
3743
|
use Import::Into; |
|
10
|
|
|
|
|
21690
|
|
|
10
|
|
|
|
|
352
|
|
9
|
10
|
|
|
10
|
|
5060
|
use Best [ [qw(YAML::XS YAML)], qw(LoadFile) ]; |
|
10
|
|
|
|
|
40679
|
|
|
10
|
|
|
|
|
72
|
|
10
|
10
|
|
|
10
|
|
42075
|
use Data::Dumper; # for verbose |
|
10
|
|
|
|
|
68214
|
|
|
10
|
|
|
|
|
629
|
|
11
|
|
|
|
|
|
|
|
12
|
10
|
|
|
10
|
|
3422
|
use Test::OnlySome::PathCapsule; |
|
10
|
|
|
|
|
25
|
|
|
10
|
|
|
|
|
445
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.001003'; |
15
|
|
|
|
|
|
|
|
16
|
10
|
|
|
10
|
|
67
|
use constant DEFAULT_FILENAME => '.onlysome.yml'; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
4217
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Docs {{{2 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Test::OnlySome::RerunFailed - Load Test::OnlySome, and skip tests based on a file on disk |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 INSTALLATION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
See L, with which this module is distributed. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use Test::OnlySome::RerunFailed; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This will load L and configure it to skip any test marked |
33
|
|
|
|
|
|
|
as a clean pass by the last run of L. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 OPTIONS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
The C |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item C<< filename => 'some filename' >> |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Specify the file from which to read test results. The default is |
44
|
|
|
|
|
|
|
C<.onlysome.yml>. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item C<< verbose => 1 >> |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
If specified, print debugging information. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=back |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# }}}2 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub import { |
57
|
10
|
|
|
10
|
|
83
|
my $self = shift; |
58
|
10
|
|
|
|
|
43
|
my %opts = @_; # options from the `use` statement |
59
|
10
|
|
|
|
|
20
|
my @skips; # test numbers to skip |
60
|
10
|
|
|
|
|
36
|
my ($target, $caller_fn) = caller; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Process options |
63
|
10
|
|
50
|
|
|
52
|
$opts{filename} //= DEFAULT_FILENAME; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
print STDERR "# Called from $target in $caller_fn; YML in $opts{filename}\n" |
66
|
10
|
50
|
|
|
|
55
|
if $opts{verbose}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Read the YAML file |
69
|
10
|
|
|
|
|
66
|
my $fn = _localpath(1, $opts{filename}, 1); |
70
|
10
|
|
|
|
|
54
|
my $hrCfg; |
71
|
10
|
|
|
|
|
68
|
eval { $hrCfg = LoadFile($fn); }; |
|
10
|
|
|
|
|
194
|
|
72
|
|
|
|
|
|
|
|
73
|
10
|
50
|
|
|
|
2949
|
if($opts{verbose}) { |
74
|
0
|
|
|
|
|
0
|
my $msg = "Configuration:\n" . Dumper($hrCfg); |
75
|
0
|
|
|
|
|
0
|
$msg =~ s/^/# /gm; |
76
|
0
|
|
|
|
|
0
|
print STDERR $msg; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
10
|
100
|
|
|
|
39
|
if($hrCfg) { |
80
|
8
|
50
|
|
|
|
46
|
if($hrCfg->{$caller_fn}->{actual_passed}) { |
81
|
|
|
|
|
|
|
#my %skipped = map { $_ => 1 } |
82
|
|
|
|
|
|
|
# @{ $hrCfg->{$caller_fn}->{skipped} // \() }; |
83
|
|
|
|
|
|
|
#@skips = grep { !$skipped{$_} } @{ $hrCfg->{$caller_fn}->{actual_passed} }; |
84
|
8
|
|
|
|
|
20
|
@skips = @{ $hrCfg->{$caller_fn}->{actual_passed} }; |
|
8
|
|
|
|
|
49
|
|
85
|
|
|
|
|
|
|
print STDERR "# Skipping ", join(", ", @skips), "\n" |
86
|
|
|
|
|
|
|
if $opts{verbose} |
87
|
8
|
50
|
|
|
|
33
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Load Test::OnlySome with the appropriate skips |
91
|
|
|
|
|
|
|
'Test::OnlySome'->import::into($target, |
92
|
|
|
|
|
|
|
@skips ? 'skip' : (), @skips, |
93
|
10
|
100
|
|
|
|
295
|
$opts{verbose} ? (verbose => 1) : () |
|
|
50
|
|
|
|
|
|
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _localpath { # Return the path to a file in the same directory as the caller {{{2 |
98
|
10
|
50
|
|
10
|
|
37
|
my $calleridx = shift or croak 'Need a caller index'; |
99
|
10
|
50
|
|
|
|
32
|
my $newfn = shift or croak 'Need a filename'; |
100
|
10
|
|
|
|
|
21
|
my $moveup = shift; |
101
|
|
|
|
|
|
|
|
102
|
10
|
|
|
|
|
73
|
my ($package, $filename) = caller($calleridx); |
103
|
|
|
|
|
|
|
|
104
|
10
|
50
|
33
|
|
|
81
|
$filename = 'dummy' unless $filename && $filename ne '-e'; |
105
|
|
|
|
|
|
|
# Dummy filename assumed to be in cwd, if we're running from -e |
106
|
|
|
|
|
|
|
# or are otherwise without a caller. |
107
|
|
|
|
|
|
|
|
108
|
10
|
|
|
|
|
40
|
my $path = Test::OnlySome::PathCapsule->new($filename); |
109
|
|
|
|
|
|
|
# Assume the code up to this point hasn't changed cwd |
110
|
|
|
|
|
|
|
|
111
|
10
|
|
|
|
|
284
|
$path->up while $moveup--; |
112
|
10
|
|
|
|
|
63
|
$path->file($newfn); |
113
|
|
|
|
|
|
|
|
114
|
10
|
|
|
|
|
46
|
return $path->abs; |
115
|
|
|
|
|
|
|
} #}}}2 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
# vi: set fdm=marker fdl=1 fo-=ro: |