dragonchild has asked for the wisdom of the Perl Monks concerning the following question:
001_sometest.t -------------- use_ok( $CLASS ); my $obj = $CLASS->new( filename => $logfile, ); isa_ok( $obj, $CLASS ); ok( -e $logfile, "$CLASS created logfile" ); open my $fh, '>>', $logfile or die "Cannot open '$logfile' for appending: $!\n"; my $rc = flock( $fh, LOCK_EX | LOCK_NB ); ok( !$rc, "Cannot flock $logfile" );
The point is that new() will open $filename for appending, then flock it with LOCK_EX. All this is happening successfully. Except, I don't seem to be able to test that I got the flock correctly. Is this because I'm trying to test a process-level lock within the same process? How would you test it? I don't want to whip out Proc::Background . . .
The Perfect is the Enemy of the Good.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Testing if your code successfully flocked
by Joost (Canon) on Apr 26, 2005 at 15:04 UTC | |
|
Re: Testing if your code successfully flocked
by Transient (Hermit) on Apr 26, 2005 at 15:00 UTC | |
|
Re: Testing if your code successfully flocked
by ikegami (Patriarch) on Apr 26, 2005 at 15:02 UTC | |
by dragonchild (Archbishop) on Apr 26, 2005 at 15:07 UTC | |
by Joost (Canon) on Apr 26, 2005 at 15:13 UTC | |
|
Re: Testing if your code successfully flocked
by salva (Canon) on Apr 26, 2005 at 15:10 UTC | |
|
Re: Testing if your code successfully flocked
by halley (Prior) on Apr 26, 2005 at 16:30 UTC |