Subject: | [PATCH] truncate.t doesn't check return status when testing whether we can test |
In determining whether tests based on truncate() are worth running, truncate.t calls truncate()
inside an eval, which should handle the case where the function doesn't exist. But since the
return value is not checked, it doesn't handle the case where a simple truncate operation fails.
The attached patch remedies that.
This came up because on VMS, the C library's ftruncate() does not play nice with temporary files
having the delete-on-close bit set, which is what File:Temp gives us by default. An alternative
would be to have it roll its own temp file, but that seems an unnecessary burden to place on a
test script that is doing the right thing.
Subject: | truncate.patch.txt |
--- t/lib/autodie/truncate.t;-0 Sat Dec 20 07:32:08 2008
+++ t/lib/autodie/truncate.t Fri Jan 2 10:24:27 2009
@@ -6,13 +6,14 @@ use File::Temp qw(tempfile);
use IO::Handle;
my $tmpfh = tempfile();
+my $truncate_status;
eval {
- truncate($tmpfh, 0);
+ $truncate_status = truncate($tmpfh, 0);
};
-if ($@) {
- plan skip_all => 'Truncate not implemented on this system';
+if ($@ || !defined($truncate_status)) {
+ plan skip_all => 'Truncate not implemented or not working on this system';
}
plan tests => 3;