[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-Modules] Testing Tests



Hi, all

(Well, leastways everyone on this particular list. :-) )

As a result of building Bit::Vector the lack of a Test::Harness useable
with MacPerl became really an issue. Bit::Vector has over 67 thousand
subtests.

As a temporary hack I included a little script with our binary of
Bit::Vector, and a suggested MPW For loop to run the script on each 't'
file.

This is dissatisfying. So last night I played around with some ideas. What
I have at the moment is basically this:

@all_tests = @ARGV or (some combo of opendir+readdir+closedir)

foreach $testfile (@all_tests) {

# create tempfile (I'm using IO::File->new_tmpfile)
...

# initialize local counters
$ok = 0, $nok = 0, ...

# require the current test script into a known namespace
package Test;	# something safe
require "$::testfile"; # this is actually wrapped in an eval

# zap the Test namespace
%Test:: = ()

# do whatever for test-by-test printout
...

# close the temporary file
$tmpf->close;
}

# any final summary printout code
...

__END__

This is pseudocode, mostly, but you get the drift. It evidently works, but
I'd like hardnosed commentary.

Are there any MacPerl issues around using IO::File->new_tmpfile? Just
curious - it seems too good to be true. :-)

What about the approach of require'ing each 't' file into a separate
"Test" namespace, and then, since the temporary file, which is being read
line by line to get 'ok/not ok' stats, has been created, immediately
cleaning out the %Test:: symbol table? I had previously tried just wiping
out any subroutines added by the 't' file, but this was insufficient.

There are probably a few other minor issues lurking here or there - in
particular, there may need to be more resetting after each 't' script, not
just extirpating the added symbols. I'm thinking of pragmas and such.

Any ideas, comments, better approaches? I really can't think of anything
better given what we have to work with, but I could be wrong. :-)

Arved



==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-modules-request@macperl.org