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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 # TODO(ehmaldonado): Implement this flag instead of just "eating" it. |
65 parser.add_argument('--isolated-script-test-chartjson-output', type=str, | 65 parser.add_argument('--isolated-script-test-chartjson-output', type=str, |
ehmaldonado_webrtc
2017/04/28 10:32:39
Not related to this CL, but I think we don't need
kjellander_webrtc
2017/04/28 10:59:38
I see, can you update the comment to mention the a
| |
66 default=None) | 66 default=None) |
67 | 67 |
68 # TODO(ehmaldonado): Figure out a way to avoid duplicating the flags in | |
69 # gtest-parallel. | |
70 parser.add_argument('--gtest_color', type=str, default='yes') | |
kjellander_webrtc
2017/04/28 10:59:38
What about having 'auto' as the default, since it
| |
68 parser.add_argument('--output_dir', type=str, default=None) | 71 parser.add_argument('--output_dir', type=str, default=None) |
69 parser.add_argument('--timeout', type=int, default=None) | 72 parser.add_argument('--timeout', type=int, default=None) |
70 | 73 |
71 # GTEST_SHARD_INDEX and GTEST_TOTAL_SHARDS must be removed from the | 74 # 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 | 75 # environment. Otherwise it will be picked up by the binary, causing a bug |
73 # where only tests in the first shard are executed. | 76 # where only tests in the first shard are executed. |
74 test_env = os.environ.copy() | 77 test_env = os.environ.copy() |
75 gtest_shard_index = test_env.pop('GTEST_SHARD_INDEX', '0') | 78 gtest_shard_index = test_env.pop('GTEST_SHARD_INDEX', '0') |
76 gtest_total_shards = test_env.pop('GTEST_TOTAL_SHARDS', '1') | 79 gtest_total_shards = test_env.pop('GTEST_TOTAL_SHARDS', '1') |
77 | 80 |
78 webrtc_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 81 webrtc_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
79 gtest_parallel_path = os.path.join( | 82 gtest_parallel_path = os.path.join( |
80 webrtc_root, 'third_party', 'gtest-parallel', 'gtest-parallel') | 83 webrtc_root, 'third_party', 'gtest-parallel', 'gtest-parallel') |
81 | 84 |
82 options, unprocessed = parser.parse_known_args() | 85 options, unprocessed = parser.parse_known_args() |
83 test_executable = unprocessed[0] | 86 test_executable = unprocessed[0] |
84 test_arguments = unprocessed[1:] | 87 test_arguments = unprocessed[1:] |
85 | 88 |
86 gtest_args = [ | 89 gtest_args = [ |
87 test_executable, | 90 test_executable, |
88 '--shard_count', | 91 '--shard_count', |
89 gtest_total_shards, | 92 gtest_total_shards, |
90 '--shard_index', | 93 '--shard_index', |
91 gtest_shard_index, | 94 gtest_shard_index, |
95 '--gtest_color', | |
96 options.gtest_color, | |
92 ] | 97 ] |
93 | 98 |
94 # --isolated-script-test-output is used to upload results to the flakiness | 99 # --isolated-script-test-output is used to upload results to the flakiness |
95 # dashboard. This translation is made because gtest-parallel expects the flag | 100 # dashboard. This translation is made because gtest-parallel expects the flag |
96 # to be called --dump_json_test_results instead. | 101 # to be called --dump_json_test_results instead. |
97 if options.isolated_script_test_output: | 102 if options.isolated_script_test_output: |
98 gtest_args += [ | 103 gtest_args += [ |
99 '--dump_json_test_results', | 104 '--dump_json_test_results', |
100 options.isolated_script_test_output, | 105 options.isolated_script_test_output, |
101 ] | 106 ] |
(...skipping 13 matching lines...) Expand all Loading... | |
115 command = [ | 120 command = [ |
116 sys.executable, | 121 sys.executable, |
117 gtest_parallel_path, | 122 gtest_parallel_path, |
118 ] + gtest_args + ['--'] + test_arguments | 123 ] + gtest_args + ['--'] + test_arguments |
119 | 124 |
120 print 'gtest-parallel-wrapper: Executing command %s' % ' '.join(command) | 125 print 'gtest-parallel-wrapper: Executing command %s' % ' '.join(command) |
121 sys.stdout.flush() | 126 sys.stdout.flush() |
122 | 127 |
123 exit_code = subprocess.call(command, env=test_env, cwd=os.getcwd()) | 128 exit_code = subprocess.call(command, env=test_env, cwd=os.getcwd()) |
124 | 129 |
125 for test_status in 'passed', 'failed', 'interrupted': | 130 if options.output_dir: |
kjellander_webrtc
2017/04/28 10:59:38
if this is a bugfix, can you mention it in the CL
| |
126 logs_dir = os.path.join(options.output_dir, test_status) | 131 for test_status in 'passed', 'failed', 'interrupted': |
127 if not os.path.isdir(logs_dir): | 132 logs_dir = os.path.join(options.output_dir, test_status) |
128 continue | 133 if not os.path.isdir(logs_dir): |
129 logs = [os.path.join(logs_dir, log) for log in os.listdir(logs_dir)] | 134 continue |
130 log_file = os.path.join(options.output_dir, '%s-tests.log' % test_status) | 135 logs = [os.path.join(logs_dir, log) for log in os.listdir(logs_dir)] |
131 CatFiles(logs, log_file) | 136 log_file = os.path.join(options.output_dir, '%s-tests.log' % test_status) |
132 os.rmdir(logs_dir) | 137 CatFiles(logs, log_file) |
138 os.rmdir(logs_dir) | |
133 | 139 |
134 return exit_code | 140 return exit_code |
135 | 141 |
136 | 142 |
137 if __name__ == '__main__': | 143 if __name__ == '__main__': |
138 sys.exit(main()) | 144 sys.exit(main()) |
OLD | NEW |