📄 bisect-builds
字号:
#!/usr/bin/perl -w# Copyright (C) 2007, 2008 Apple Inc. All rights reserved.## Redistribution and use in source and binary forms, with or without# modification, are permitted provided that the following conditions# are met:## 1. Redistributions of source code must retain the above copyright# notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright# notice, this list of conditions and the following disclaimer in the# documentation and/or other materials provided with the distribution. # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of# its contributors may be used to endorse or promote products derived# from this software without specific prior written permission. ## THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.# This script attempts to find the point at which a regression (or progression)# of behavior occurred by searching WebKit nightly builds.# To override the location where the nightly builds are downloaded or the path# to the Safari web browser, create a ~/.bisect-buildsrc file with one or more of# the following lines (use "~/" to specify a path from your home directory):## $branch = "branch-name";# $nightlyDownloadDirectory = "~/path/to/nightly/downloads";# $safariPath = "/path/to/Safari.app";use strict;use File::Basename;use File::Path;use File::Spec;use File::Temp qw(tempfile);use Getopt::Long;use Time::HiRes qw(usleep);sub createTempFile($);sub downloadNightly($$$);sub findMacOSXVersion();sub findNearestNightlyIndex(\@$$);sub findSafariVersion($);sub loadSettings();sub makeNightlyList($$$$);sub max($$) { return $_[0] > $_[1] ? $_[0] : $_[1]; }sub mountAndRunNightly($$$$);sub parseRevisions($$;$);sub printStatus($$$);sub promptForTest($);loadSettings();my %validBranches = map { $_ => 1 } qw(feature-branch trunk);my $branch = $Settings::branch;my $nightlyDownloadDirectory = $Settings::nightlyDownloadDirectory;my $safariPath = $Settings::safariPath;my @nightlies;my $isProgression;my $localOnly;my @revisions;my $sanityCheck;my $showHelp;my $testURL;# Fix up -r switches in @ARGV@ARGV = map { /^(-r)(.+)$/ ? ($1, $2) : $_ } @ARGV;my $result = GetOptions( "b|branch=s" => \$branch, "d|download-directory=s" => \$nightlyDownloadDirectory, "h|help" => \$showHelp, "l|local!" => \$localOnly, "p|progression!" => \$isProgression, "r|revisions=s" => \&parseRevisions, "safari-path=s" => \$safariPath, "s|sanity-check!" => \$sanityCheck,);$testURL = shift @ARGV;$branch = "feature-branch" if $branch eq "feature";if (!exists $validBranches{$branch}) { print STDERR "ERROR: Invalid branch '$branch'\n"; $showHelp = 1;}if (!$result || $showHelp || scalar(@ARGV) > 0) { print STDERR "Search WebKit nightly builds for changes in behavior.\n"; print STDERR "Usage: " . basename($0) . " [options] [url]\n"; print STDERR <<END; [-b|--branch name] name of the nightly build branch (default: trunk) [-d|--download-directory dir] nightly build download directory (default: ~/Library/Caches/WebKit-Nightlies) [-h|--help] show this help message [-l|--local] only use local (already downloaded) nightlies [-p|--progression] searching for a progression, not a regression [-r|--revision M[:N]] specify starting (and optional ending) revisions to search [--safari-path path] path to Safari application bundle (default: /Applications/Safari.app) [-s|--sanity-check] verify both starting and ending revisions before bisectingEND exit 1;}my $nightlyWebSite = "http://nightly.webkit.org";my $nightlyBuildsURLBase = $nightlyWebSite . File::Spec->catdir("/builds", $branch, "mac");my $nightlyFilesURLBase = $nightlyWebSite . File::Spec->catdir("/files", $branch, "mac");$nightlyDownloadDirectory = glob($nightlyDownloadDirectory) if $nightlyDownloadDirectory =~ /^~/;$safariPath = glob($safariPath) if $safariPath =~ /^~/;$safariPath = File::Spec->catdir($safariPath, "Contents/MacOS/Safari") if $safariPath =~ m#\.app/*#;$nightlyDownloadDirectory = File::Spec->catdir($nightlyDownloadDirectory, $branch);if (! -d $nightlyDownloadDirectory) { mkpath($nightlyDownloadDirectory, 0, 0755) || die "Could not create $nightlyDownloadDirectory: $!";}@nightlies = makeNightlyList($localOnly, $nightlyDownloadDirectory, findMacOSXVersion(), findSafariVersion($safariPath));my $startIndex = $revisions[0] ? findNearestNightlyIndex(@nightlies, $revisions[0], 'ceil') : 0;my $endIndex = $revisions[1] ? findNearestNightlyIndex(@nightlies, $revisions[1], 'floor') : $#nightlies;my $tempFile = createTempFile($testURL);if ($sanityCheck) { my $didReproduceBug; do { printf "\nChecking starting revision r%s...\n", $nightlies[$startIndex]->{rev}; downloadNightly($nightlies[$startIndex]->{file}, $nightlyFilesURLBase, $nightlyDownloadDirectory); mountAndRunNightly($nightlies[$startIndex]->{file}, $nightlyDownloadDirectory, $safariPath, $tempFile); $didReproduceBug = promptForTest($nightlies[$startIndex]->{rev}); $startIndex-- if $didReproduceBug < 0; } while ($didReproduceBug < 0); die "ERROR: Bug reproduced in starting revision! Do you need to test an earlier revision or for a progression?" if $didReproduceBug && !$isProgression; die "ERROR: Bug not reproduced in starting revision! Do you need to test an earlier revision or for a regression?" if !$didReproduceBug && $isProgression; do { printf "\nChecking ending revision r%s...\n", $nightlies[$endIndex]->{rev}; downloadNightly($nightlies[$endIndex]->{file}, $nightlyFilesURLBase, $nightlyDownloadDirectory); mountAndRunNightly($nightlies[$endIndex]->{file}, $nightlyDownloadDirectory, $safariPath, $tempFile); $didReproduceBug = promptForTest($nightlies[$endIndex]->{rev}); $endIndex++ if $didReproduceBug < 0; } while ($didReproduceBug < 0); die "ERROR: Bug NOT reproduced in ending revision! Do you need to test a later revision or for a progression?" if !$didReproduceBug && !$isProgression; die "ERROR: Bug reproduced in ending revision! Do you need to test a later revision or for a regression?" if $didReproduceBug && $isProgression;}printStatus($nightlies[$startIndex]->{rev}, $nightlies[$endIndex]->{rev}, $isProgression);my %brokenRevisions = ();while (abs($endIndex - $startIndex) > 1) { my $index = $startIndex + int(($endIndex - $startIndex) / 2); my $didReproduceBug; do { if (exists $nightlies[$index]) { my $buildsLeft = max(max(0, $endIndex - $index - 1), max(0, $index - $startIndex - 1)); my $plural = $buildsLeft == 1 ? "" : "s"; printf "\nChecking revision r%s (%d build%s left to test after this)...\n", $nightlies[$index]->{rev}, $buildsLeft, $plural; downloadNightly($nightlies[$index]->{file}, $nightlyFilesURLBase, $nightlyDownloadDirectory); mountAndRunNightly($nightlies[$index]->{file}, $nightlyDownloadDirectory, $safariPath, $tempFile); $didReproduceBug = promptForTest($nightlies[$index]->{rev}); } if ($didReproduceBug < 0) { $brokenRevisions{$nightlies[$index]->{rev}} = $nightlies[$index]->{file}; delete $nightlies[$index]; $endIndex--; $index = $startIndex + int(($endIndex - $startIndex) / 2); } } while ($didReproduceBug < 0); if ($didReproduceBug && !$isProgression || !$didReproduceBug && $isProgression) { $endIndex = $index; } else { $startIndex = $index; } print "\nBroken revisions skipped: r" . join(", r", keys %brokenRevisions) . "\n" if scalar keys %brokenRevisions > 0; printStatus($nightlies[$startIndex]->{rev}, $nightlies[$endIndex]->{rev}, $isProgression);}unlink $tempFile if $tempFile;exit 0;sub createTempFile($){ my ($url) = @_; return undef if !$url; my ($fh, $tempFile) = tempfile( basename($0) . "-XXXXXXXX", DIR => ($ENV{'TMPDIR'} || "/tmp"), SUFFIX => ".html", UNLINK => 0,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -