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