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 | ||
19 | system $^X, $runner, '--check-args', @ARGV and exit 255; | |
6a8dbfd7 | 20 | |
4819dd2a NC |
21 | # We try these in this order for the start revision if none is specified. |
22 | my @stable = qw(perl-5.002 perl-5.003 perl-5.004 perl-5.005 perl-5.6.0 | |
23 | perl-5.8.0 v5.10.0 v5.12.0 v5.14.0); | |
e295b7be | 24 | |
4819dd2a NC |
25 | if ($start) { |
26 | system "git rev-parse $start >/dev/null" and die; | |
27 | } | |
6a8dbfd7 | 28 | $end = 'blead' unless defined $end; |
6a8dbfd7 NC |
29 | system "git rev-parse $end >/dev/null" and die; |
30 | ||
31 | my $modified = () = `git ls-files --modified --deleted --others`; | |
32 | ||
33 | die "This checkout is not clean - $modified modified or untracked file(s)" | |
34 | if $modified; | |
35 | ||
36 | system "git bisect reset" and die; | |
37 | ||
6a8dbfd7 | 38 | # Sanity check the first and last revisions: |
4819dd2a NC |
39 | if (defined $start) { |
40 | system "git checkout $start" and die; | |
e295b7be | 41 | my $ret = system $^X, $runner, @ARGV; |
4819dd2a NC |
42 | die "Runner returned $ret, not 0 for start revision" if $ret; |
43 | } else { | |
44 | # Try to find the earliest version for which the test works | |
45 | foreach my $try (@stable) { | |
46 | system "git checkout $try" and die; | |
e295b7be | 47 | my $ret = system $^X, $runner, @ARGV; |
4819dd2a NC |
48 | if (!$ret) { |
49 | $start = $try; | |
50 | last; | |
51 | } | |
52 | } | |
53 | die "Can't find a suitable start revision to default to. Tried @stable" | |
54 | unless defined $start; | |
55 | } | |
6a8dbfd7 | 56 | system "git checkout $end" and die; |
e295b7be | 57 | my $ret = system $^X, $runner, @ARGV; |
6a8dbfd7 NC |
58 | die "Runner returned $ret for end revision" unless $ret; |
59 | ||
60 | system "git bisect start" and die; | |
61 | system "git bisect good $start" and die; | |
62 | system "git bisect bad $end" and die; | |
63 | ||
64 | # And now get git bisect to do the hard work: | |
e295b7be | 65 | system 'git', 'bisect', 'run', $^X, $runner, @ARGV and die; |
6a8dbfd7 | 66 | |
c3d98a71 NC |
67 | END { |
68 | my $end_time = time; | |
6a8dbfd7 | 69 | |
c3d98a71 NC |
70 | printf "That took %d seconds\n", $end_time - $start_time |
71 | if defined $start_time; | |
72 | } | |
73 | ||
74 | # Local variables: | |
75 | # cperl-indent-level: 4 | |
76 | # indent-tabs-mode: nil | |
77 | # End: | |
78 | # | |
79 | # ex: set ts=8 sts=4 sw=4 et: |