On Wed, Nov 06, 2002 at 07:18:14PM -0500, Michael G Schwern wrote: > On Sat, Oct 26, 2002 at 04:22:49PM +0100, Nicholas Clark wrote: > > However, I'd like to be able to cleanly print out my random number seed to > > STDERR (or whatever Test::Builder's correct name for this is) if it believes > > that any tests have failed, and I can't see a clean way to do this. > > In an END block, grab the T::B object and check the summary(). > > #!/usr/bin/perl -w > > use Test::More tests => 1; > > pass('foo'); > > END { > my $failed = grep!$_, Test::More->builder->summary; > diag $failed ? "Failed\n" : "Passed\n"; > } > > The only trouble there is if the test as a whole fails during the ending, > like because the wrong number of tests were run or the exit code was odd, > the above logic is too simple to know that. You have to go through the > sort of logic _ending() does.
I think that will do fine for what I need. I'm only reporting extra diagnostics if all tests failed. I now have this wierd thought that I may have asked you this question in Munich and you told me this answer before. If so, oops. > > Not sure to add in an ending callback or an is_passing() method. Or both. > > > BTW How does one get the current srand if you use the one set by Perl? I don't think it's possible. I think I'm going to have to overload rand and do the srand thing by hand. (and probably overload srand in case anyone else is attempting to go behind my back) Nicholas Clark