In perl.git, the branch blead has been updated <https://perl5.git.perl.org/perl.git/commitdiff/c0a22fcc1cf66dc415acf252a180a384f2e4d360?hp=68e4117104b9c2ff428dd80807d165702e35bb7b>
- Log ----------------------------------------------------------------- commit c0a22fcc1cf66dc415acf252a180a384f2e4d360 Author: Zefram <[email protected]> Date: Tue Nov 14 09:49:11 2017 +0000 fix naming of some test temp files The files should be named t/tmp*, to fall under .gitignore and be ignored by podcheck. ----------------------------------------------------------------------- Summary of changes: t/comp/utf.t | 6 +++--- t/io/argv.t | 52 +++++++++++++++++++++++------------------------ t/op/taint.t | 2 +- t/porting/extrefs.t | 5 +++-- t/run/runenv.t | 14 ++++++------- t/run/switches.t | 58 ++++++++++++++++++++++++++--------------------------- t/test.pl | 2 +- 7 files changed, 70 insertions(+), 69 deletions(-) diff --git a/t/comp/utf.t b/t/comp/utf.t index 4e747c4a98..95c23651b9 100644 --- a/t/comp/utf.t +++ b/t/comp/utf.t @@ -34,11 +34,11 @@ sub bytes_to_utf { sub test { my ($enc, $write, $expect, $bom, $nl, $name) = @_; - open my $fh, ">", "utf$$.pl" or die "utf.pl: $!"; + open my $fh, ">", "tmputf$$.pl" or die "tmputf$$.pl: $!"; binmode $fh; print $fh bytes_to_utf($enc, $write . ($nl ? "\n" : ''), $bom); close $fh or die $!; - my $got = do "./utf$$.pl"; + my $got = do "./tmputf$$.pl"; $test = $test + 1; if (!defined $got) { if ($@ =~ /^(Unsupported script encoding \Q$enc\E)/) { @@ -100,5 +100,5 @@ for my $bom (0, 1) { } END { - 1 while unlink "utf$$.pl"; + 1 while unlink "tmputf$$.pl"; } diff --git a/t/io/argv.t b/t/io/argv.t index 288586e97d..417fab418d 100644 --- a/t/io/argv.t +++ b/t/io/argv.t @@ -17,16 +17,16 @@ if (is_miniperl()) { $devnull = File::Spec->devnull; } -open(TRY, '>Io_argv1.tmp') || (die "Can't open temp file: $!"); +open(TRY, '>tmpIo_argv1.tmp') || (die "Can't open temp file: $!"); print TRY "a line\n"; close TRY or die "Could not close: $!"; -open(TRY, '>Io_argv2.tmp') || (die "Can't open temp file: $!"); +open(TRY, '>tmpIo_argv2.tmp') || (die "Can't open temp file: $!"); print TRY "another line\n"; close TRY or die "Could not close: $!"; $x = runperl( prog => 'while (<>) { print $., $_; }', - args => [ 'Io_argv1.tmp', 'Io_argv1.tmp' ], + args => [ 'tmpIo_argv1.tmp', 'tmpIo_argv1.tmp' ], ); is($x, "1a line\n2a line\n", '<> from two files'); @@ -34,7 +34,7 @@ is($x, "1a line\n2a line\n", '<> from two files'); $x = runperl( prog => 'while (<>) { print $_; }', stdin => "foo\n", - args => [ 'Io_argv1.tmp', '-' ], + args => [ 'tmpIo_argv1.tmp', '-' ], ); is($x, "a line\nfoo\n", '<> from a file and STDIN'); @@ -55,9 +55,9 @@ is($x, "1a line\n2a line\n", '<> from two files'); $x = runperl( prog => 'while (<>) { print $ARGV.q/,/.$_ }', - args => [ 'Io_argv1.tmp', 'Io_argv2.tmp' ], + args => [ 'tmpIo_argv1.tmp', 'tmpIo_argv2.tmp' ], ); - is($x, "Io_argv1.tmp,a line\nIo_argv2.tmp,another line\n", '$ARGV is the file name'); + is($x, "tmpIo_argv1.tmp,a line\ntmpIo_argv2.tmp,another line\n", '$ARGV is the file name'); TODO: { local $::TODO = "unrelated bug in redirection implementation" if $^O eq 'VMS'; @@ -83,8 +83,8 @@ TODO: { is( 0+$?, 0, q(eof() doesn't segfault) ); } -@ARGV = is_miniperl() ? ('Io_argv1.tmp', 'Io_argv1.tmp', 'Io_argv1.tmp') - : ('Io_argv1.tmp', 'Io_argv1.tmp', $devnull, 'Io_argv1.tmp'); +@ARGV = is_miniperl() ? ('tmpIo_argv1.tmp', 'tmpIo_argv1.tmp', 'tmpIo_argv1.tmp') + : ('tmpIo_argv1.tmp', 'tmpIo_argv1.tmp', $devnull, 'tmpIo_argv1.tmp'); while (<>) { $y .= $. . $_; if (eof()) { @@ -95,11 +95,11 @@ while (<>) { is($y, "1a line\n2a line\n3a line\n", '<> from @ARGV'); -open(TRY, '>Io_argv1.tmp') or die "Can't open temp file: $!"; +open(TRY, '>tmpIo_argv1.tmp') or die "Can't open temp file: $!"; close TRY or die "Could not close: $!"; -open(TRY, '>Io_argv2.tmp') or die "Can't open temp file: $!"; +open(TRY, '>tmpIo_argv2.tmp') or die "Can't open temp file: $!"; close TRY or die "Could not close: $!"; -@ARGV = ('Io_argv1.tmp', 'Io_argv2.tmp'); +@ARGV = ('tmpIo_argv1.tmp', 'tmpIo_argv2.tmp'); $^I = '_bak'; # not .bak which confuses VMS $/ = undef; my $i = 11; @@ -109,9 +109,9 @@ while (<>) { print; next_test(); } -open(TRY, '<Io_argv1.tmp') or die "Can't open temp file: $!"; +open(TRY, '<tmpIo_argv1.tmp') or die "Can't open temp file: $!"; print while <TRY>; -open(TRY, '<Io_argv2.tmp') or die "Can't open temp file: $!"; +open(TRY, '<tmpIo_argv2.tmp') or die "Can't open temp file: $!"; print while <TRY>; close TRY or die "Could not close: $!"; undef $^I; @@ -123,7 +123,7 @@ ok( eof TRY ); ok( eof NEVEROPENED, 'eof() true on unopened filehandle' ); } -open STDIN, 'Io_argv1.tmp' or die $!; +open STDIN, 'tmpIo_argv1.tmp' or die $!; @ARGV = (); ok( !eof(), 'STDIN has something' ); @@ -135,7 +135,7 @@ SKIP: { @ARGV = (); ok( eof(), 'eof() true with empty @ARGV' ); - @ARGV = ('Io_argv1.tmp'); + @ARGV = ('tmpIo_argv1.tmp'); ok( !eof() ); @ARGV = ($devnull, $devnull); @@ -147,7 +147,7 @@ SKIP: { SKIP: { local $/; - open my $fh, 'Io_argv1.tmp' or die "Could not open Io_argv1.tmp: $!"; + open my $fh, 'tmpIo_argv1.tmp' or die "Could not open tmpIo_argv1.tmp: $!"; <$fh>; # set $. = 1 is( <$fh>, undef ); @@ -165,19 +165,19 @@ SKIP: { close $fh or die "Could not close: $!"; } -open(TRY, '>Io_argv1.tmp') || (die "Can't open temp file: $!"); +open(TRY, '>tmpIo_argv1.tmp') || (die "Can't open temp file: $!"); print TRY "one\n\nthree\n"; close TRY or die "Could not close: $!"; $x = runperl( prog => 'print $..$ARGV.$_ while <<>>', - args => [ 'Io_argv1.tmp' ], + args => [ 'tmpIo_argv1.tmp' ], ); -is($x, "1Io_argv1.tmpone\n2Io_argv1.tmp\n3Io_argv1.tmpthree\n", '<<>>'); +is($x, "1tmpIo_argv1.tmpone\n2tmpIo_argv1.tmp\n3tmpIo_argv1.tmpthree\n", '<<>>'); $x = runperl( prog => '$w=q/b/;$w.=<<>>;print $w', - args => [ 'Io_argv1.tmp' ], + args => [ 'tmpIo_argv1.tmp' ], ); is($x, "bone\n", '<<>> and rcatline'); @@ -232,24 +232,24 @@ SKIP: { $x = runperl( prog => 'while (<<>>) { }', stderr => 1, - args => [ 'Io_argv1.tmp', '"echo foo |"' ], + args => [ 'tmpIo_argv1.tmp', '"echo foo |"' ], ); like($x, qr/^Can't open echo foo \|: .* at -e line 1, <> line 3/, '<<>> does not treat ...| as fork after eof'); } # This used to dump core fresh_perl_is( <<'**PROG**', "foobar", {}, "ARGV aliasing and eof()" ); -open OUT, ">Io_argv3.tmp" or die "Can't open temp file: $!"; +open OUT, ">tmpIo_argv3.tmp" or die "Can't open temp file: $!"; print OUT "foo"; close OUT; -open IN, "Io_argv3.tmp" or die "Can't open temp file: $!"; +open IN, "tmpIo_argv3.tmp" or die "Can't open temp file: $!"; *ARGV = *IN; while (<>) { print; print "bar" if eof(); } close IN; -unlink "Io_argv3.tmp"; +unlink "tmpIo_argv3.tmp"; **PROG** # This used to fail an assertion. @@ -263,6 +263,6 @@ is runperl(prog => 'undef *x; delete $::{ARGV}; $x++;' "ok\n", 'deleting $::{ARGV}'; END { - unlink_all 'Io_argv1.tmp', 'Io_argv1.tmp_bak', - 'Io_argv2.tmp', 'Io_argv2.tmp_bak', 'Io_argv3.tmp'; + unlink_all 'tmpIo_argv1.tmp', 'tmpIo_argv1.tmp_bak', + 'tmpIo_argv2.tmp', 'tmpIo_argv2.tmp_bak', 'tmpIo_argv3.tmp'; } diff --git a/t/op/taint.t b/t/op/taint.t index 9a17336a5d..f9dac45c2c 100644 --- a/t/op/taint.t +++ b/t/op/taint.t @@ -123,7 +123,7 @@ sub violates_taint { } # We need an external program to call. -my $ECHO = ($Is_MSWin32 ? ".\\echo$$" : ($Is_NetWare ? "echo$$" : "./echo$$")); +my $ECHO = ($Is_MSWin32 ? ".\\tmpecho$$" : ($Is_NetWare ? "tmpecho$$" : "./tmpecho$$")); END { unlink $ECHO } open my $fh, '>', $ECHO or die "Can't create $ECHO: $!"; print $fh 'print "@ARGV\n"', "\n"; diff --git a/t/porting/extrefs.t b/t/porting/extrefs.t index 2e911e7a0b..f8cb6acd3b 100644 --- a/t/porting/extrefs.t +++ b/t/porting/extrefs.t @@ -70,13 +70,14 @@ sub try_compile_and_link { return 0; } - my $COREincdir = File::Spec->catdir(File::Spec->updir); + my $COREincdir = + File::Spec->catdir(File::Spec->updir, File::Spec->updir); my $ccflags = $Config{'ccflags'} . ' ' . "-I$COREincdir" . ' -DPERL_NO_INLINE_FUNCTIONS'; if ($^O eq "MSWin32") { - $ccflags .= " -I../win32 -I../win32/include"; + $ccflags .= " -I../../win32 -I../../win32/include"; } my $libs = ''; diff --git a/t/run/runenv.t b/t/run/runenv.t index c1e1b825da..a709f51c9a 100644 --- a/t/run/runenv.t +++ b/t/run/runenv.t @@ -140,18 +140,18 @@ try({PERL5OPT => '-Mstrict -Mwarnings'}, "ok", ""); -open my $fh, ">", "Oooof.pm" or die "Can't write Oooof.pm: $!"; -print $fh "package Oooof; 1;\n"; +open my $fh, ">", "tmpOooof.pm" or die "Can't write tmpOooof.pm: $!"; +print $fh "package tmpOooof; 1;\n"; close $fh; -END { 1 while unlink "Oooof.pm" } +END { 1 while unlink "tmpOooof.pm" } -try({PERL5OPT => '-I. -MOooof'}, - ['-e', 'print "ok" if $INC{"Oooof.pm"} eq "Oooof.pm"'], +try({PERL5OPT => '-I. -MtmpOooof'}, + ['-e', 'print "ok" if $INC{"tmpOooof.pm"} eq "tmpOooof.pm"'], "ok", ""); -try({PERL5OPT => '-I./ -MOooof'}, - ['-e', 'print "ok" if $INC{"Oooof.pm"} eq "Oooof.pm"'], +try({PERL5OPT => '-I./ -MtmpOooof'}, + ['-e', 'print "ok" if $INC{"tmpOooof.pm"} eq "tmpOooof.pm"'], "ok", ""); diff --git a/t/run/switches.t b/t/run/switches.t index b11946c38d..0ce0af75cf 100644 --- a/t/run/switches.t +++ b/t/run/switches.t @@ -353,9 +353,9 @@ SKIP: { local $TODO = ''; # these ones should work on VMS - sub do_i_unlink { unlink_all("file", "file.bak") } + sub do_i_unlink { unlink_all("tmpswitches", "tmpswitches.bak") } - open(FILE, ">file") or die "$0: Failed to create 'file': $!"; + open(FILE, ">tmpswitches") or die "$0: Failed to create 'tmpswitches': $!"; my $yada = <<__EOF__; foo yada dada bada foo bing @@ -366,13 +366,13 @@ __EOF__ END { do_i_unlink() } - runperl( switches => ['-pi.bak'], prog => 's/foo/bar/', args => ['file'] ); + runperl( switches => ['-pi.bak'], prog => 's/foo/bar/', args => ['tmpswitches'] ); - open(FILE, "file") or die "$0: Failed to open 'file': $!"; + open(FILE, "tmpswitches") or die "$0: Failed to open 'tmpswitches': $!"; chomp(my @file = <FILE>); close FILE; - open(BAK, "file.bak") or die "$0: Failed to open 'file': $!"; + open(BAK, "tmpswitches.bak") or die "$0: Failed to open 'tmpswitches.bak': $!"; chomp(my @bak = <BAK>); close BAK; @@ -399,11 +399,11 @@ __EOF__ prog => 'exit', stderr => 1, stdin => "1\n", - args => ['file'], + args => ['tmpswitches'], ); is($out2, "", "no warning when files given"); - open my $f, ">", "file" or die "$0: failed to create 'file': $!"; + open my $f, ">", "tmpswitches" or die "$0: failed to create 'tmpswitches': $!"; print $f "foo\nbar\n"; close $f; @@ -412,10 +412,10 @@ __EOF__ switches => [ '-i', '-p' ], prog => 's/foo/quux/', stderr => 1, - args => [ 'file' ], + args => [ 'tmpswitches' ], ); is($out3, "", "no warnings/errors without backup extension"); - open $f, "<", "file" or die "$0: cannot open 'file': $!"; + open $f, "<", "tmpswitches" or die "$0: cannot open 'tmpswitches': $!"; chomp(my @out4 = <$f>); close $f; is(join(":", @out4), "quux:bar", "correct output without backup extension"); @@ -423,9 +423,9 @@ __EOF__ eval { require File::Spec; 1 } or skip "Cannot load File::Spec - miniperl?", 20; - -d "inplacetmp" or mkdir("inplacetmp") - or die "Cannot mkdir 'inplacetmp': $!"; - my $work = File::Spec->catfile("inplacetmp", "foo"); + -d "tmpinplace" or mkdir("tmpinplace") + or die "Cannot mkdir 'tmpinplace': $!"; + my $work = File::Spec->catfile("tmpinplace", "foo"); # exit or die should leave original content in file for my $inplace (qw/-i -i.bak/) { @@ -474,7 +474,7 @@ __EOF__ && $Config{d_linkat} && $Config{ccflags} !~ /-DNO_USE_ATFUNCTIONS\b/; fresh_perl_is(<<'CODE', "ok\n", { }, -@ARGV = ("inplacetmp/foo"); +@ARGV = ("tmpinplace/foo"); $^I = ""; while (<>) { chdir ".."; @@ -495,7 +495,7 @@ CODE fresh_perl_is(<<'CODE', "ok\n", { stderr => 1 }, use threads; use strict; -@ARGV = ("inplacetmp/foo"); +@ARGV = ("tmpinplace/foo"); $^I = ""; while (<>) { threads->create(sub { })->join; @@ -520,7 +520,7 @@ CODE close $fh or die "Cannot close $work: $!"; fresh_perl_is(<<'CODE', "ok\n", { stderr => 1 }, use strict; -@ARGV = ("inplacetmp/foo"); +@ARGV = ("tmpinplace/foo"); $^I = ""; while (<>) { my $pid = fork; @@ -546,7 +546,7 @@ CODE # make it fail by creating a directory of the backup name mkdir "$work.bak" or die "Cannot make mask backup directory: $!"; fresh_perl_like(<<'CODE', qr/Can't rename/, { stderr => 1 }, "fail backup rename"); -@ARGV = ("inplacetmp/foo"); +@ARGV = ("tmpinplace/foo"); $^I = ".bak"; while (<>) { print; @@ -571,7 +571,7 @@ CODE # we now use temp files for in-place editing, make sure we didn't leave # any behind in the above test - opendir my $d, "inplacetmp" or die "Cannot opendir inplacetmp: $!"; + opendir my $d, "tmpinplace" or die "Cannot opendir tmpinplace: $!"; my @names = grep !/^\.\.?$/ && $_ ne 'foo', readdir $d; closedir $d; is(scalar(@names), 0, "no extra files") @@ -586,23 +586,23 @@ CODE # test we handle the rename of the work to the original failing # make it fail by removing write perms from the directory # but first check that doesn't prevent writing - chmod 0500, "inplacetmp"; - my $check = File::Spec->catfile("inplacetmp", "check"); + chmod 0500, "tmpinplace"; + my $check = File::Spec->catfile("tmpinplace", "check"); my $canwrite = open my $fh, ">", $check; unlink $check; - chmod 0700, "inplacetmp" or die "Cannot make inplacetmp writable again: $!"; - skip "Cannot make inplacetmp read only", 1 + chmod 0700, "tmpinplace" or die "Cannot make tmpinplace writable again: $!"; + skip "Cannot make tmpinplace read only", 1 if $canwrite; fresh_perl_like(<<'CODE', qr/Can't rename/, { stderr => 1 }, "fail final rename"); -@ARGV = ("inplacetmp/foo"); +@ARGV = ("tmpinplace/foo"); $^I = ""; while (<>) { - chmod 0500, "inplacetmp"; + chmod 0500, "tmpinplace"; print; } print "ok\n"; CODE - chmod 0700, "inplacetmp" or die "Cannot make inplacetmp writable again: $!"; + chmod 0700, "tmpinplace" or die "Cannot make tmpinplace writable again: $!"; } SKIP: @@ -613,8 +613,8 @@ CODE && ($Config{d_dirfd} || $Config{d_dir_dd_fd}) && $Config{d_linkat} && $Config{ccflags} !~ /-DNO_USE_ATFUNCTIONS\b/; - fresh_perl_like(<<'CODE', qr/^Cannot complete in-place edit of inplacetmp\/foo: .* - line 5, <> line \d+\./, { }, -@ARGV = ("inplacetmp/foo"); + fresh_perl_like(<<'CODE', qr/^Cannot complete in-place edit of tmpinplace\/foo: .* - line 5, <> line \d+\./, { }, +@ARGV = ("tmpinplace/foo"); $^I = ""; while (<>) { chdir ".."; @@ -627,14 +627,14 @@ CODE unlink $work; - opendir $d, "inplacetmp" or die "Cannot opendir inplacetmp: $!"; + opendir $d, "tmpinplace" or die "Cannot opendir tmpinplace: $!"; @names = grep !/^\.\.?$/ && !/foo$/aai, readdir $d; closedir $d; # clean up in case the above failed - unlink map File::Spec->catfile("inplacetmp", $_), @names; + unlink map File::Spec->catfile("tmpinplace", $_), @names; - rmdir "inplacetmp"; + rmdir "tmpinplace"; } # Tests for -E diff --git a/t/test.pl b/t/test.pl index 1782dcf73c..ed6391af7f 100644 --- a/t/test.pl +++ b/t/test.pl @@ -917,7 +917,7 @@ $::tempfile_regexp = 'tmp\d+[A-Z][A-Z]?'; my $tempfile_count = 0; sub tempfile { while(1){ - my $try = "tmp$$"; + my $try = (-d "t" ? "t/" : "")."tmp$$"; my $alpha = _num_to_alpha($tempfile_count,2); last unless defined $alpha; $try = $try . $alpha; -- Perl5 Master Repository
