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

macperl-modules-digest V1 #8




macperl-modules-digest     Friday, March 12 1999     Volume 01 : Number 008



[MacPerl-Modules] Testing Tests
Re: [MacPerl-Modules] Testing Tests

----------------------------------------------------------------------

Date: Wed, 10 Mar 1999 12:57:09 -0400 (AST)
From: Arved Sandstrom <Arved_37@chebucto.ns.ca>
Subject: [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

------------------------------

Date: Wed, 10 Mar 1999 12:13:10 -0500
From: Chris Nandor <pudge@pobox.com>
Subject: Re: [MacPerl-Modules] Testing Tests

At 11.57 -0500 1999.03.10, Arved Sandstrom wrote:
>Are there any MacPerl issues around using IO::File->new_tmpfile? Just
>curious - it seems too good to be true. :-)

I use it for File::Sort.  I think it is essentially on a toolbox function.
You get a file opened in r/w mode that disappears when it is closed.


>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. :-)

I can't think of much offhand, but then, I am tired right now.

- --
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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

------------------------------

End of macperl-modules-digest V1 #8
***********************************


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