Commit | Line | Data |
---|---|---|
6a8dbfd7 NC |
1 | #!/usr/bin/perl -w |
2 | use strict; | |
3 | ||
4 | my $start_time = time; | |
5 | ||
e295b7be NC |
6 | # The default, auto_abbrev will treat -e as an abbreviation of --end |
7 | # Which isn't what we want. | |
8 | use Getopt::Long qw(:config pass_through no_auto_abbrev); | |
6a8dbfd7 | 9 | |
e295b7be | 10 | my ($start, $end); |
77ae6092 NC |
11 | unshift @ARGV, '--help' unless GetOptions('start=s' => \$start, |
12 | 'end=s' => \$end); | |
13 | ||
14 | my $runner = $0; | |
15 | $runner =~ s/bisect\.pl/bisect-runner.pl/; | |
16 | ||
17 | die "Can't find bisect runner $runner" unless -f $runner; | |
18 | ||
5842706e NC |
19 | { |
20 | my ($dev0, $ino0) = stat $0; | |
21 | die "Can't stat $0: $!" unless defined $ino0; | |
22 | my ($dev1, $ino1) = stat 'Porting/bisect.pl'; | |
23 | die "Can't run a bisect using the directory containing $runner" | |
24 | if defined $dev1 && $dev0 == $dev1 && $ino0 == $ino1; | |
25 | } | |
26 | ||
77ae6092 | 27 | system $^X, $runner, '--check-args', @ARGV and exit 255; |
6a8dbfd7 | 28 | |
4819dd2a NC |
29 | # We try these in this order for the start revision if none is specified. |
30 | my @stable = qw(perl-5.002 perl-5.003 perl-5.004 perl-5.005 perl-5.6.0 | |
31 | perl-5.8.0 v5.10.0 v5.12.0 v5.14.0); | |
e295b7be | 32 | |
4819dd2a NC |
33 | if ($start) { |
34 | system "git rev-parse $start >/dev/null" and die; | |
35 | } | |
6a8dbfd7 | 36 | $end = 'blead' unless defined $end; |
6a8dbfd7 NC |
37 | system "git rev-parse $end >/dev/null" and die; |
38 | ||
39 | my $modified = () = `git ls-files --modified --deleted --others`; | |
40 | ||
41 | die "This checkout is not clean - $modified modified or untracked file(s)" | |
42 | if $modified; | |
43 | ||
44 | system "git bisect reset" and die; | |
45 | ||
6a8dbfd7 | 46 | # Sanity check the first and last revisions: |
4819dd2a NC |
47 | if (defined $start) { |
48 | system "git checkout $start" and die; | |
e295b7be | 49 | my $ret = system $^X, $runner, @ARGV; |
4819dd2a NC |
50 | die "Runner returned $ret, not 0 for start revision" if $ret; |
51 | } else { | |
52 | # Try to find the earliest version for which the test works | |
53 | foreach my $try (@stable) { | |
54 | system "git checkout $try" and die; | |
e295b7be | 55 | my $ret = system $^X, $runner, @ARGV; |
4819dd2a NC |
56 | if (!$ret) { |
57 | $start = $try; | |
58 | last; | |
59 | } | |
60 | } | |
61 | die "Can't find a suitable start revision to default to. Tried @stable" | |
62 | unless defined $start; | |
63 | } | |
6a8dbfd7 | 64 | system "git checkout $end" and die; |
e295b7be | 65 | my $ret = system $^X, $runner, @ARGV; |
6a8dbfd7 NC |
66 | die "Runner returned $ret for end revision" unless $ret; |
67 | ||
68 | system "git bisect start" and die; | |
69 | system "git bisect good $start" and die; | |
70 | system "git bisect bad $end" and die; | |
71 | ||
72 | # And now get git bisect to do the hard work: | |
e295b7be | 73 | system 'git', 'bisect', 'run', $^X, $runner, @ARGV and die; |
6a8dbfd7 | 74 | |
c3d98a71 NC |
75 | END { |
76 | my $end_time = time; | |
6a8dbfd7 | 77 | |
c3d98a71 NC |
78 | printf "That took %d seconds\n", $end_time - $start_time |
79 | if defined $start_time; | |
80 | } | |
81 | ||
82 | # Local variables: | |
83 | # cperl-indent-level: 4 | |
84 | # indent-tabs-mode: nil | |
85 | # End: | |
86 | # | |
87 | # ex: set ts=8 sts=4 sw=4 et: |