Chromium Code Reviews| 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..00ec46df7e1144a8098a5ff50bfb4c893420e3ce 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,55 @@ 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, _ = parser.parse_known_args(rest_args) |
| + |
| + rest_args_filtered = [] |
| + if option.write_run_test_arguments: |
| + for arg in rest_args: |
| + if arg != '--write-run-test-arguments': |
| + rest_args_filtered.append(arg) |
| + else: |
| + rest_args_filtered = rest_args |
|
Ken Russell (switch to Gerrit)
2017/03/15 04:25:29
This is redundant. Just assign:
option, rest_arg
oetuaho-nv
2017/03/15 10:26:17
Done.
|
| + |
| 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) |
|
Ken Russell (switch to Gerrit)
2017/03/15 04:25:29
I really wish it weren't necessary to do this seco
oetuaho-nv
2017/03/15 10:26:17
Yep, it's ugly but I couldn't think of a better wa
|
| - 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__': |