Debian Codegraph @

cpan/Test-Harness/t/compat/failure.t

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