summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2012-05-24 11:40:41 +0200
committerNicholas Clark <nick@ccl4.org>2012-05-31 18:09:45 +0200
commite687eccd5383c3e09f3fa6fb6761a4949e743d51 (patch)
treedb8cc3f6d527b95a8b707947357b722a0beb9148
parentdcefe67b927264e55ef5d32ae1bc2880ef1e3da9 (diff)
downloadperl-e687eccd5383c3e09f3fa6fb6761a4949e743d51.tar.gz
In t/op/filetest.t, use one temporary file for testing instead of two.
The readonly file tests aren't worried about the file's length, and the zero-length file tests aren't concerned about whether it's writable, so it's possible to use the same file in both tests.
-rw-r--r--t/op/filetest.t22
1 files changed, 9 insertions, 13 deletions
diff --git a/t/op/filetest.t b/t/op/filetest.t
index a3df1c0eb4..5a76763108 100644
--- a/t/op/filetest.t
+++ b/t/op/filetest.t
@@ -17,15 +17,15 @@ ok( !-f 'op' );
ok( !-d 'TEST' );
ok( -r 'TEST' );
-# Make a read only file
-my $ro_file = tempfile();
+# Make a read only file. This happens to be empty, so we also use it later.
+my $ro_empty_file = tempfile();
{
- open my $fh, '>', $ro_file or die "open $fh: $!";
+ open my $fh, '>', $ro_empty_file or die "open $fh: $!";
close $fh or die "close $fh: $!";
}
-chmod 0555, $ro_file or die "chmod 0555, '$ro_file' failed: $!";
+chmod 0555, $ro_empty_file or die "chmod 0555, '$ro_empty_file' failed: $!";
SKIP: {
my $restore_root;
@@ -39,7 +39,7 @@ SKIP: {
++$restore_root;
}
- ok( !-w $ro_file );
+ ok( !-w $ro_empty_file );
if ($restore_root) {
# If the previous assignment to $> worked, so should this:
@@ -72,14 +72,10 @@ ok( (-s -f 'TEST' > 1), "-s returns real size" );
ok( -f -s 'TEST' == 1 );
# now with an empty file
-my $tempfile = tempfile();
-open my $fh, ">", $tempfile;
-close $fh;
-ok( -f $tempfile );
-is( -s $tempfile, 0 );
-is( -f -s $tempfile, 0 );
-is( -s -f $tempfile, 0 );
-unlink_all $tempfile;
+ok( -f $ro_empty_file );
+is( -s $ro_empty_file, 0 );
+is( -f -s $ro_empty_file, 0 );
+is( -s -f $ro_empty_file, 0 );
# stacked -l
eval { -l -e "TEST" };