summaryrefslogtreecommitdiff
path: root/lib/Test
diff options
context:
space:
mode:
authorAndreas König <a.koenig@mind.de>2000-12-09 18:14:25 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2000-12-10 04:39:19 +0000
commitd667a7e6cc929099334c86c1f8ba43c1add38609 (patch)
treecb2200563c1df675e088590a64a63daea84d92f2 /lib/Test
parentcbc5248d01a71061a57c964b98f44bd4cb3a75c0 (diff)
downloadperl-d667a7e6cc929099334c86c1f8ba43c1add38609.tar.gz
Re: PATCH: Let Test::Harness bail out early (Was: Testing module dependencies)
Message-ID: <m3wvd9o9lq.fsf@ak-71.mind.de> p4raw-id: //depot/perl@8069
Diffstat (limited to 'lib/Test')
-rw-r--r--lib/Test/Harness.pm25
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/Test/Harness.pm b/lib/Test/Harness.pm
index a8038df694..febc4fc8d0 100644
--- a/lib/Test/Harness.pm
+++ b/lib/Test/Harness.pm
@@ -1,3 +1,4 @@
+# -*- Mode: cperl; cperl-indent-level: 4 -*-
package Test::Harness;
use 5.005_64;
@@ -11,7 +12,7 @@ our($VERSION, $verbose, $switches, $have_devel_corestack, $curtest,
$columns, @ISA, @EXPORT, @EXPORT_OK);
$have_devel_corestack = 0;
-$VERSION = "1.1605";
+$VERSION = "1.1606";
$ENV{HARNESS_ACTIVE} = 1;
@@ -158,7 +159,9 @@ sub runtests {
$next = $this;
}
$next = $this + 1;
- }
+ } elsif (/^Bail out!\s*(.*)/i) { # magic words
+ die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n");
+ }
}
$fh->close; # must close to reap child resource values
my $wstatus = $ignore_exitcode ? 0 : $?; # Can trust $? ?
@@ -259,7 +262,7 @@ sub runtests {
}
}
my $t_total = timediff(new Benchmark, $t_start);
-
+
if ($^O eq 'VMS') {
if (defined $old5lib) {
$ENV{PERL5LIB} = $old5lib;
@@ -462,7 +465,7 @@ script supplies test numbers again. So the following test script
ok
END
-will generate
+will generate
FAILED tests 1, 3, 6
Failed 3/6 tests, 50.00% okay
@@ -488,6 +491,15 @@ C<1..0> line emitted if the test is skipped completely:
1..0 # Skipped: no leverage found
+As an emergency measure, a test script can decide that further tests
+are useless (e.g. missing dependencies) and testing should stop
+immediately. In that case the test script prints the magic words
+
+ Bail out!
+
+to standard output. Any message after these words will be displayed by
+C<Test::Harness> as the reason why testing is stopped.
+
=head1 EXPORT
C<&runtests> is exported by Test::Harness per default.
@@ -518,6 +530,11 @@ printed in a message similar to the above.
If not all tests were successful, the script dies with one of the
above messages.
+=item C<FAILED--Further testing stopped%s>
+
+If a single subtest decides that further testing will not make sense,
+the script dies with this message.
+
=back
=head1 ENVIRONMENT