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

[PATCH t/op/pack.t pod/perlhack.pod] Adding the failure diagnostic (was Re: [PATCH pod/perlhack.pod t/op/pack.t] Fixing bad testing advice)

From:
Michael G Schwern
Date:
August 28, 2001 06:57
Subject:
[PATCH t/op/pack.t pod/perlhack.pod] Adding the failure diagnostic (was Re: [PATCH pod/perlhack.pod t/op/pack.t] Fixing bad testing advice)
Message ID:
20010828095738.E17775@blackrider
On Tue, Aug 28, 2001 at 02:25:06PM +0100, Nicholas Clark wrote:
> Another would be to make a small ok function from something that can be
> cut&pasted into any of the core perl tests (ie stuff before lib/)

God, you're, like, *SO* last night. ;) I already did this, it's in
perlhack.


> Something that will issue a comment using caller() to find the line number
> of the failing test, and let the user pass in names for the tests.

I'll patch this in.

--- t/op/pack.t	2001/08/28 13:54:46	1.1
+++ t/op/pack.t	2001/08/28 13:55:52
@@ -19,6 +19,8 @@
     $out .= "ok $test\n";
     print $out;
 
+    printf "# Failed test at line %d\n", (caller)[2] unless $ok;
+
     $test++;
     return $ok;
 }
--- pod/perlhack.pod	2001/08/28 13:54:34	1.1
+++ pod/perlhack.pod	2001/08/28 13:55:17
@@ -1489,6 +1489,8 @@
         $out .= "ok $test\n";
         print $out;
 
+        printf "# Failed test at line %d\n", (caller)[2] unless $ok;
+
         $test++;
         return $ok;
     }



> Alternatively an ok() function and encouraging a style of
> 
> ok ($schwern->DonateBucksToYAS(500))
>   or print "# Schwern still has the money - there are " .
> 	$core->countUntestedModules() . " untested modules in the core\n";

You can already do exactly that with it.


-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>	     Kwalitee Is Job One
How can I stoop so low?  Years of practise, that's how. It's been hard
going but now I can stoop lower than a pygmy limbo dancer.
	-- BOFH



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