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
23# TB methods expect to be wrapped
24my $ok           = sub { shift->ok(@_) };
25my $plan         = sub { shift->plan(@_) };
26my $done_testing = sub { shift->done_testing(@_) };
27
28my $Test = Test::Builder->new;
29
30# Set up a builder to record some failing tests.
31{
32    my $tb = Test::Builder::NoOutput->create;
33    $tb->$plan( tests => 5 );
34
35#line 28
36    $tb->$ok( 1, 'passing' );
37    $tb->$ok( 2, 'passing still' );
38    $tb->$ok( 3, 'still passing' );
39    $tb->$ok( 0, 'oh no!' );
40    $tb->$ok( 0, 'damnit' );
41    $tb->_ending;
42
43    $Test->is_eq($tb->read('out'), <<OUT);
441..5
45ok 1 - passing
46ok 2 - passing still
47ok 3 - still passing
48not ok 4 - oh no!
49not ok 5 - damnit
50OUT
51
52    $Test->is_eq($tb->read('err'), <<ERR);
53#   Failed test 'oh no!'
54#   at $0 line 31.
55#   Failed test 'damnit'
56#   at $0 line 32.
57# Looks like you failed 2 tests of 5.
58ERR
59
60    $Test->$done_testing(2);
61}
62