Commit | Line | Data |
---|---|---|
33459055 | 1 | #!perl -w |
3e887aae | 2 | |
3 | # Simple test of what failure output looks like | |
4dd974da | 4 | |
15db8fc4 | 5 | BEGIN { |
a9153838 | 6 | if( $ENV{PERL_CORE} ) { |
7 | chdir 't'; | |
8 | @INC = ('../lib', 'lib'); | |
9 | } | |
10 | else { | |
11 | unshift @INC, 't/lib'; | |
12 | } | |
15db8fc4 | 13 | } |
14 | ||
33459055 | 15 | use strict; |
33459055 | 16 | |
3e887aae | 17 | # Normalize the output whether we're running under Test::Harness or not. |
30e302f8 | 18 | local $ENV{HARNESS_ACTIVE} = 0; |
33459055 | 19 | |
3e887aae | 20 | use Test::Builder; |
21 | use Test::Builder::NoOutput; | |
33459055 | 22 | |
3e887aae | 23 | my $Test = Test::Builder->new; |
4dd974da | 24 | |
3e887aae | 25 | # Set up a builder to record some failing tests. |
26 | { | |
27 | my $tb = Test::Builder::NoOutput->create; | |
28 | $tb->plan( tests => 5 ); | |
4dd974da | 29 | |
3e887aae | 30 | #line 28 |
31 | $tb->ok( 1, 'passing' ); | |
32 | $tb->ok( 2, 'passing still' ); | |
33 | $tb->ok( 3, 'still passing' ); | |
34 | $tb->ok( 0, 'oh no!' ); | |
35 | $tb->ok( 0, 'damnit' ); | |
36 | $tb->_ending; | |
4dd974da | 37 | |
3e887aae | 38 | $Test->is_eq($tb->read('out'), <<OUT); |
4dd974da | 39 | 1..5 |
40 | ok 1 - passing | |
41 | ok 2 - passing still | |
42 | ok 3 - still passing | |
43 | not ok 4 - oh no! | |
44 | not ok 5 - damnit | |
45 | OUT | |
46 | ||
3e887aae | 47 | $Test->is_eq($tb->read('err'), <<ERR); |
b1ddf169 | 48 | # Failed test 'oh no!' |
3e887aae | 49 | # at $0 line 31. |
b1ddf169 | 50 | # Failed test 'damnit' |
3e887aae | 51 | # at $0 line 32. |
33459055 | 52 | # Looks like you failed 2 tests of 5. |
53 | ERR | |
4dd974da | 54 | |
3e887aae | 55 | $Test->done_testing(2); |
4dd974da | 56 | } |