Cross-build fix for generated .t files

The *target* OS should determine whether to use system or exec.
This commit is contained in:
Andrew Johnson
2017-06-16 15:37:55 -05:00
parent 411a60c32d
commit 69d530f1db

View File

@@ -23,10 +23,6 @@ use strict;
my ($target, $exe) = @ARGV;
# Use system on Windows, exec doesn't work the same there and
# GNUmake thinks the test has finished as soon as Perl exits.
my $exec = $^O eq 'MSWin32' ? "system('./$exe') == 0" : "exec './$exe'";
open(my $OUT, '>', $target) or die "Can't create $target: $!\n";
print $OUT <<EOF;
@@ -37,7 +33,15 @@ use Cwd 'abs_path';
\$ENV{HARNESS_ACTIVE} = 1 if scalar \@ARGV && shift eq '-tap';
\$ENV{TOP} = abs_path(\$ENV{TOP}) if exists \$ENV{TOP};
$exec or die "Can't run $exe: \$!\\n";
if (\$^O eq 'MSWin32') {
# Use system on Windows, exec doesn't work the same there and
# GNUmake thinks the test has finished as soon as Perl exits.
system('./$exe') == 0 or die "Can't run $exe: \$!\\n";
}
else {
exec './$exe' or die "Can't run $exe: \$!\\n";
}
EOF
close $OUT or die "Can't close $target: $!\n";