Commit | Line | Data |
d1ef75db |
1 | #!/usr/bin/perl -w |
2 | |
3 | BEGIN { |
4 | if ( $ENV{PERL_CORE} ) { |
5 | chdir 't'; |
6 | @INC = ('../lib', 'lib'); |
7 | } |
8 | else { |
9 | unshift @INC, 't/lib'; |
10 | } |
11 | } |
12 | |
13 | use strict; |
14 | |
15 | use Test::More tests => 6; |
e7738894 |
16 | use File::Spec; |
d1ef75db |
17 | |
18 | BEGIN { |
19 | use_ok( 'Test::Harness' ); |
20 | } |
21 | |
22 | my $died; |
23 | sub prepare_for_death { $died = 0; } |
24 | sub signal_death { $died = 1; } |
25 | |
e7738894 |
26 | my $Curdir = File::Spec->curdir; |
27 | my $SAMPLE_TESTS = $ENV{PERL_CORE} |
28 | ? File::Spec->catdir($Curdir, 'lib', 'sample-tests') |
29 | : File::Spec->catdir($Curdir, 't', 'sample-tests'); |
30 | |
d1ef75db |
31 | PASSING: { |
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 | |
39 | FAILING: { |
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 | } |