summaryrefslogtreecommitdiffstats
path: root/infra
diff options
context:
space:
mode:
authorPaweł Hajdan, Jr <phajdan.jr@chromium.org>2015-11-16 16:16:11 +0100
committerPaweł Hajdan, Jr <phajdan.jr@chromium.org>2015-11-16 15:17:56 +0000
commit4e96b1de65143bac77420ed8610b5df8a7237cd0 (patch)
tree373d658da57dab85cad09859e68147a04b7d8947 /infra
parent411eecbfe40524f5f62dee1662cde665d12dfaf9 (diff)
downloadchromium_src-4e96b1de65143bac77420ed8610b5df8a7237cd0.zip
chromium_src-4e96b1de65143bac77420ed8610b5df8a7237cd0.tar.gz
chromium_src-4e96b1de65143bac77420ed8610b5df8a7237cd0.tar.bz2
sizes.py: implement individual failures, at least for Linux
BUG=553425 R=akuegel@chromium.org Review URL: https://codereview.chromium.org/1428833006 . Cr-Commit-Position: refs/heads/master@{#359839}
Diffstat (limited to 'infra')
-rwxr-xr-xinfra/scripts/legacy/scripts/slave/chromium/sizes.py48
1 files changed, 37 insertions, 11 deletions
diff --git a/infra/scripts/legacy/scripts/slave/chromium/sizes.py b/infra/scripts/legacy/scripts/slave/chromium/sizes.py
index 9875826..77331d1 100755
--- a/infra/scripts/legacy/scripts/slave/chromium/sizes.py
+++ b/infra/scripts/legacy/scripts/slave/chromium/sizes.py
@@ -12,6 +12,7 @@
"""
import errno
+import json
import platform
import optparse
import os
@@ -28,6 +29,22 @@ SRC_DIR = os.path.abspath(
os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', '..', '..'))
+class ResultsCollector(object):
+ def __init__(self):
+ self.results = {}
+
+ def add_result(self, name, identifier, value, units):
+ assert name not in self.results
+ self.results[name] = {
+ 'identifier': identifier,
+ 'value': int(value),
+ 'units': units
+ }
+
+ # Legacy printing, previously used for parsing the text logs.
+ print 'RESULT %s: %s= %s %s' % (name, identifier, value, units)
+
+
def get_size(filename):
return os.stat(filename)[stat.ST_SIZE]
@@ -67,7 +84,7 @@ def print_si_fail_hint(path_to_tool):
print '# HINT: diff against the log from the last run to see what changed'
-def main_mac(options, args):
+def main_mac(options, args, results_collector):
"""Print appropriate size information about built Mac targets.
Returns the first non-zero exit status of any command it executes,
@@ -271,7 +288,7 @@ def check_linux_binary(target_dir, binary_name, options):
return result, sizes
-def main_linux(options, args):
+def main_linux(options, args, results_collector):
"""Print appropriate size information about built Linux targets.
Returns the first non-zero exit status of any command it executes,
@@ -298,7 +315,7 @@ def main_linux(options, args):
if result == 0:
result = this_result
for name, identifier, totals_id, value, units in this_sizes:
- print 'RESULT %s: %s= %s %s' % (name, identifier, value, units)
+ results_collector.add_result(name, identifier, value, units)
totals_id = totals_id or identifier, units
totals[totals_id] = totals.get(totals_id, 0) + int(value)
@@ -315,15 +332,15 @@ def main_linux(options, args):
if e.errno == errno.ENOENT:
continue # Don't print anything for missing files.
raise
- print 'RESULT %s: %s= %s bytes' % (filename, filename, size)
+ results_collector.add_result(filename, filename, size, 'bytes')
totals['size', 'bytes'] += size
# TODO(mcgrathr): This should all be refactored so the mac and win flavors
# also deliver data structures rather than printing, and the logic for
# the printing and the summing totals is shared across all three flavors.
for (identifier, units), value in sorted(totals.iteritems()):
- print 'RESULT totals-%s: %s= %s %s' % (identifier, identifier,
- value, units)
+ results_collector.add_result(
+ 'totals-%s' % identifier, identifier, value, units)
return result
@@ -344,7 +361,7 @@ def check_android_binaries(binaries, target_dir, options):
return result
-def main_android(options, args):
+def main_android(options, args, results_collector):
"""Print appropriate size information about built Android targets.
Returns the first non-zero exit status of any command it executes,
@@ -361,7 +378,7 @@ def main_android(options, args):
return check_android_binaries(binaries, target_dir, options)
-def main_android_webview(options, args):
+def main_android_webview(options, args, results_collector):
"""Print appropriate size information about Android WebViewChromium targets.
Returns the first non-zero exit status of any command it executes,
@@ -375,7 +392,7 @@ def main_android_webview(options, args):
return check_android_binaries(binaries, target_dir, options)
-def main_android_cronet(options, args):
+def main_android_cronet(options, args, results_collector):
"""Print appropriate size information about Android Cronet targets.
Returns the first non-zero exit status of any command it executes,
@@ -394,7 +411,7 @@ def main_android_cronet(options, args):
return check_android_binaries(binaries, target_dir, options)
-def main_win(options, args):
+def main_win(options, args, results_collector):
"""Print appropriate size information about built Windows targets.
Returns the first non-zero exit status of any command it executes,
@@ -459,6 +476,7 @@ def main():
default=default_platform,
help='specify platform (%s) [default: %%default]'
% ', '.join(platforms))
+ option_parser.add_option('--json', help='Path to JSON output file')
options, args = option_parser.parse_args()
@@ -471,7 +489,15 @@ def main():
msg = 'Use the --platform= option to specify a supported platform:\n'
sys.stderr.write(msg + ' ' + ' '.join(platforms) + '\n')
return 2
- return real_main(options, args)
+
+ results_collector = ResultsCollector()
+ rc = real_main(options, args, results_collector)
+
+ if options.json:
+ with open(options.json, 'w') as f:
+ json.dump(results_collector.results, f)
+
+ return rc
if '__main__' == __name__: