develooper Front page | perl.perl5.porters | Postings from January 2001

[PATCH Test.pm 1.14] (was Re: Unifying 'skip' and 'todo' test output)

Thread Previous | Thread Next
From:
Michael G Schwern
Date:
January 17, 2001 22:16
Subject:
[PATCH Test.pm 1.14] (was Re: Unifying 'skip' and 'todo' test output)
Message ID:
20010118001603.G21824@chaos.wustl.edu
On Wed, Jan 17, 2001 at 06:37:33PM -1000, Tim Jenness wrote:
> On Wed, 17 Jan 2001, Michael G Schwern wrote:
> This looks okay. One thing that has always surprised me with Test.pm is
> that it expects you to put the "skip" into the reason.
> 
>  i.e.   skip($reason)
> 
> expects $reason to start with "skip" (it adds the "#") even though you
> are using the "skip" function. I was going to patch this to add "skip"
> (and now "todo") but I'll wait until your patch unless you beat me to it.

That's tangental to the issue, and up to Joshua.  And it probably can't
be fixed without breaking backwards compatibility...

	# Currently works, but if "fixed" it will produce
	# '# skip skip lunch break'
	skip("skip lunch break");

However, you could always add a little logic to skip to help that...

--- Test.pm	2001/01/18 01:27:22	1.1
+++ Test.pm	2001/01/18 06:06:42
@@ -122,8 +122,11 @@
 sub skip ($$;$$) {
     my $whyskip = to_value(shift);
     if ($whyskip) {
+        $whyskip =~ s/^skip//i;  # backwards compatibility, old versions
+                                 # required the reason to start with 
+                                 # 'skip'
 	$whyskip = 'skip' if $whyskip =~ m/^\d+$/;
-	print $TESTOUT "ok $ntest # $whyskip\n";
+	print $TESTOUT "ok $ntest # skip $whyskip\n";
 	++ $ntest;
 	1;
     } else {

This also necesitates a change to t/skip.t

--- t/skip.t    2001/01/18 06:11:52     1.1
+++ t/skip.t    2001/01/18 06:12:09
@@ -30,8 +30,8 @@
 END { close F; unlink "skips" }
 
 __DATA__
-ok 1 # skip
+ok 1 # skip skip
 
-ok 2 # hop
+ok 2 # skip hop
 
-ok 3 # jump
+ok 3 # skip jump


The fact that this patch blows a regression test worries me.  Does
skip() have any valid utility if its first argument doesn't begin with
'skip'?  Is skip('hop') useful (before the patch)?


> The problem is exacerbated by the Test.pm documentation that doesn't
> explain this - you should be able to use Test.pm without having to
> understand how Test::Harness recognizes failures/skips/todo

Yes, the documentation for skip() (and ok()) is very unclear and never
explicitly documented.  The third argument to ok() is never really
explained at all!  I'm going to hold on patching this up until Joshua
gets a say in.


PS I'm going to be tidying up my personal testing code and releasing
it shortly.  Its nothing fabulous, but I'm getting tired of cutting
and pasting my ok() routines into my test scripts.


-- 
Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
You see, in this world there's two kinds of people.  Those with loaded
 guns, and those who dig.  Dig.
                 -- Blonde, "The Good, The Bad And The Ugly"

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About