This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Getopt-Long to CPAN version 2.48
[perl5.git] / Porting / bisect-runner.pl
index 275f14c..5c228b8 100755 (executable)
@@ -5,6 +5,7 @@ use Getopt::Long qw(:config bundling no_auto_abbrev);
 use Pod::Usage;
 use Config;
 use File::Temp qw(tempdir);
+use File::Spec;
 
 my @targets
     = qw(none config.sh config.h miniperl lib/Config.pm Fcntl perl test_prep);
@@ -65,7 +66,7 @@ unless(GetOptions(\%options,
                   'test-build', 'validate',
                   'all-fixups', 'early-fixup=s@', 'late-fixup=s@', 'valgrind',
                   'check-args', 'check-shebang!', 'usage|help|?', 'gold=s',
-                  'module=s', 'with-module=s',
+                  'module=s', 'with-module=s', 'cpan-config-dir=s',
                   'A=s@',
                   'D=s@' => sub {
                       my (undef, $val) = @_;
@@ -166,6 +167,8 @@ bisect.pl - use git bisect to pinpoint changes
  .../Porting/bisect.pl --module=autobox,Moose
  # When did this code stop working in blead with these modules?
  .../Porting/bisect.pl --with-module=Moose,Moo -e 'use Moose; 1;'
+ # Like the above 2 but with custom CPAN::MyConfig
+ .../Porting/bisect.pl --module=Moo --cpan-config-dir=/home/blah/custom/
 
 =head1 DESCRIPTION
 
@@ -558,11 +561,12 @@ MSCHWERN/Test-Simple-1.005000_005.tar.gz.
 
 In so far, it is not such a misnomer.
 
-Note that this and B<--with-module> will both require a CPAN::MyConfig.
-If F</home/.cpan/CPAN/MyConfig.pm> does not exist, a CPAN shell will
+Note that this and I<--with-module> will both require a C<CPAN::MyConfig>.
+If F<$ENV{HOME}/.cpan/CPAN/MyConfig.pm> does not exist, a CPAN shell will
 be started up for you so you can configure one. Feel free to let
 CPAN pick defaults for you. Enter 'quit' when you are done, and
-then everything should be all set.
+then everything should be all set. Alternatively, you may
+specify a custom C<CPAN::MyConfig> by using I<--cpan-config-dir>.
 
 Also, if you want to bisect a module that needs a display (like
 TK) and you don't want random screens appearing and disappearing
@@ -571,8 +575,9 @@ this:
 
 In a terminal:
 
-  $ while true; do date ; if ! ps auxww | grep -v grep | grep -q Xvfb;\
-    then Xvfb :121 & fi; echo -n 'sleeping 60 '; sleep 60; done
+ $ while true; do date ; if ! ps auxww | grep -v grep \
+   | grep -q Xvfb; then Xvfb :121 & fi; echo -n 'sleeping 60 '; \
+   sleep 60; done
 
 And then:
 
@@ -584,7 +589,7 @@ And then:
 
 --with-module module1,module2,...
 
-Like B<--module> above, except this simply installs the requested
+Like I<--module> above, except this simply installs the requested
 modules and they can then be used in other tests.
 
 For example:
@@ -593,6 +598,20 @@ For example:
 
 =item *
 
+--cpan-config-dir /home/blah/custom
+
+If defined, this will cause L<CPAN> to look for F<CPAN/MyConfig.pm> inside of
+the specified directory, instead of using the default config of
+F<$ENV{HOME}/.cpan/>.
+
+If no default config exists, a L<CPAN> shell will be fired up for you to
+configure things. Letting L<CPAN> automatically configure things for you
+should work well enough. You probably want to choose I<manual> instead of
+I<local::lib> if it asks. When you're finished with configuration, just
+type I<q> and hit I<ENTER> and the bisect should continue.
+
+=item *
+
 --force-manifest
 
 By default, a build will "skip" if any files listed in F<MANIFEST> are not
@@ -1230,7 +1249,7 @@ sub match_and_exit {
         while (<$fh>) {
             if ($_ =~ $re) {
                 ++$matches;
-                if (tr/\t\r\n -~\200-\377//c) {
+                if (/[^[:^cntrl:]\h\v]/a) { # Matches non-spacing non-C1 controls
                     print "Binary file $file matches\n";
                 } else {
                     $_ .= "\n" unless /\n\z/;
@@ -1361,6 +1380,7 @@ push @ARGS, map {"-A$_"} @{$options{A}};
 
 my $prefix;
 
+# Testing a module? We need to install perl/cpan modules to a temp dir
 if ($options{module} || $options{'with-module'}) {
   $prefix = tempdir(CLEANUP => 1);
 
@@ -1458,8 +1478,20 @@ if ($options{module} || $options{'with-module'}) {
   $ENV{AUTOMATED_TESTING} = 1;
   $ENV{PERL_MM_USE_DEFAULT} = 1;
 
+  # Don't let these interfere with our cpan installs
+  delete $ENV{PERL_MB_OPT};
+  delete $ENV{PERL_MM_OPT};
+
+  # Make sure we load up our CPAN::MyConfig and then
+  # override the build_dir so we have a fresh one
+  # every build
+  my $cdir = $options{'cpan-config-dir'}
+          || File::Spec->catfile($ENV{HOME},".cpan");
+
   my @cpanshell = (
     "$prefix/bin/perl",
+    "-I", "$cdir",
+    "-MCPAN::MyConfig",
     "-MCPAN",
     "-e","\$CPAN::Config->{build_dir}=q{$bdir};",
     "-e",