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

Unified Diff: content/test/gpu/run_gpu_integration_test.py

Issue 2735373002: Fix writing GPU test runner arguments to results file (Closed)
Patch Set: Clean up argument filtering Created 3 years, 9 months 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/gpu/run_gpu_integration_test.py
diff --git a/content/test/gpu/run_gpu_integration_test.py b/content/test/gpu/run_gpu_integration_test.py
index 16deb3aef05a349d991e865b92729043670239f9..4845805fec5ab6deb0a61b5aace17372a1052e21 100755
--- a/content/test/gpu/run_gpu_integration_test.py
+++ b/content/test/gpu/run_gpu_integration_test.py
@@ -5,6 +5,7 @@
import argparse
import json
+import os
import sys
from gpu_tests import path_util
@@ -15,31 +16,47 @@ path_util.SetupTelemetryPaths()
from telemetry.testing import browser_test_runner
def PostprocessJSON(file_name, run_test_args):
- def TrimPrefix(s):
- return s[1 + s.rfind('.'):]
- with open(file_name) as f:
- test_result = json.load(f)
- test_result['successes'] = map(TrimPrefix, test_result['successes'])
- test_result['failures'] = map(TrimPrefix, test_result['failures'])
- test_result['run_test_args'] = run_test_args
- with open(file_name, 'w') as f:
- json.dump(test_result, f)
+ # The file is not necessarily written depending on the arguments - only
+ # postprocess it in case it is.
+ if os.path.isfile(file_name):
+ with open(file_name) as f:
+ test_result = json.load(f)
+ test_result['run_test_args'] = run_test_args
+ with open(file_name, 'w') as f:
+ json.dump(test_result, f, indent=2)
def main():
rest_args = sys.argv[1:]
+ parser = argparse.ArgumentParser(description='Extra argument parser',
+ add_help=False)
+
+ parser.add_argument(
+ '--write-run-test-arguments',
+ action='store_true',
+ help=('Write the test script arguments to the results file.'))
+ option, rest_args_filtered = parser.parse_known_args(rest_args)
+
retval = browser_test_runner.Run(
- gpu_project_config.CONFIG, rest_args)
- # Postprocess the outputted JSON to trim all of the prefixes from
- # the test names, to keep them as similar to the old form as
- # possible -- and keep them from getting crazily long.
- parser = argparse.ArgumentParser(description='Temporary argument parser')
+ gpu_project_config.CONFIG, rest_args_filtered)
+
+ # We're not relying on argparse to print the help in the normal way, because
+ # we need the help output from both the argument parser here and the argument
+ # parser in browser_test_runner.
+ if '--help' in rest_args:
+ parser.print_help()
+ return retval
+
+ # This duplicates an argument of browser_test_runner.
parser.add_argument(
- '--write-abbreviated-json-results-to', metavar='FILENAME',
+ '--write-full-results-to', metavar='FILENAME',
action='store',
- help=('Full path for json results'))
+ help=('If specified, writes the full results to that path.'))
+
option, _ = parser.parse_known_args(rest_args)
- if option.write_abbreviated_json_results_to:
- PostprocessJSON(option.write_abbreviated_json_results_to, rest_args)
+
+ # Postprocess the outputted JSON to add test arguments.
+ if option.write_run_test_arguments and option.write_full_results_to:
+ PostprocessJSON(option.write_full_results_to, rest_args)
return retval
if __name__ == '__main__':
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698