Commit | Line | Data |
b965d173 |
1 | #!/usr/bin/perl -w |
2 | |
3 | use strict; |
4 | use lib 't/lib'; |
5 | |
6 | use Test::More tests => 5; |
7 | |
8 | use File::Spec; |
9 | use Test::Harness; |
10 | |
11 | { |
12 | |
13 | #todo_skip 'Harness compatibility incomplete', 5; |
14 | #local $TODO = 'Harness compatibility incomplete'; |
15 | my $died; |
16 | |
17 | sub prepare_for_death { |
18 | $died = 0; |
19 | return sub { $died = 1 } |
20 | } |
21 | |
fbd6575c |
22 | my $sample_tests; |
27fc0087 |
23 | if ( $ENV{PERL_CORE} ) { |
24 | my $updir = File::Spec->updir; |
25 | $sample_tests |
26 | = File::Spec->catdir( $updir, 'ext', 'Test', 'Harness', 't', |
27 | 'sample-tests' ); |
28 | } |
29 | else { |
30 | my $curdir = File::Spec->curdir; |
31 | $sample_tests = File::Spec->catdir( $curdir, 't', 'sample-tests' ); |
fbd6575c |
32 | } |
b965d173 |
33 | |
34 | { |
35 | local $SIG{__DIE__} = prepare_for_death(); |
36 | eval { _runtests( File::Spec->catfile( $sample_tests, "simple" ) ); }; |
37 | ok( !$@, "simple lives" ); |
38 | is( $died, 0, "Death never happened" ); |
39 | } |
40 | |
41 | { |
42 | local $SIG{__DIE__} = prepare_for_death(); |
43 | eval { |
44 | _runtests( File::Spec->catfile( $sample_tests, "too_many" ) ); |
45 | }; |
46 | ok( $@, "error OK" ); |
47 | ok( $@ =~ m[Failed 1/1], "too_many dies" ); |
48 | is( $died, 1, "Death happened" ); |
49 | } |
50 | } |
51 | |
52 | sub _runtests { |
53 | my (@tests) = @_; |
54 | |
55 | local $ENV{PERL_TEST_HARNESS_DUMP_TAP} = 0; |
56 | local $ENV{HARNESS_VERBOSE} = 0; |
57 | local $ENV{HARNESS_DEBUG} = 0; |
58 | local $ENV{HARNESS_TIMER} = 0; |
59 | |
60 | local $Test::Harness::Verbose = -9; |
61 | |
62 | runtests(@tests); |
63 | } |
64 | |
65 | # vim:ts=4:sw=4:et:sta |