'target=s', 'jobs|j=i', 'expect-pass=i',
'expect-fail' => sub { $options{'expect-pass'} = 0; },
'clean!', 'one-liner|e=s', 'match=s', 'force-manifest',
- 'force-regen', 'test-build', 'check-args', 'A=s@', 'l', 'w',
- 'usage|help|?',
+ 'force-regen', 'test-build', 'A=s@', 'l', 'w',
+ 'check-args', 'check-shebang!', 'usage|help|?',
'D=s@' => sub {
my (undef, $val) = @_;
if ($val =~ /\A([^=]+)=(.*)/s) {
pod2usage(exitval => 255, verbose => 1)
if !$options{'one-liner'} && ($options{l} || $options{w});
+check_shebang($ARGV[0]) if $options{'check-shebang'} && @ARGV;
+
exit 0 if $options{'check-args'};
=head1 NAME
=item *
+--check-shebang
+
+Validate that the test case isn't an executable file with a
+C<#!/usr/bin/perl> line (or similar). As F<bisect-runner.pl> does B<not>
+prepend C<./perl> to the test case, a I<#!> line specifying an external
+F<perl> binary will cause the test case to always run with I<that> F<perl>,
+not the F<perl> built by the bisect runner. Likely this is not what you
+wanted. If your test case is actually a wrapper script to run other
+commands, you should run it with an explicit interpreter, to be clear. For
+example, instead of C<../perl/Porting/bisect.pl ~/test/testcase.pl> you'd
+run C<../perl/Porting/bisect.pl /usr/bin/perl ~/test/testcase.pl>
+
+=item *
+
--usage
=item *
and die "Could not extract $file at revision $commit";
}
+sub check_shebang {
+ my $file = shift;
+ return unless -e $file;
+ if (!-x $file) {
+ die "$file is not executable.
+system($file, ...) is always going to fail.
+
+Bailing out";
+ }
+ my $fh = open_or_die($file);
+ my $line = <$fh>;
+ return unless $line =~ m{\A#!(/\S+/perl\S*)\s};
+ die "$file will always be run by $1
+It won't be tested by the ./perl we build.
+If you intended to run it with that perl binary, please change your
+test case to
+
+ $1 @ARGV
+
+If you intended to test it with the ./perl we build, please change your
+test case to
+
+ ./perl -Ilib @ARGV
+
+[You may also need to add -- before ./perl to prevent that -Ilib as being
+parsed as an argument to bisect.pl]
+
+Bailing out";
+}
+
sub clean {
if ($options{clean}) {
# Needed, because files that are build products in this checked out