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

[PATCH lib/Test/Harness.pm] (was Re: Patch 7989 breaks the Schwern style of testing)

Thread Next
From:
Michael G Schwern
Date:
January 17, 2001 16:39
Subject:
[PATCH lib/Test/Harness.pm] (was Re: Patch 7989 breaks the Schwern style of testing)
Message ID:
20010117193904.B3093@blackrider.aocn.com
While I throughly enjoy being a pathological case, is my test output
broken, or did Test::Harness break?  The 1.1604 man page defines
/^(not\s+)?ok\b/ as the regex for determining if something is test
output (shouldn't that be /i?), but doesn't clearly define what is a
successful test and what is a failed one.

I find having stuff after the "ok 3" very useful.  My motivation was
that "not ok 35" caused me to have to scan through my test counting
"ok" calls to find which test failed.  Tedious.  Numbering the tests
in the testing code was unmaintianable (every time I inserted a test I
had to redo the numbers).  Thus, I label them.  "not ok 35 - pidgeon
toed" means I just scan through for the string "pidgeon toed" to find
the failed test.

Disallowing this will break pretty much all of my modules, then I
would have to cry.


So, I'm tearing apart Test::Harness to fix this as well as add in
tests.  Irony of ironies, our testing harness does not have a test!


Random mumblings about harness.patch...

I've found this "todo" thing in the code.  It looks like it comes from
an old patch from Joshua Pritkin and is sort of documented in Test.pm
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1998-02/msg01624.html
I'm going to leave it for now and discuss it in my next message.

Some of these regexes make my eyes bleed.  I'm going to expand them
out a bit.

I'm making the /ok/, /not ok/ tests case insensitive.  I don't see any
reason they have to be pedantic about case.  I'm also allowing
/skip(ped)?/i

The documentation needs some partitioning, I'm throwing in some =items.

runtests() is 330 lines long and reads like stereo instructions.
Worse, it has formatting and printing code inside of it, making it
difficult to test.  I'm breaking it up.  This will involve collecting
all the various lexical variables into a couple of hashes (%test and
%tot) to ease parameter passing into the newly formed routines.
_runtests(), _show_results(), _read_header(), _parse_test_line(),
_bonusmsg(), _close_fh(), _set_switches(), _dubious_return(),
_garbled_output, _create_fmts() all sprang from this.  I only went so
far in this as needed for my purposes, but its in the right direction.

In order to keep my sanity I'm making all global variables Upper_Case.
$verbose and $switches will be preserved as aliases.

Is the '1..N' leader required?  Is it required that it comes before
any test output?  With the current logic, its not either.  Its also
possible to have two '1..N' lines in a single test file, with the
second overwriting the first.  This bodes ill.  The docs imply its
expected, so I'm making the code enforce this.  It also simplifies
things a bit.


t/lib/test_harness.t and t/lib/sample_tests/*.t (in
sample_tests.tar.gz) contain basic tests for Test::Harness.


PS  Hopefully I won't raise havoc with this patch, I finally got an
rsync'd version of the perl source.

PPS  I'm going to follow this up with some ideas about unifying the way
'todo' and 'skip' are handled.

-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
If you have to shoot, shoot!  Don't talk.
		 -- Tuco, "The Good, The Bad And The Ugly"

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