From: Bram Date: Mon, 16 Feb 2009 15:07:19 +0000 (+0100) Subject: Use tempfile() in tests X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1ab9acc5e047d5b80c252fe3d5e4d905e6367701;p=p5sagit%2Fp5-mst-13.2.git Use tempfile() in tests --- diff --git a/t/op/filetest.t b/t/op/filetest.t index 97ce3f9..c73d747 100755 --- a/t/op/filetest.t +++ b/t/op/filetest.t @@ -80,13 +80,14 @@ ok( (-s -f 'TEST' > 1), "-s returns real size" ); ok( -f -s 'TEST' == 1 ); # now with an empty file -open my $fh, ">", "foo"; +my $tempfile = tempfile(); +open my $fh, ">", $tempfile; close $fh; -ok( -f "foo" ); -is( -s "foo", 0 ); -is( -f -s "foo", 0 ); -is( -s -f "foo", 0 ); -unlink "foo"; +ok( -f $tempfile ); +is( -s $tempfile, 0 ); +is( -f -s $tempfile, 0 ); +is( -s -f $tempfile, 0 ); +unlink $tempfile; # test that _ is a bareword after filetest operators diff --git a/t/op/sysio.t b/t/op/sysio.t index 435be12..dd63a15 100755 --- a/t/op/sysio.t +++ b/t/op/sysio.t @@ -4,6 +4,7 @@ print "1..42\n"; chdir('op') || chdir('t/op') || die "sysio.t: cannot look for myself: $!"; @INC = '../../lib'; +require '../test.pl'; open(I, 'sysio.t') || die "sysio.t: cannot find myself: $!"; @@ -60,7 +61,7 @@ print "ok 9\n"; print 'not ' unless ($a eq "#!.\0\0erl"); print "ok 10\n"; -$outfile = 'sysio.out'; +$outfile = tempfile(); open(O, ">$outfile") || die "sysio.t: cannot write $outfile: $!"; diff --git a/t/op/taint.t b/t/op/taint.t index 2dc1bb9..01ab368 100755 --- a/t/op/taint.t +++ b/t/op/taint.t @@ -285,7 +285,7 @@ my $TEST = catfile(curdir(), 'TEST'); # How about command-line arguments? The problem is that we don't # always get some, so we'll run another process with some. SKIP: { - my $arg = catfile(curdir(), tempfile()); + my $arg = tempfile(); open PROG, "> $arg" or die "Can't create $arg: $!"; print PROG q{ eval { join('', @ARGV), kill 0 };