| 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..7a9d3d55576fb23039a2121a59ff4a6510c0be89 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
|
| @@ -26,13 +26,13 @@ FULL_RESULTS_FILENAME = 'full_results.json'
|
| TIMES_MS_FILENAME = 'times_ms.json'
|
|
|
|
|
| -def get_results_map_from_json(results_json):
|
| +def get_results_map_from_json(gtest_json):
|
| """Returns a map of test results given a gtest json string.
|
|
|
| Returns:
|
| {'Test.Name': [TestResult, TestResult, ...], 'Test.Name2': [...]}
|
| """
|
| - contents = json.loads(results_json)
|
| + contents = json.loads(gtest_json)
|
|
|
| test_results_map = {}
|
| for test in contents.get('disabled_tests', []):
|
| @@ -49,13 +49,19 @@ 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(gtest_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 |gtest_json|.
|
|
|
| Args:
|
| - test_results_map: A map of TestResult.
|
| + gtest_json: the raw test results object that follows GTest format.
|
| +
|
| + Returns:
|
| + A list of tuples (<file name>, <file path>). The list has two
|
| + elements: the first represent the full test results file, and the
|
| + second is is the times_ms.json file.
|
| """
|
| + test_results_map = get_results_map_from_json(gtest_json)
|
| if not os.path.exists(results_directory):
|
| os.makedirs(results_directory)
|
|
|
| @@ -78,9 +84,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 +116,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 +133,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 +150,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 +158,4 @@ def main():
|
|
|
|
|
| if __name__ == '__main__':
|
| - sys.exit(main())
|
| + sys.exit(main(sys.argv[1:]))
|
|
|