Move the modules, tests, prove and Changes file from lib/ to
[p5sagit/p5-mst-13.2.git] / ext / Test / Harness / t / compat / failure.t
CommitLineData
b965d173 1#!/usr/bin/perl -w
2
3use strict;
4use lib 't/lib';
5
6use Test::More tests => 5;
7
8use File::Spec;
9use 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
46sub _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