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

Side by Side Diff: testing/scripts/run_telemetry_as_googletest.py

Issue 2403913002: [testing/script] Switch run_telemetry_as_googletest.py to produce full json results format (Closed)
Patch Set: Update flag type Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Runs isolate bundled Telemetry unittests. 6 """Runs isolate bundled Telemetry unittests.
7 7
8 This script attempts to emulate the contract of gtest-style tests 8 This script attempts to emulate the contract of gtest-style tests
9 invoked via recipes. The main contract is that the caller passes the 9 invoked via recipes. The main contract is that the caller passes the
10 argument: 10 argument:
(...skipping 17 matching lines...) Expand all
28 import common 28 import common
29 29
30 # Add src/testing/ into sys.path for importing xvfb. 30 # Add src/testing/ into sys.path for importing xvfb.
31 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) 31 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
32 import xvfb 32 import xvfb
33 33
34 34
35 def main(): 35 def main():
36 parser = argparse.ArgumentParser() 36 parser = argparse.ArgumentParser()
37 parser.add_argument( 37 parser.add_argument(
38 '--isolated-script-test-output', type=argparse.FileType('w'), 38 '--isolated-script-test-output', type=str,
39 required=True) 39 required=True)
40 parser.add_argument('--xvfb', help='Start xvfb.', action='store_true') 40 parser.add_argument('--xvfb', help='Start xvfb.', action='store_true')
41 args, rest_args = parser.parse_known_args() 41 args, rest_args = parser.parse_known_args()
42 # Remove the chartjson extra arg until this script cares about chartjson 42 # Remove the chartjson extra arg until this script cares about chartjson
43 # results from telemetry 43 # results from telemetry
44 index = 0 44 index = 0
45 for arg in rest_args: 45 for arg in rest_args:
46 if '--isolated-script-test-chartjson-output' in arg: 46 if '--isolated-script-test-chartjson-output' in arg:
47 rest_args.pop(index) 47 rest_args.pop(index)
48 break 48 break
(...skipping 16 matching lines...) Expand all
65 if 'GTEST_SHARD_INDEX' in env: 65 if 'GTEST_SHARD_INDEX' in env:
66 shard_index = int(env['GTEST_SHARD_INDEX']) 66 shard_index = int(env['GTEST_SHARD_INDEX'])
67 del env['GTEST_SHARD_INDEX'] 67 del env['GTEST_SHARD_INDEX']
68 sharding_args = [] 68 sharding_args = []
69 if total_shards is not None and shard_index is not None: 69 if total_shards is not None and shard_index is not None:
70 sharding_args = [ 70 sharding_args = [
71 '--total-shards=%d' % total_shards, 71 '--total-shards=%d' % total_shards,
72 '--shard-index=%d' % shard_index 72 '--shard-index=%d' % shard_index
73 ] 73 ]
74 try: 74 try:
75 with common.temporary_file() as tempfile_path: 75 return common.run_command([sys.executable] + rest_args + sharding_args + [
76 rc = common.run_command([sys.executable] + rest_args + sharding_args + [ 76 '--write-full-results-to', args.isolated_script_test_output], env=env)
77 '--write-full-results-to', tempfile_path,
78 ], env=env)
79 with open(tempfile_path) as f:
80 results = json.load(f)
81 parsed_results = common.parse_common_test_results(results,
82 test_separator='.')
83 failures = parsed_results['unexpected_failures']
84
85 json.dump({
86 'valid': bool(rc <= common.MAX_FAILURES_EXIT_STATUS and
87 ((rc == 0) or failures)),
88 'failures': failures.keys(),
89 }, args.isolated_script_test_output)
90
91 return rc
92 finally: 77 finally:
93 xvfb.kill(xvfb_proc) 78 xvfb.kill(xvfb_proc)
94 xvfb.kill(openbox_proc) 79 xvfb.kill(openbox_proc)
95 xvfb.kill(xcompmgr_proc) 80 xvfb.kill(xcompmgr_proc)
96 81
97 82
98 83
99 # This is not really a "script test" so does not need to manually add 84 # This is not really a "script test" so does not need to manually add
100 # any additional compile targets. 85 # any additional compile targets.
101 def main_compile_targets(args): 86 def main_compile_targets(args):
102 json.dump([], args.output) 87 json.dump([], args.output)
103 88
104 89
105 if __name__ == '__main__': 90 if __name__ == '__main__':
106 # Conform minimally to the protocol defined by ScriptTest. 91 # Conform minimally to the protocol defined by ScriptTest.
107 if 'compile_targets' in sys.argv: 92 if 'compile_targets' in sys.argv:
108 funcs = { 93 funcs = {
109 'run': None, 94 'run': None,
110 'compile_targets': main_compile_targets, 95 'compile_targets': main_compile_targets,
111 } 96 }
112 sys.exit(common.run_script(sys.argv[1:], funcs)) 97 sys.exit(common.run_script(sys.argv[1:], funcs))
113 sys.exit(main()) 98 sys.exit(main())
OLDNEW
« 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