Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libtest-harness-perl / libtest-harness-perl-3.12 / t / compat / failure.t
diff --git a/dev/i386/libtest-harness-perl/libtest-harness-perl-3.12/t/compat/failure.t b/dev/i386/libtest-harness-perl/libtest-harness-perl-3.12/t/compat/failure.t
new file mode 100644 (file)
index 0000000..c1b902b
--- /dev/null
@@ -0,0 +1,59 @@
+#!/usr/bin/perl -w
+
+use strict;
+use lib 't/lib';
+
+use Test::More tests => 5;
+
+use File::Spec;
+use Test::Harness;
+
+{
+
+    #todo_skip 'Harness compatibility incomplete', 5;
+    #local $TODO = 'Harness compatibility incomplete';
+    my $died;
+
+    sub prepare_for_death {
+        $died = 0;
+        return sub { $died = 1 }
+    }
+
+    my $curdir = File::Spec->curdir;
+    my $sample_tests
+      = $ENV{PERL_CORE}
+      ? File::Spec->catdir( $curdir, 'lib', 'sample-tests' )
+      : File::Spec->catdir( $curdir, 't',   'sample-tests' );
+
+    {
+        local $SIG{__DIE__} = prepare_for_death();
+        eval { _runtests( File::Spec->catfile( $sample_tests, "simple" ) ); };
+        ok( !$@, "simple lives" );
+        is( $died, 0, "Death never happened" );
+    }
+
+    {
+        local $SIG{__DIE__} = prepare_for_death();
+        eval {
+            _runtests( File::Spec->catfile( $sample_tests, "too_many" ) );
+        };
+        ok( $@, "error OK" );
+        ok( $@ =~ m[Failed 1/1], "too_many dies" );
+        is( $died, 1, "Death happened" );
+    }
+}
+
+sub _runtests {
+    my (@tests) = @_;
+
+    local $ENV{PERL_TEST_HARNESS_DUMP_TAP} = 0;
+    local $ENV{HARNESS_VERBOSE}            = 0;
+    local $ENV{HARNESS_DEBUG}              = 0;
+    local $ENV{HARNESS_TIMER}              = 0;
+
+    local $Test::Harness::Verbose = -9;
+
+    runtests(@tests);
+}
+
+# vim:ts=4:sw=4:et:sta