Debian lenny version packages
[pkg-perl] / deb-src / libtest-harness-perl / libtest-harness-perl-3.12 / t / compat / failure.t
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
22     my $curdir = File::Spec->curdir;
23     my $sample_tests
24       = $ENV{PERL_CORE}
25       ? File::Spec->catdir( $curdir, 'lib', 'sample-tests' )
26       : File::Spec->catdir( $curdir, 't',   'sample-tests' );
27
28     {
29         local $SIG{__DIE__} = prepare_for_death();
30         eval { _runtests( File::Spec->catfile( $sample_tests, "simple" ) ); };
31         ok( !$@, "simple lives" );
32         is( $died, 0, "Death never happened" );
33     }
34
35     {
36         local $SIG{__DIE__} = prepare_for_death();
37         eval {
38             _runtests( File::Spec->catfile( $sample_tests, "too_many" ) );
39         };
40         ok( $@, "error OK" );
41         ok( $@ =~ m[Failed 1/1], "too_many dies" );
42         is( $died, 1, "Death happened" );
43     }
44 }
45
46 sub _runtests {
47     my (@tests) = @_;
48
49     local $ENV{PERL_TEST_HARNESS_DUMP_TAP} = 0;
50     local $ENV{HARNESS_VERBOSE}            = 0;
51     local $ENV{HARNESS_DEBUG}              = 0;
52     local $ENV{HARNESS_TIMER}              = 0;
53
54     local $Test::Harness::Verbose = -9;
55
56     runtests(@tests);
57 }
58
59 # vim:ts=4:sw=4:et:sta