From: Vincent Pit Date: Wed, 11 Nov 2015 15:36:17 +0000 (-0200) Subject: Make sure an absolute path is used in the dummy valgrind script shebang X-Git-Tag: v1.16~10 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=592fa78810e50cd5c9376dc493dfbe0891890080;p=perl%2Fmodules%2FTest-Valgrind.git Make sure an absolute path is used in the dummy valgrind script shebang And skip if we can't find it. --- diff --git a/t/70-session.t b/t/70-session.t index 22c78cd..bada708 100644 --- a/t/70-session.t +++ b/t/70-session.t @@ -21,8 +21,17 @@ like $@, qr/^No appropriate valgrind executable/, 'nonexistant valgrind'; sub fake_vg { my ($version) = @_; + + my $perl = $^X; + unless (-e $perl and -x $perl) { + $perl = $Config::Config{perlpath}; + unless (-e $perl and -x $perl) { + return undef; + } + } + return <<" FAKE_VG"; -#!$^X +#!$perl if (\@ARGV == 1 && \$ARGV[0] eq '--version') { print "valgrind-$version\n"; } else { @@ -34,8 +43,12 @@ if (\@ARGV == 1 && \$ARGV[0] eq '--version') { SKIP: { skip 'Only on linux or darwin' => 5 unless $^O eq 'linux' or $^O eq 'darwin'; + my $fake_vg_code = fake_vg('3.0.0'); + skip 'Could not generate the dummy valgrind executable' => 5 + unless defined $fake_vg_code; + my $vg_old = File::Temp->new(UNLINK => 1); - print $vg_old fake_vg('3.0.0'); + print $vg_old $fake_vg_code; close $vg_old; chmod 0755, $vg_old->filename; @@ -45,8 +58,12 @@ SKIP: { ) }; like $@, qr/^No appropriate valgrind executable/, 'old valgrind'; + $fake_vg_code = fake_vg('3.4.0'); + skip 'Could not generate the dummy valgrind executable' => 4 + unless defined $fake_vg_code; + my $vg_new = File::Temp->new(UNLINK => 1); - print $vg_new fake_vg('3.4.0'); + print $vg_new $fake_vg_code; close $vg_new; chmod 0755, $vg_new->filename;