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 |
| 11 # pylint: disable=invalid-name |
11 """ | 12 """ |
12 This script acts as an interface between the Chromium infrastructure and | 13 This script acts as an interface between the Chromium infrastructure and |
13 gtest-parallel, renaming options and translating environment variables into | 14 gtest-parallel, renaming options and translating environment variables into |
14 flags. Developers should execute gtest-parallel directly. | 15 flags. Developers should execute gtest-parallel directly. |
15 | 16 |
16 In particular, this translates the GTEST_SHARD_INDEX and GTEST_TOTAL_SHARDS | 17 In particular, this translates the GTEST_SHARD_INDEX and GTEST_TOTAL_SHARDS |
17 environment variables to the --shard_index and --shard_count flags, and renames | 18 environment variables to the --shard_index and --shard_count flags, and renames |
18 the --isolated-script-test-output flag to --dump_json_test_results. | 19 the --isolated-script-test-output flag to --dump_json_test_results. |
19 | 20 |
20 Note that the flags unprocessed by this script will passed as arguments to the | 21 Note that the flags unprocessed by this script will passed as arguments to the |
(...skipping 15 matching lines...) Expand all Loading... |
36 --unprocessed_arg_1 | 37 --unprocessed_arg_1 |
37 --unprocessed_arg_2 | 38 --unprocessed_arg_2 |
38 """ | 39 """ |
39 | 40 |
40 import argparse | 41 import argparse |
41 import os | 42 import os |
42 import subprocess | 43 import subprocess |
43 import sys | 44 import sys |
44 | 45 |
45 | 46 |
46 def cat_files(file_list, output_file): | 47 def CatFiles(file_list, output_file): |
47 with open(output_file, 'w') as output_file: | 48 with open(output_file, 'w') as output_file: |
48 for filename in file_list: | 49 for filename in file_list: |
49 with open(filename) as input_file: | 50 with open(filename) as input_file: |
50 output_file.write(input_file.read()) | 51 output_file.write(input_file.read()) |
51 os.remove(filename) | 52 os.remove(filename) |
52 | 53 |
53 | 54 |
54 def main(): | 55 def main(): |
55 # 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 |
56 # as arguments. | 57 # as arguments. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 sys.stdout.flush() | 121 sys.stdout.flush() |
121 | 122 |
122 exit_code = subprocess.call(command, env=test_env, cwd=os.getcwd()) | 123 exit_code = subprocess.call(command, env=test_env, cwd=os.getcwd()) |
123 | 124 |
124 for test_status in 'passed', 'failed', 'interrupted': | 125 for test_status in 'passed', 'failed', 'interrupted': |
125 logs_dir = os.path.join(options.output_dir, test_status) | 126 logs_dir = os.path.join(options.output_dir, test_status) |
126 if not os.path.isdir(logs_dir): | 127 if not os.path.isdir(logs_dir): |
127 continue | 128 continue |
128 logs = [os.path.join(logs_dir, log) for log in os.listdir(logs_dir)] | 129 logs = [os.path.join(logs_dir, log) for log in os.listdir(logs_dir)] |
129 log_file = os.path.join(options.output_dir, '%s-tests.log' % test_status) | 130 log_file = os.path.join(options.output_dir, '%s-tests.log' % test_status) |
130 cat_files(logs, log_file) | 131 CatFiles(logs, log_file) |
131 os.rmdir(logs_dir) | 132 os.rmdir(logs_dir) |
132 | 133 |
133 return exit_code | 134 return exit_code |
134 | 135 |
135 | 136 |
136 if __name__ == '__main__': | 137 if __name__ == '__main__': |
137 sys.exit(main()) | 138 sys.exit(main()) |
OLD | NEW |