On Tue, Mar 28, 2006 at 08:22:25PM +1000 Adam Kennedy wrote: > Tassilo von Parseval wrote: > >Hi, > > > >I was told that Test::More patches should now go to this list so here we > >go. > > > >The attached patch serves as a draft for enabling test-scripts that fork > >without the test-counter getting confused. It does so by using a > >Storable imaged shared between the processes. The patch however does > >need some modification because there's a race condition in there. It > >uses lock_nstore and lock_retrieve to store the current test-metrics > >thusly: > > To get back to the subject at hand, can you explain what the > implications of this might be for portability, given the universality of > Test::More. > > Wouldn't this patch introduce IPC and forking portability issues to > Test::More, when it currently does have these issues (that I'm aware of).
Forking issues no, IPC issues yes. My patch doesn't make Test::More fork, it only adds means of synchronizing processes that were forked in a test-script. The only unportable part is the locking of the Storable image. Ideally this should get factored out in two methods acquire_lock() and release_lock(), thusly: sub acquire_lock { my $self = shift; if (HAVE_FLOCK) { flock $self->{Forked} => LOCK_EX; } elsif (HAVE_EXCL_SYSOPEN) { select undef, undef, undef, 0.05 while not sysopen my $lockf, $self->{Lockfile}, O_CREAT|O_EXCL; } elsif (HAVE_WHATEVER_OTHER_METHOD) { ... } ... } sub release_lock { my $self = shift; if (HAVE_FLOCK) { flock $self->{Forked} => LOCK_UN; } elsif (HAVE_EXCL_SYSOPEN) { unlink $self->{Lockfile}; } ... } > Do you think this might work better, or could be implemented as, a > seperate Test::Fork type module? It certainly could be done. But it would essentially share 90% of its code with Test::Builder. It's simple really: Either my proposed method is robust in which case it can go into Test-Simple. Or it isn't. Then there's no need to implement it as a separate module. :-) Cheers, Tassilo -- use bigint; $n=71423350343770280161397026330337371139054411854220053437565440; $m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);