From 015efd9e49470c09db5efed3e664795673663252 Mon Sep 17 00:00:00 2001 From: Andrew Fresh Date: Sat, 29 Mar 2014 15:06:50 -0700 Subject: [PATCH] Don't try to open files in the distribution for writing When imported into OpenBSD, this will be attempted to run from a readonly source tree. This test fails in that situation because we are not allowed to open t/truncate_me for writing. Instead, we can just use the tempfile. --- t/truncate.t | 7 +++---- t/truncate_me | 0 2 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 t/truncate_me diff --git a/t/truncate.t b/t/truncate.t index 2472139a..df6270e6 100755 --- a/t/truncate.t +++ b/t/truncate.t @@ -6,13 +6,12 @@ use File::Temp qw(tempfile); use IO::Handle; use File::Spec; use FindBin qw($Bin); -use constant TRUNCATE_ME => File::Spec->catfile($Bin,'truncate_me'); -my ($truncate_status, $tmpfh); +my ($truncate_status, $tmpfh, $tmpfile); # Some systems have a screwy tempfile. We don't run our tests there. eval { - $tmpfh = tempfile(); + ($tmpfh, $tmpfile) = tempfile(); }; if ($@ or !defined $tmpfh) { @@ -80,7 +79,7 @@ isa_ok($@, 'autodie::exception', "Truncating unopened file (TRUNCATE_FH)"); # wrong with our tests, or autodie... { use autodie qw(open); - open(TRUNCATE_FH, '+<', TRUNCATE_ME); + open(TRUNCATE_FH, '+<', $tmpfile); } # Now try truncating the filehandle. This should succeed. diff --git a/t/truncate_me b/t/truncate_me deleted file mode 100644 index e69de29b..00000000