| Index: tools/bisect-builds.py
|
| diff --git a/tools/bisect-builds.py b/tools/bisect-builds.py
|
| index 04b4689d4e42dd5935ff9fcb4b6b21bc11c7001f..3ccc2f03fec1de26a04da3d8fab6c820bb1ec859 100755
|
| --- a/tools/bisect-builds.py
|
| +++ b/tools/bisect-builds.py
|
| @@ -182,7 +182,7 @@ class PathContext(object):
|
| except ValueError:
|
| pass
|
| return (revisions, next_marker)
|
| -
|
| +
|
| # Fetch the first list of revisions.
|
| (revisions, next_marker) = _FetchAndParse(self.GetListingURL())
|
|
|
| @@ -296,23 +296,31 @@ def FetchRevision(context, rev, filename, quit_event=None, progress_event=None):
|
| pass
|
|
|
|
|
| -def RunRevision(context, revision, zipfile, profile, num_runs, args):
|
| - """Given a zipped revision, unzip it and run the test."""
|
| +def RunRevision(context, revision, zipfile, num_runs, exec_args, outdir=None):
|
| + """Given a zipped revision, unzip it and run the test.
|
| + @param context A PathContext instance.
|
| + @param revision The Chromium revision number/tag to run.
|
| + @param zipfile Path to a zip file containing the Chromium revision.
|
| + @param num_runs Number of times to run the given Chromium revision.
|
| + @param exec_args Function which takes in the path of the unzipped Chromium
|
| + revision and returns the full command to execute Chromium.
|
| + @param outdir Path to save output to. If specified, stdout will be saved at
|
| + outdir/<revision>_<iteration>.out and stderr will be saved
|
| + at outdir/<revision>_<iteration>.err. If left as None, the
|
| + output is not saved.
|
| + """
|
| print "Trying revision %s..." % str(revision)
|
|
|
| - # Create a temp directory and unzip the revision into it.
|
| - cwd = os.getcwd()
|
| tempdir = tempfile.mkdtemp(prefix='bisect_tmp')
|
| UnzipFilenameToDir(zipfile, tempdir)
|
| - os.chdir(tempdir)
|
| + testargs = exec_args(os.path.join(tempdir, context.GetLaunchPath()))
|
|
|
| - # Run the build as many times as specified.
|
| - testargs = [context.GetLaunchPath(), '--user-data-dir=%s' % profile] + args
|
| # The sandbox must be run as root on Official Chrome, so bypass it.
|
| if context.is_official and (context.platform == 'linux' or
|
| context.platform == 'linux64'):
|
| testargs.append('--no-sandbox')
|
|
|
| + # Run the build as many times as specified.
|
| for i in range(0, num_runs):
|
| subproc = subprocess.Popen(testargs,
|
| bufsize=-1,
|
| @@ -320,7 +328,19 @@ def RunRevision(context, revision, zipfile, profile, num_runs, args):
|
| stderr=subprocess.PIPE)
|
| (stdout, stderr) = subproc.communicate()
|
|
|
| - os.chdir(cwd)
|
| + if outdir is not None:
|
| + if not os.path.isdir(outdir):
|
| + os.mkdir(outdir)
|
| +
|
| + fout = open(os.path.join(outdir, '%s_%s.out' % (str(revision), str(i))),
|
| + 'w')
|
| + fout.write(stdout)
|
| + fout.close()
|
| + ferr = open(os.path.join(outdir, '%s_%s.err' % (str(revision), str(i))),
|
| + 'w')
|
| + ferr.write(stderr)
|
| + ferr.close()
|
| +
|
| try:
|
| shutil.rmtree(tempdir, True)
|
| except Exception, e:
|
| @@ -471,6 +491,9 @@ def Bisect(platform,
|
| _GetDownloadPath(up_rev))
|
| up_fetch.Start()
|
|
|
| + def execute_args(chrome_path):
|
| + return [chrome_path, '--user-data-dir=%s' % profile] + try_args
|
| +
|
| # Run test on the pivot revision.
|
| status = None
|
| stdout = None
|
| @@ -479,11 +502,11 @@ def Bisect(platform,
|
| (status, stdout, stderr) = RunRevision(context,
|
| rev,
|
| zipfile,
|
| - profile,
|
| num_runs,
|
| - try_args)
|
| + execute_args)
|
| except Exception, e:
|
| print >>sys.stderr, e
|
| +
|
| os.unlink(zipfile)
|
| zipfile = None
|
|
|
|
|