6 Documentation for this is in bisect-runner.pl
10 # The default, auto_abbrev will treat -e as an abbreviation of --end
11 # Which isn't what we want.
12 use Getopt::Long qw(:config pass_through no_auto_abbrev);
14 my ($start, $end, $validate, $usage, $bad);
15 $bad = !GetOptions('start=s' => \$start, 'end=s' => \$end,
16 validate => \$validate, 'usage|help|?' => \$usage);
17 unshift @ARGV, '--help' if $bad || $usage;
18 unshift @ARGV, '--validate' if $validate;
21 $runner =~ s/bisect\.pl/bisect-runner.pl/;
23 die "Can't find bisect runner $runner" unless -f $runner;
25 system $^X, $runner, '--check-args', '--check-shebang', @ARGV and exit 255;
30 my ($dev0, $ino0) = stat $0;
31 die "Can't stat $0: $!" unless defined $ino0;
32 my ($dev1, $ino1) = stat 'Porting/bisect.pl';
33 die "Can't run a bisect using the directory containing $runner"
34 if defined $dev1 && $dev0 == $dev1 && $ino0 == $ino1;
37 my $start_time = time;
39 # We try these in this order for the start revision if none is specified.
40 my @stable = qw(perl-5.005 perl-5.6.0 perl-5.8.0 v5.10.0 v5.12.0 v5.14.0);
43 my ($dev_C, $ino_C) = stat 'Configure';
44 my ($dev_c, $ino_c) = stat 'configure';
45 if (defined $dev_C && defined $dev_c
46 && $dev_C == $dev_c && $ino_C == $ino_c) {
47 print "You seem to be on a case-insensitive file system.\n\n";
49 unshift @stable, qw(perl-5.002 perl-5.003 perl-5.004)
53 $end = 'blead' unless defined $end;
55 # Canonicalising branches to revisions before moving the checkout permits one
56 # to use revisions such as 'HEAD' for --start or --end
57 foreach ($start, $end) {
59 $_ = `git rev-parse $_`;
60 die unless defined $_;
64 my $modified = () = `git ls-files --modified --deleted --others`;
66 die "This checkout is not clean - $modified modified or untracked file(s)"
71 if (defined $start && `git rev-list -n1 $commit ^$start^` eq "") {
72 print "Skipping $commit, as it is earlier than $start\n";
75 if (defined $end && `git rev-list -n1 $end ^$commit^` eq "") {
76 print "Skipping $commit, as it is more recent than $end\n";
79 print "Testing $commit...\n";
80 system "git checkout $commit </dev/null" and die;
81 my $ret = system $^X, $runner, '--no-clean', @ARGV;
82 die "Runner returned $ret, not 0 for revision $commit" if $ret;
83 system 'git clean -dxf </dev/null' and die;
84 system 'git reset --hard HEAD </dev/null' and die;
90 my @built = map {validate $_} 'blead', reverse @stable;
92 print Text::Wrap::wrap("", "", "Successfully validated @built\n");
95 print "Did not validate anything\n";
99 my $git_version = `git --version`;
100 if (defined $git_version
101 && $git_version =~ /\Agit version (\d+\.\d+\.\d+)(.*)/) {
102 $git_version = eval "v$1";
104 $git_version = v0.0.0;
107 if ($git_version ge v1.6.6) {
108 system "git bisect reset HEAD" and die;
110 system "git bisect reset" and die;
113 # Sanity check the first and last revisions:
114 system "git checkout $end" and die;
115 my $ret = system $^X, $runner, @ARGV;
116 die "Runner returned $ret for end revision" unless $ret;
118 if (defined $start) {
119 system "git checkout $start" and die;
120 my $ret = system $^X, $runner, @ARGV;
121 die "Runner returned $ret, not 0 for start revision" if $ret;
123 # Try to find the earliest version for which the test works
125 foreach my $try (@stable) {
126 if (`git rev-list -n1 $end ^$try^` eq "") {
127 print "Skipping $try, as it is more recent than end commit "
128 . (substr $end, 0, 16) . "\n";
129 # As @stable is supposed to be in age order, arguably we should
133 system "git checkout $try" and die;
134 my $ret = system $^X, $runner, @ARGV;
141 die "Can't find a suitable start revision to default to.\nTried @tried"
142 unless defined $start;
145 system "git bisect start" and die;
146 system "git bisect good $start" and die;
147 system "git bisect bad $end" and die;
149 # And now get git bisect to do the hard work:
150 system 'git', 'bisect', 'run', $^X, $runner, @ARGV and die;
155 printf "That took %d seconds\n", $end_time - $start_time
156 if defined $start_time;
161 Documentation for this is in bisect-runner.pl
166 # cperl-indent-level: 4
167 # indent-tabs-mode: nil
170 # ex: set ts=8 sts=4 sw=4 et: