From: Vincent Pit Date: Thu, 12 Nov 2015 15:10:32 +0000 (-0200) Subject: Allow fake valgrind test helpers to have a body X-Git-Tag: v1.16~5 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=09d4e2a26f1f8ca433f2224b8a6e5281646ff7af;p=perl%2Fmodules%2FTest-Valgrind.git Allow fake valgrind test helpers to have a body --- diff --git a/t/lib/Test/Valgrind/FakeValgrind.pm b/t/lib/Test/Valgrind/FakeValgrind.pm index 098bae0..ec3abd4 100644 --- a/t/lib/Test/Valgrind/FakeValgrind.pm +++ b/t/lib/Test/Valgrind/FakeValgrind.pm @@ -8,7 +8,7 @@ use File::Spec; use File::Temp; sub _dummy_valgrind_code { - my ($version) = @_; + my ($version, $body) = @_; my $perl = $^X; unless (-e $perl and -x $perl) { @@ -18,11 +18,18 @@ sub _dummy_valgrind_code { } } + if (defined $body) { + $body = "\n$body"; + } else { + $body = ''; + } + return <<" FAKE_VG"; #!$perl if (\@ARGV == 1 && \$ARGV[0] eq '--version') { print "valgrind-$version\n"; -} + exit 0; +}$body FAKE_VG } @@ -31,6 +38,7 @@ sub new { my $exe_name = $args{exe_name}; my $version = $args{version} || '3.1.0'; + my $body = $args{body}; my $self = { }; @@ -45,7 +53,7 @@ sub new { $self->{tmp_dir} = File::Spec->catpath($vol, $dir, ''); } - my $code = _dummy_valgrind_code($version); + my $code = _dummy_valgrind_code($version, $body); return 'Could not generate the dummy valgrind executable' unless $code; return 'Temporary file already exists' if -s $self->{tmp_file};