OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 3 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license | 5 # Use of this source code is governed by a BSD-style license |
6 # that can be found in the LICENSE file in the root of the source | 6 # that can be found in the LICENSE file in the root of the source |
7 # tree. An additional intellectual property rights grant can be found | 7 # tree. An additional intellectual property rights grant can be found |
8 # in the file PATENTS. All contributing project authors may | 8 # in the file PATENTS. All contributing project authors may |
9 # be found in the AUTHORS file in the root of the source tree. | 9 # be found in the AUTHORS file in the root of the source tree. |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 def main(): | 55 def main(): |
56 # Ignore '--'. Options unprocessed by this script will be passed to the test | 56 # Ignore '--'. Options unprocessed by this script will be passed to the test |
57 # as arguments. | 57 # as arguments. |
58 if '--' in sys.argv: | 58 if '--' in sys.argv: |
59 del sys.argv[sys.argv.index('--')] | 59 del sys.argv[sys.argv.index('--')] |
60 | 60 |
61 parser = argparse.ArgumentParser() | 61 parser = argparse.ArgumentParser() |
62 parser.add_argument('--isolated-script-test-output', type=str, default=None) | 62 parser.add_argument('--isolated-script-test-output', type=str, default=None) |
63 | 63 |
64 # TODO(ehmaldonado): Implement this flag instead of just "eating" it. | 64 # We don't need to implement this flag, and possibly can't, since it's |
| 65 # intended for results of Telemetry tests. See |
| 66 # https://chromium.googlesource.com/external/github.com/catapult-project/catap
ult/+/HEAD/dashboard/docs/data-format.md |
65 parser.add_argument('--isolated-script-test-chartjson-output', type=str, | 67 parser.add_argument('--isolated-script-test-chartjson-output', type=str, |
66 default=None) | 68 default=None) |
67 | 69 |
| 70 # TODO(ehmaldonado): Figure out a way to avoid duplicating the flags in |
| 71 # gtest-parallel. |
| 72 parser.add_argument('--gtest_color', type=str, default='auto') |
68 parser.add_argument('--output_dir', type=str, default=None) | 73 parser.add_argument('--output_dir', type=str, default=None) |
69 parser.add_argument('--timeout', type=int, default=None) | 74 parser.add_argument('--timeout', type=int, default=None) |
70 | 75 |
71 # GTEST_SHARD_INDEX and GTEST_TOTAL_SHARDS must be removed from the | 76 # GTEST_SHARD_INDEX and GTEST_TOTAL_SHARDS must be removed from the |
72 # environment. Otherwise it will be picked up by the binary, causing a bug | 77 # environment. Otherwise it will be picked up by the binary, causing a bug |
73 # where only tests in the first shard are executed. | 78 # where only tests in the first shard are executed. |
74 test_env = os.environ.copy() | 79 test_env = os.environ.copy() |
75 gtest_shard_index = test_env.pop('GTEST_SHARD_INDEX', '0') | 80 gtest_shard_index = test_env.pop('GTEST_SHARD_INDEX', '0') |
76 gtest_total_shards = test_env.pop('GTEST_TOTAL_SHARDS', '1') | 81 gtest_total_shards = test_env.pop('GTEST_TOTAL_SHARDS', '1') |
77 | 82 |
78 webrtc_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 83 webrtc_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
79 gtest_parallel_path = os.path.join( | 84 gtest_parallel_path = os.path.join( |
80 webrtc_root, 'third_party', 'gtest-parallel', 'gtest-parallel') | 85 webrtc_root, 'third_party', 'gtest-parallel', 'gtest-parallel') |
81 | 86 |
82 options, unprocessed = parser.parse_known_args() | 87 options, unprocessed = parser.parse_known_args() |
83 test_executable = unprocessed[0] | 88 test_executable = unprocessed[0] |
84 test_arguments = unprocessed[1:] | 89 test_arguments = unprocessed[1:] |
85 | 90 |
86 gtest_args = [ | 91 gtest_args = [ |
87 test_executable, | 92 test_executable, |
88 '--shard_count', | 93 '--shard_count', |
89 gtest_total_shards, | 94 gtest_total_shards, |
90 '--shard_index', | 95 '--shard_index', |
91 gtest_shard_index, | 96 gtest_shard_index, |
| 97 '--gtest_color', |
| 98 options.gtest_color, |
92 ] | 99 ] |
93 | 100 |
94 # --isolated-script-test-output is used to upload results to the flakiness | 101 # --isolated-script-test-output is used to upload results to the flakiness |
95 # dashboard. This translation is made because gtest-parallel expects the flag | 102 # dashboard. This translation is made because gtest-parallel expects the flag |
96 # to be called --dump_json_test_results instead. | 103 # to be called --dump_json_test_results instead. |
97 if options.isolated_script_test_output: | 104 if options.isolated_script_test_output: |
98 gtest_args += [ | 105 gtest_args += [ |
99 '--dump_json_test_results', | 106 '--dump_json_test_results', |
100 options.isolated_script_test_output, | 107 options.isolated_script_test_output, |
101 ] | 108 ] |
(...skipping 13 matching lines...) Expand all Loading... |
115 command = [ | 122 command = [ |
116 sys.executable, | 123 sys.executable, |
117 gtest_parallel_path, | 124 gtest_parallel_path, |
118 ] + gtest_args + ['--'] + test_arguments | 125 ] + gtest_args + ['--'] + test_arguments |
119 | 126 |
120 print 'gtest-parallel-wrapper: Executing command %s' % ' '.join(command) | 127 print 'gtest-parallel-wrapper: Executing command %s' % ' '.join(command) |
121 sys.stdout.flush() | 128 sys.stdout.flush() |
122 | 129 |
123 exit_code = subprocess.call(command, env=test_env, cwd=os.getcwd()) | 130 exit_code = subprocess.call(command, env=test_env, cwd=os.getcwd()) |
124 | 131 |
125 for test_status in 'passed', 'failed', 'interrupted': | 132 if options.output_dir: |
126 logs_dir = os.path.join(options.output_dir, test_status) | 133 for test_status in 'passed', 'failed', 'interrupted': |
127 if not os.path.isdir(logs_dir): | 134 logs_dir = os.path.join(options.output_dir, test_status) |
128 continue | 135 if not os.path.isdir(logs_dir): |
129 logs = [os.path.join(logs_dir, log) for log in os.listdir(logs_dir)] | 136 continue |
130 log_file = os.path.join(options.output_dir, '%s-tests.log' % test_status) | 137 logs = [os.path.join(logs_dir, log) for log in os.listdir(logs_dir)] |
131 CatFiles(logs, log_file) | 138 log_file = os.path.join(options.output_dir, '%s-tests.log' % test_status) |
132 os.rmdir(logs_dir) | 139 CatFiles(logs, log_file) |
| 140 os.rmdir(logs_dir) |
133 | 141 |
134 return exit_code | 142 return exit_code |
135 | 143 |
136 | 144 |
137 if __name__ == '__main__': | 145 if __name__ == '__main__': |
138 sys.exit(main()) | 146 sys.exit(main()) |
OLD | NEW |