line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::More::Prefix; |
2
|
|
|
|
|
|
|
$Test::More::Prefix::VERSION = '0.005'; |
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Test::More::Prefix - Prefix some test output |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Inject a prefix in to Test::Builder's informational output. Useful for |
10
|
|
|
|
|
|
|
providing context in noisy and repetitive tests |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Test::More; |
15
|
|
|
|
|
|
|
use Test::More::Prefix qw/test_prefix/; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
note "Bar"; # Print '# Bar' |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
test_prefix("Foo"); |
20
|
|
|
|
|
|
|
note "Baz"; # Print '# Foo: Baz' |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
test_prefix(''); |
23
|
|
|
|
|
|
|
note "Bat"; # Print '# Bat' |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 IMPLEMENTATION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 Test::Builder |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
For versions of L<Test::Simple> which use the original L<Test::Builder> |
30
|
|
|
|
|
|
|
underneath, intercepts calls to L<Test::Builder>'s internal C<_print_comment> |
31
|
|
|
|
|
|
|
command and adds your prefix to all defined lines. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 Test::Stream |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
For versions of L<Test::Simple> which use this new-fangled L<Test::Stream> |
36
|
|
|
|
|
|
|
stuff, we wrap setting of L<TB2::Event::Log>'s C<message> attribute to prepend |
37
|
|
|
|
|
|
|
the prefix. This means that more of the possible output contains the prefix. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 FUNCTIONS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 test_prefix |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Set the prefix. Accepts a string. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 AUTHOR |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Peter Sergeant - C<pete@clueball.com> on behalf of |
48
|
|
|
|
|
|
|
L<Net-A-Porter|http://www.net-a-porter.com/>. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
1
|
|
21248
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
53
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
54
|
1
|
|
|
1
|
|
3
|
use Test::More; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
4
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub import { |
57
|
1
|
|
|
1
|
|
6
|
my ( $class, @args ) = @_; |
58
|
1
|
50
|
|
|
|
4
|
if ( $INC{'Test/Stream.pm'} ) { |
59
|
0
|
|
|
|
|
0
|
require Test::More::Prefix::TB2; |
60
|
0
|
|
|
|
|
0
|
Test::More::Prefix::TB2->import(@args); |
61
|
|
|
|
|
|
|
} else { |
62
|
1
|
|
|
|
|
424
|
require Test::More::Prefix::TB1; |
63
|
0
|
|
|
|
|
|
Test::More::Prefix::TB1->import(@args); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |