Adapt the new Test::Harness test to the core
[p5sagit/p5-mst-13.2.git] / lib / Test / Harness / t / failure.t
CommitLineData
d1ef75db 1#!/usr/bin/perl -w
2
3BEGIN {
4 if ( $ENV{PERL_CORE} ) {
5 chdir 't';
6 @INC = ('../lib', 'lib');
7 }
8 else {
9 unshift @INC, 't/lib';
10 }
11}
12
13use strict;
14
15use Test::More tests => 6;
e7738894 16use File::Spec;
d1ef75db 17
18BEGIN {
19 use_ok( 'Test::Harness' );
20}
21
22my $died;
23sub prepare_for_death { $died = 0; }
24sub signal_death { $died = 1; }
25
e7738894 26my $Curdir = File::Spec->curdir;
27my $SAMPLE_TESTS = $ENV{PERL_CORE}
28 ? File::Spec->catdir($Curdir, 'lib', 'sample-tests')
29 : File::Spec->catdir($Curdir, 't', 'sample-tests');
30
d1ef75db 31PASSING: {
32 local $SIG{__DIE__} = \&signal_death;
33 prepare_for_death();
e7738894 34 eval { runtests( File::Spec->catfile( $SAMPLE_TESTS, "simple" ) ) };
d1ef75db 35 ok( !$@, "simple lives" );
36 is( $died, 0, "Death never happened" );
37}
38
39FAILING: {
40 local $SIG{__DIE__} = \&signal_death;
41 prepare_for_death();
e7738894 42 eval { runtests( File::Spec->catfile( $SAMPLE_TESTS, "too_many" ) ) };
d1ef75db 43 ok( $@, "$@" );
44 ok( $@ =~ m[Failed 1/1], "too_many dies" );
45 is( $died, 1, "Death happened" );
46}