There is no skip_rest(), but skip_all() can do that job, with a tiny enhancement


sub skip_all {
-    if (@_) {
-       print STDOUT "1..0 # Skipped: @_\n";
+    if ($test == 1) {
+       if (@_) {
+           print STDOUT "1..0 \# Skipped: @_\n";
+       } else {
+           print STDOUT "1..0\n";
+       }
    } else {
-       print STDOUT "1..0\n";
+       # allow skipping all remaining tests
+       for ($test..$planned) {
+           print STDOUT $test++, " \# skip @_\n";
+       }
    }
    exit(0);
}

Tested with:

#!./perl
chdir 't' if -d 't';
@INC = ('../lib','.');
require "test.pl";
plan(42);
ok(1);
skip_all();


there are obviously ways to do it currently, but theyre suboptimal.

the patch above prints $planned - $test different lines,
IFF TAP allows it,
13..25 # skipped: various reasons
could be legitimate way to skip rest, at least when a plan is established already.
13..0 # skipped
could also be legitimate
thus avoiding 12 boring skip lines.


I think this is open to interpretation, at least its not specifically excluded in
http://www.petdance.com/random/tap.html#skipping_tests




The real goal is to test the waters for a similar addition to Test::More,
so that some test files can be simplified to

use_ok ( Foo );
$foo = new Foo;
isa_ok ($foo, 'Foo');
skip_all "no Bar available" unless eval "require 'Bar'";
...

Ok, not a particularly compelling example,
but I hate getting my skip-counts wrong just cuz I added a few tests.
Also, given that tests should ideally be order independent,
its good to use use_ok, isa_ok at the top of your test-scripts,
and thus skip_rest should be available.

So I just want to see if interpretations are locked down b4 I went down a garden path.



Reply via email to