diff --git a/Changes b/Changes index 173e3a6..b80aca7 100644 --- a/Changes +++ b/Changes @@ -1,8 +1,9 @@ Revision history for File-Edit-Portable 1.16 2016-01-22 - - disabled the lock test if RELEASE_TESTING isn't available, as it was - failing on a small number of situations + - closes #15; removed the write() lock test completely + - closes #12; platform_recsep() can be used as the custom recsep to + write(). Added tests to confirm this 1.15 2016-01-18 - we now LOCK_EX in write() (prereq Fcntl) diff --git a/lib/File/Edit/Portable.pm b/lib/File/Edit/Portable.pm index 72fac93..8d94ac2 100644 --- a/lib/File/Edit/Portable.pm +++ b/lib/File/Edit/Portable.pm @@ -105,9 +105,6 @@ sub write { } } - # the following allows unit tests to test the lock - sleep 1 if $ENV{TEST_WRITE_LOCK}; - close $wfh; $self->{is_read} = 0; diff --git a/t/02-write.t b/t/02-write.t index 9be6193..6eae967 100644 --- a/t/02-write.t +++ b/t/02-write.t @@ -100,40 +100,30 @@ my $rw = File::Edit::Portable->new; is($recsep_sub->called_count, 3, "recsep() is called if ! is_read"); } -{ - SKIP: { - skip "RELEASE_TESTING not enabled for lock test", 1 if ! $ENV{RELEASE_TESTING}; +SKIP: { - $ENV{TEST_WRITE_LOCK} = 1; + skip "win32 test, but not on windows", 1 unless $^O eq 'MSWin32'; - my @file = $rw->read($unix); + my $fh = $rw->read($unix); - writing($rw, \@file); + $rw->write(copy => $copy, contents => $fh, recsep => $rw->platform_recsep); - sleep 1; + my $eor = $rw->recsep($copy, 'hex'); - open my $fh, '<', $copy or die $!; + is ($eor, '\0d\0a', "platform_recsep() w/ no parameters can be used as custom recsep" ); +}; +SKIP: { - eval { - flock($fh, LOCK_EX | LOCK_NB) or die "can't lock write file"; - 1; - }; + skip "nix test but we're not on unix", 1 unless $^O ne 'MSWin32'; - like ($@, qr/can't lock write file/, "when writing, file is locked ok"); - print "here"; - sleep 1; # because we need to wait for the fork() to finish - }; -} + my $fh = $rw->read($unix); -done_testing(); + $rw->write(copy => $copy, contents => $fh, recsep => $rw->platform_recsep); -sub writing { - my ($rw, $contents) = @_; - my $pid = fork; + my $eor = $rw->recsep($copy, 'hex'); - return if $pid; + is ($eor, '\0d\0a', "platform_recsep() w/ no parameters can be used as custom recsep" ); +}; - $rw->write(copy => $copy, contents => $contents); +done_testing(); - exit 0; -}