Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Unified Diff: scripts/slave/recipe_modules/test_results/resources/upload_test_results.py

Issue 2469233003: [recipe_modules/test_results] Refactor the logic of generating full json results files to a method (Closed)
Patch Set: Add test & fix Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/test_results/resources/upload_test_results_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/recipe_modules/test_results/resources/upload_test_results.py
diff --git a/scripts/slave/recipe_modules/test_results/resources/upload_test_results.py b/scripts/slave/recipe_modules/test_results/resources/upload_test_results.py
index 2a1ae7ea41e9425499cdd978f6854d3686887300..daf23e9b22ac307e334aaf898c54087dbdec79c3 100755
--- a/scripts/slave/recipe_modules/test_results/resources/upload_test_results.py
+++ b/scripts/slave/recipe_modules/test_results/resources/upload_test_results.py
@@ -49,13 +49,14 @@ def get_results_map_from_json(results_json):
return test_results_map
-def generate_json_results(test_results_map, builder_name, build_number,
+def generate_json_results_file(results_json, builder_name, build_number,
results_directory, chrome_revision, master_name):
- """Generates JSON results files from the given test_results_map.
+ """Generates JSON results files from the given |results_json|.
Args:
estaab 2016/11/03 15:05:09 Can you add a "Returns:" section documenting the r
nednguyen 2016/11/03 21:34:57 Done.
- test_results_map: A map of TestResult.
+ results_json: the raw test results object that follows GTest format.
estaab 2016/11/03 15:05:09 The comment mentions this is in gtest format - is
nednguyen 2016/11/03 21:34:57 Done.
"""
+ test_results_map = get_results_map_from_json(results_json)
nednguyen 2016/11/02 22:56:09 The test also helps catch this bug.
if not os.path.exists(results_directory):
os.makedirs(results_directory)
@@ -78,9 +79,11 @@ def generate_json_results(test_results_map, builder_name, build_number,
master_name=master_name)
generator.generate_json_output()
generator.generate_times_ms_file()
+ return [(f, os.path.join(results_directory, f)) for f in
+ (FULL_RESULTS_FILENAME, TIMES_MS_FILENAME)]
-def main():
+def main(args):
option_parser = optparse.OptionParser()
option_parser.add_option('--test-type',
help='Test type that generated the results json,'
@@ -108,7 +111,7 @@ def main():
help='The Chromium revision being tested. If not '
'given, defaults to 0.')
- options = option_parser.parse_args()[0]
+ options = option_parser.parse_args(args)[0]
logging.basicConfig()
if not options.test_type:
@@ -125,11 +128,14 @@ def main():
'uploaded to the server.')
with file(options.input_json) as json_file:
- results_map = get_results_map_from_json(json_file.read())
+ results_json = json_file.read()
- generate_json_results(results_map, options.builder_name,
- options.build_number, options.results_directory,
- options.chrome_revision, options.master_name)
+ files = generate_json_results_file(
+ results_json, builder_name=options.builder_name,
+ build_number=options.build_number,
+ results_directory=options.results_directory,
+ chrome_revision=options.chrome_revision,
+ master_name=options.master_name)
# Upload to a test results server if specified.
if options.test_results_server and options.master_name:
@@ -139,9 +145,6 @@ def main():
('testtype', options.test_type),
('master', options.master_name)]
- files = [(f, os.path.join(options.results_directory, f)) for f in
- (FULL_RESULTS_FILENAME, TIMES_MS_FILENAME)]
-
# Set uploading timeout in case appengine server is having problem.
# 120 seconds are more than enough to upload test results.
test_results_uploader.upload_test_results(
@@ -150,4 +153,4 @@ def main():
if __name__ == '__main__':
- sys.exit(main())
+ sys.exit(main(sys.argv[1:]))
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/test_results/resources/upload_test_results_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698