X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FTest-Valgrind.git;a=blobdiff_plain;f=t%2Flib%2FTest%2FValgrind%2FFakeValgrind.pm;h=0d13a0d50fdf226fdd30410dbafc9c7861767956;hp=067309b6a5cd708f0b04a8fc064673ffbe49740b;hb=5f7c59874ed712bf2787c3b0dbbaaf899fdd508c;hpb=63366af6711a7bcbaf8f1c0a78bc45ebb307124e diff --git a/t/lib/Test/Valgrind/FakeValgrind.pm b/t/lib/Test/Valgrind/FakeValgrind.pm index 067309b..0d13a0d 100644 --- a/t/lib/Test/Valgrind/FakeValgrind.pm +++ b/t/lib/Test/Valgrind/FakeValgrind.pm @@ -45,28 +45,39 @@ BEGIN { sub new { my ($class, %args) = @_; + return 'Temporary executables do not work on Windows' if $^O eq 'MSWin32'; + my $exe_name = $args{exe_name}; my $version = $args{version} || '3.1.0'; my $body = $args{body}; my $self = { }; + my $exe_ext = $Config::Config{exe_ext}; + $exe_ext = '' unless defined $exe_ext; if (defined $exe_name) { return 'File::Temp 0.19 is required to make a proper temporary directory' unless $good_enough_file_temp; + if (length $exe_ext and $exe_name !~ /\Q$exe_ext\E$/) { + $exe_name .= $exe_ext; + } $self->{tmp_dir_obj} = File::Temp->newdir(CLEANUP => 1); $self->{tmp_dir} = $self->{tmp_dir_obj}->dirname; $self->{tmp_file} = File::Spec->catfile($self->{tmp_dir}, $exe_name); } else { # Can't use the OO interface if we don't wan't the file to be opened by # default, but then we have to deal with cleanup ourselves. - local $^W = 0; - (undef, my $tmp_file) = File::Temp::tempfile( + my %args = ( TEMPLATE => 'fakevgXXXX', TMPDIR => 1, CLEANUP => 0, OPEN => 0, ); + $args{SUFFIX} = $exe_ext if length $exe_ext; + my $tmp_file = do { + local $^W = 0; + (File::Temp::tempfile(%args))[1] + }; $self->{tmp_file} = $tmp_file; my ($vol, $dir) = File::Spec->splitpath($self->{tmp_file}); $self->{tmp_dir} = File::Spec->catpath($vol, $dir, '');