Hi there,
I've just added a really simple convenience function that skips the rest of the
tests in a suite. It's different from the normal skip() in that it doesn't
require nested named blocks.
This came about trying to find a better way to fix t/op/lfs.t in bleadperl. (I
have a patch for that as well that illustrates my dilemma. If anyone's
interested, I can post it as well.)
There may be a much more elegant way to solve this. I'm all ears. (The POD
patch may rather belong in Test::More instead of Test::Simple, as well.)
-- c
--- lib/Test/~More.pm Thu Sep 6 06:57:08 2001
+++ lib/Test/More.pm Fri Sep 14 23:36:28 2001
@@ -21,7 +21,7 @@
skip todo
pass fail
eq_array eq_hash eq_set
- skip
+ skip skip_rest
$TODO
plan
can_ok isa_ok
--- lib/Test/~Simple.pm Sat Sep 15 00:29:54 2001
+++ lib/Test/Simple.pm Sat Sep 15 00:29:30 2001
@@ -57,6 +57,7 @@
no strict 'refs';
my($caller) = caller;
*{$caller.'::ok'} = \&ok;
+ *{$caller.'::skip_rest'} = \&skip_rest;
}
@@ -199,6 +200,35 @@
return $test ? 1 : 0;
}
+=cut
+
+=over 4
+
+=item B<skip_rest>
+
+ skip_rest();
+ skip_rest( $why );
+
+skip_rest() is given an explanation as to why to skip the rest of the tests.
+It'll happily report "ok $testnum # skip $why" for each skipped test. If no
+reason is provided, it will just say that it skipped things. This is a
+last-resort test, to ditch things without having to wrap everything in a SKIP
+block.
+
+=cut
+
+
+sub skip_rest {
+ my($why) = shift;
+
+ my $msg;
+ for ($Num_Tests + 1 .. $Planned_Tests) {
+ _skipped($why);
+ ($why) = (split(/\n/, $why))[0];
+ }
+
+ exit(0);
+}
sub _skipped {
my($why) = shift;