<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[185243] trunk/Tools</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/185243">185243</a></dd>
<dt>Author</dt> <dd>slewis@apple.com</dd>
<dt>Date</dt> <dd>2015-06-05 02:11:21 -0700 (Fri, 05 Jun 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add errors to run-benchmark exception handling.
Reviewed by Ryosuke Niwa.
* Scripts/run-benchmark:
(main):
* Scripts/webkitpy/benchmark_runner/benchmark_builder/generic_benchmark_builder.py:
(GenericBenchmarkBuilder.prepare):
(GenericBenchmarkBuilder._runCreateScript):
(GenericBenchmarkBuilder._applyPatch):
(GenericBenchmarkBuilder.clean):
* Scripts/webkitpy/benchmark_runner/benchmark_runner.py:
(BenchmarkRunner.__init__):
(BenchmarkRunner.execute):
(BenchmarkRunner):
(BenchmarkRunner.cleanup):
* Scripts/webkitpy/benchmark_runner/generic_factory.py:
(GenericFactory.iterateGetItem):
(GenericFactory.create):
* Scripts/webkitpy/benchmark_runner/utils.py:
(loadModule):
(loadJSONFromFile):
(forceRemove):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptsrunbenchmark">trunk/Tools/Scripts/run-benchmark</a></li>
<li><a href="#trunkToolsScriptswebkitpybenchmark_runnerbenchmark_buildergeneric_benchmark_builderpy">trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder/generic_benchmark_builder.py</a></li>
<li><a href="#trunkToolsScriptswebkitpybenchmark_runnerbenchmark_runnerpy">trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py</a></li>
<li><a href="#trunkToolsScriptswebkitpybenchmark_runnergeneric_factorypy">trunk/Tools/Scripts/webkitpy/benchmark_runner/generic_factory.py</a></li>
<li><a href="#trunkToolsScriptswebkitpybenchmark_runnerutilspy">trunk/Tools/Scripts/webkitpy/benchmark_runner/utils.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (185242 => 185243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-06-05 09:11:18 UTC (rev 185242)
+++ trunk/Tools/ChangeLog        2015-06-05 09:11:21 UTC (rev 185243)
</span><span class="lines">@@ -1,5 +1,32 @@
</span><span class="cx"> 2015-06-05 Stephanie Lewis <slewis@apple.com>
</span><span class="cx">
</span><ins>+
+ Add errors to run-benchmark exception handling.
+
+ Reviewed by Ryosuke Niwa.
+
+ * Scripts/run-benchmark:
+ (main):
+ * Scripts/webkitpy/benchmark_runner/benchmark_builder/generic_benchmark_builder.py:
+ (GenericBenchmarkBuilder.prepare):
+ (GenericBenchmarkBuilder._runCreateScript):
+ (GenericBenchmarkBuilder._applyPatch):
+ (GenericBenchmarkBuilder.clean):
+ * Scripts/webkitpy/benchmark_runner/benchmark_runner.py:
+ (BenchmarkRunner.__init__):
+ (BenchmarkRunner.execute):
+ (BenchmarkRunner):
+ (BenchmarkRunner.cleanup):
+ * Scripts/webkitpy/benchmark_runner/generic_factory.py:
+ (GenericFactory.iterateGetItem):
+ (GenericFactory.create):
+ * Scripts/webkitpy/benchmark_runner/utils.py:
+ (loadModule):
+ (loadJSONFromFile):
+ (forceRemove):
+
+2015-06-05 Stephanie Lewis <slewis@apple.com>
+
</ins><span class="cx"> Streamline run-benchmark browser
</span><span class="cx">
</span><span class="cx"> Reviewed by Ryosuke Niwa.
</span></span></pre></div>
<a id="trunkToolsScriptsrunbenchmark"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/run-benchmark (185242 => 185243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/run-benchmark        2015-06-05 09:11:18 UTC (rev 185242)
+++ trunk/Tools/Scripts/run-benchmark        2015-06-05 09:11:21 UTC (rev 185243)
</span><span class="lines">@@ -36,8 +36,11 @@
</span><span class="cx"> _log.debug('\toutput file name\t: %s' % args.output)
</span><span class="cx"> _log.debug('\tbuild directory\t: %s' % args.buildDir)
</span><span class="cx"> _log.debug('\tplan name\t: %s', args.plan)
</span><del>- runner = BenchmarkRunner(args.plan, args.localCopy, args.countOverride, args.buildDir, args.output, args.platform, args.browser)
- return runner.execute()
</del><ins>+ try:
+ runner = BenchmarkRunner(args.plan, args.localCopy, args.countOverride, args.buildDir, args.output, args.platform, args.browser)
+ runner.execute()
+ except Exception as error:
+ sys.exit("Error occurred running the benchmark: %s" % error)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> if __name__ == '__main__':
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpybenchmark_runnerbenchmark_buildergeneric_benchmark_builderpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder/generic_benchmark_builder.py (185242 => 185243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder/generic_benchmark_builder.py        2015-06-05 09:11:18 UTC (rev 185242)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder/generic_benchmark_builder.py        2015-06-05 09:11:21 UTC (rev 185243)
</span><span class="lines">@@ -31,7 +31,7 @@
</span><span class="cx"> if createScript:
</span><span class="cx"> self._runCreateScript(createScript)
</span><span class="cx"> return self._applyPatch(patch)
</span><del>- except:
</del><ins>+ except Exception:
</ins><span class="cx"> self.clean()
</span><span class="cx"> raise
</span><span class="cx">
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx"> errorCode = subprocess.call(createScript)
</span><span class="cx"> os.chdir(oldWorkingDirectory)
</span><span class="cx"> if errorCode:
</span><del>- raise Exception('Cannot create the benchmark', errorCode)
</del><ins>+ raise Exception('Cannot create the benchmark - Error: %s' % errorCode)
</ins><span class="cx">
</span><span class="cx"> def _copyBenchmarkToTempDir(self, benchmarkPath):
</span><span class="cx"> shutil.copytree(getPathFromProjectRoot(benchmarkPath), self.dest)
</span><span class="lines">@@ -70,10 +70,10 @@
</span><span class="cx"> errorCode = subprocess.call(['patch', '-p1', '-f', '-i', getPathFromProjectRoot(patch)])
</span><span class="cx"> os.chdir(oldWorkingDirectory)
</span><span class="cx"> if errorCode:
</span><del>- raise Exception('Cannot apply patch, will skip current benchmarkPath')
</del><ins>+ raise Exception('Cannot apply patch, will skip current benchmarkPath - Error: %s' % errorCode)
</ins><span class="cx"> return self.webRoot
</span><span class="cx">
</span><span class="cx"> def clean(self):
</span><del>- _log.info('Cleanning Benchmark')
</del><ins>+ _log.info('Cleaning Benchmark')
</ins><span class="cx"> if self.webRoot:
</span><span class="cx"> forceRemove(self.webRoot)
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpybenchmark_runnerbenchmark_runnerpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py (185242 => 185243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py        2015-06-05 09:11:18 UTC (rev 185242)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py        2015-06-05 09:11:21 UTC (rev 185243)
</span><span class="lines">@@ -5,6 +5,7 @@
</span><span class="cx"> import shutil
</span><span class="cx"> import signal
</span><span class="cx"> import subprocess
</span><ins>+import sys
</ins><span class="cx"> import tempfile
</span><span class="cx"> import time
</span><span class="cx"> import types
</span><span class="lines">@@ -39,12 +40,12 @@
</span><span class="cx"> self.httpServerDriver = HTTPServerDriverFactory.create([self.plan['http_server_driver']])
</span><span class="cx"> self.buildDir = os.path.abspath(buildDir) if buildDir else None
</span><span class="cx"> self.outputFile = outputFile
</span><del>- except IOError:
- _log.error('Can not open plan file: %s' % planFile)
- raise
- except ValueError:
- _log.error('Plan file:%s may not follow JSON format' % planFile)
- raise
</del><ins>+ except IOError as error:
+ _log.error('Can not open plan file: %s - Error %s' % planFile, error)
+ raise error
+ except ValueError as error:
+ _log.error('Plan file: %s may not follow JSON format - Error %s' % planFile, error)
+ raise error
</ins><span class="cx">
</span><span class="cx"> def _findPlanFile(self, planFile):
</span><span class="cx"> if not os.path.exists(planFile):
</span><span class="lines">@@ -61,13 +62,13 @@
</span><span class="cx"> _log.info('Start to execute the plan')
</span><span class="cx"> _log.info('Start a new benchmark')
</span><span class="cx"> results = []
</span><del>- benchmarkBuilder = BenchmarkBuilderFactory.create([self.plan['benchmark_builder']])
</del><ins>+ self.benchmarkBuilder = BenchmarkBuilderFactory.create([self.plan['benchmark_builder']])
</ins><span class="cx">
</span><span class="cx"> if not self.plan.get('local_copy') and not self.plan.get('remote_archive'):
</span><span class="cx"> _log.error('Either local_copy or remote_archive must be specified in the plan')
</span><del>- return 2
</del><ins>+ sys.exit(2)
</ins><span class="cx">
</span><del>- webRoot = benchmarkBuilder.prepare(self.planName, self.plan.get('local_copy'), self.plan.get('remote_archive'),
</del><ins>+ webRoot = self.benchmarkBuilder.prepare(self.planName, self.plan.get('local_copy'), self.plan.get('remote_archive'),
</ins><span class="cx"> self.plan.get('benchmark_patch'), self.plan.get('create_script'))
</span><span class="cx"> for x in xrange(int(self.plan['count'])):
</span><span class="cx"> _log.info('Start the iteration %d of current benchmark' % (x + 1))
</span><span class="lines">@@ -77,33 +78,39 @@
</span><span class="cx"> self.browserDriver.launchUrl(url, self.buildDir)
</span><span class="cx"> try:
</span><span class="cx"> with timeout(self.plan['timeout']):
</span><del>- result = json.loads(self.httpServerDriver.fetchResult())
</del><ins>+ result = self.httpServerDriver.fetchResult()
</ins><span class="cx"> assert(not self.httpServerDriver.getReturnCode())
</span><span class="cx"> assert(result)
</span><del>- results.append(result)
- except:
- _log.error('No result or server crashes. Something went wrong. Will skip current benchmark.')
- self.browserDriver.closeBrowsers()
- self.httpServerDriver.killServer()
- benchmarkBuilder.clean()
- return 1
</del><ins>+ results.append(json.loads(result))
+ except Exception as error:
+ _log.error('No result or the server crashed. Something went wrong. Will skip current benchmark.\nError: %s, Server return code: %d, result: %s' % (error, not self.httpServerDriver.getReturnCode(), result))
+ self.cleanup()
+ sys.exit(1)
</ins><span class="cx"> finally:
</span><span class="cx"> self.browserDriver.closeBrowsers()
</span><span class="cx"> _log.info('End of %d iteration of current benchmark' % (x + 1))
</span><span class="cx"> results = self.wrap(results)
</span><span class="cx"> self.dump(results, self.outputFile if self.outputFile else self.plan['output_file'])
</span><span class="cx"> self.show_results(results)
</span><del>- benchmarkBuilder.clean()
- return 0
</del><ins>+ self.benchmarkBuilder.clean()
+ sys.exit()
</ins><span class="cx">
</span><ins>+ def cleanup(self):
+ if self.browserDriver:
+ self.browserDriver.closeBrowsers()
+ if self.httpServerDriver:
+ self.httpServerDriver.killServer()
+ if self.benchmarkBuilder:
+ self.benchmarkBuilder.clean()
+
</ins><span class="cx"> @classmethod
</span><span class="cx"> def dump(cls, results, outputFile):
</span><span class="cx"> _log.info('Dumping the results to file')
</span><span class="cx"> try:
</span><span class="cx"> with open(outputFile, 'w') as fp:
</span><span class="cx"> json.dump(results, fp)
</span><del>- except IOError:
- _log.error('Cannot open output file: %s' % outputFile)
</del><ins>+ except IOError as error:
+ _log.error('Cannot open output file: %s - Error: %s' % outputFile, error)
</ins><span class="cx"> _log.error('Results are:\n %s', json.dumps(results))
</span><span class="cx">
</span><span class="cx"> @classmethod
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpybenchmark_runnergeneric_factorypy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/generic_factory.py (185242 => 185243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/benchmark_runner/generic_factory.py        2015-06-05 09:11:18 UTC (rev 185242)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/generic_factory.py        2015-06-05 09:11:21 UTC (rev 185243)
</span><span class="lines">@@ -27,5 +27,5 @@
</span><span class="cx"> def create(cls, descriptions):
</span><span class="cx"> try:
</span><span class="cx"> return loadModule(cls.iterateGetItem(cls.products, descriptions))()
</span><del>- except:
</del><ins>+ except Exception:
</ins><span class="cx"> raise
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpybenchmark_runnerutilspy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/utils.py (185242 => 185243)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/benchmark_runner/utils.py        2015-06-05 09:11:18 UTC (rev 185242)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/utils.py        2015-06-05 09:11:21 UTC (rev 185243)
</span><span class="lines">@@ -18,8 +18,8 @@
</span><span class="cx"> try:
</span><span class="cx"> ret = getattr(__import__(moduleDesc['filePath'], globals(), locals(), moduleDesc['moduleName'], -1), moduleDesc['moduleName'])
</span><span class="cx"> return ret
</span><del>- except Exception as e:
- raise ModuleNotFoundError('Module (%s) with path(%s) is not found' % (moduleDesc['moduleName'], moduleDesc['filePath']))
</del><ins>+ except Exception as error:
+ raise ModuleNotFoundError('Error loading module (%s) with path(%s): {%s}' % (moduleDesc['moduleName'], moduleDesc['filePath'], error))
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> def getPathFromProjectRoot(relativePathToProjectRoot):
</span><span class="lines">@@ -34,15 +34,16 @@
</span><span class="cx"> jsonObject = json.load(open(filePath, 'r'))
</span><span class="cx"> assert(jsonObject)
</span><span class="cx"> return jsonObject
</span><del>- except:
- raise Exception("Invalid json format or empty json was found in %s" % (filePath))
</del><ins>+ except Exception as error:
+ raise Exception("Invalid json format or empty json was found in %s - Error: %s" % (filePath, error))
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> def forceRemove(path):
</span><span class="cx"> try:
</span><span class="cx"> shutil.rmtree(path)
</span><del>- except:
</del><ins>+ except Exception as error:
</ins><span class="cx"> # Directory/file does not exist or privilege issue, just ignore it
</span><ins>+ _log.info("Error removing %s: %s" % (path, error))
</ins><span class="cx"> pass
</span><span class="cx">
</span><span class="cx"> # Borrow this code from
</span></span></pre>
</div>
</div>
</body>
</html>