6 Documentation for this is in bisect-runner.pl
10 my $start_time = time;
12 # The default, auto_abbrev will treat -e as an abbreviation of --end
13 # Which isn't what we want.
14 use Getopt::Long qw(:config pass_through no_auto_abbrev);
16 my ($start, $end, $validate);
17 unshift @ARGV, '--help' unless GetOptions('start=s' => \$start,
19 validate => \$validate);
20 unshift @ARGV, '--validate' if $validate;
23 $runner =~ s/bisect\.pl/bisect-runner.pl/;
25 die "Can't find bisect runner $runner" unless -f $runner;
28 my ($dev0, $ino0) = stat $0;
29 die "Can't stat $0: $!" unless defined $ino0;
30 my ($dev1, $ino1) = stat 'Porting/bisect.pl';
31 die "Can't run a bisect using the directory containing $runner"
32 if defined $dev1 && $dev0 == $dev1 && $ino0 == $ino1;
35 system $^X, $runner, '--check-args', '--check-shebang', @ARGV and exit 255;
37 # We try these in this order for the start revision if none is specified.
38 my @stable = qw(perl-5.005 perl-5.6.0 perl-5.8.0 v5.10.0 v5.12.0 v5.14.0);
41 my ($dev_C, $ino_C) = stat 'Configure';
42 my ($dev_c, $ino_c) = stat 'configure';
43 if (defined $dev_C && defined $dev_c
44 && $dev_C == $dev_c && $ino_C == $ino_c) {
45 print "You seem to to be on a case insensitive file system.\n\n";
47 unshift @stable, qw(perl-5.002 perl-5.003 perl-5.004)
51 $end = 'blead' unless defined $end;
53 # Canonicalising branches to revisions before moving the checkout permits one
54 # to use revisions such as 'HEAD' for --start or --end
55 foreach ($start, $end) {
57 $_ = `git rev-parse $_`;
58 die unless defined $_;
62 my $modified = () = `git ls-files --modified --deleted --others`;
64 die "This checkout is not clean - $modified modified or untracked file(s)"
69 if (defined $start && `git rev-list -n1 $commit ^$start^` eq "") {
70 print "Skipping $commit, as it is earlier than $start\n";
73 if (defined $end && `git rev-list -n1 $end ^$commit^` eq "") {
74 print "Skipping $commit, as it is more recent than $end\n";
77 print "Testing $commit...\n";
78 system "git checkout $commit </dev/null" and die;
79 my $ret = system $^X, $runner, '--no-clean', @ARGV;
80 die "Runner returned $ret, not 0 for revision $commit" if $ret;
81 system 'git clean -dxf </dev/null' and die;
82 system 'git reset --hard HEAD </dev/null' and die;
88 my @built = map {validate $_} 'blead', reverse @stable;
90 print Text::Wrap::wrap("", "", "Successfully validated @built\n");
93 print "Did not validate anything\n";
97 my $git_version = `git --version`;
98 if (defined $git_version
99 && $git_version =~ /\Agit version (\d+\.\d+\.\d+)(.*)/) {
100 $git_version = eval "v$1";
102 $git_version = v0.0.0;
105 if ($git_version ge v1.6.6) {
106 system "git bisect reset HEAD" and die;
108 system "git bisect reset" and die;
111 # Sanity check the first and last revisions:
112 system "git checkout $end" and die;
113 my $ret = system $^X, $runner, @ARGV;
114 die "Runner returned $ret for end revision" unless $ret;
116 if (defined $start) {
117 system "git checkout $start" and die;
118 my $ret = system $^X, $runner, @ARGV;
119 die "Runner returned $ret, not 0 for start revision" if $ret;
121 # Try to find the earliest version for which the test works
122 foreach my $try (@stable) {
123 system "git checkout $try" and die;
124 my $ret = system $^X, $runner, @ARGV;
130 die "Can't find a suitable start revision to default to. Tried @stable"
131 unless defined $start;
134 system "git bisect start" and die;
135 system "git bisect good $start" and die;
136 system "git bisect bad $end" and die;
138 # And now get git bisect to do the hard work:
139 system 'git', 'bisect', 'run', $^X, $runner, @ARGV and die;
144 printf "That took %d seconds\n", $end_time - $start_time
145 if defined $start_time;
150 Documentation for this is in bisect-runner.pl
155 # cperl-indent-level: 4
156 # indent-tabs-mode: nil
159 # ex: set ts=8 sts=4 sw=4 et: