Chromium Code Reviews| 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 import os | 11 import os |
|
kjellander_webrtc
2016/12/07 12:36:09
I think it'd be nice with a short module documenta
| |
| 12 import subprocess | 12 import subprocess |
| 13 import sys | 13 import sys |
| 14 | 14 |
| 15 # GTEST_SHARD_INDEX and GTEST_TOTAL_SHARDS must be removed from the environment | 15 # GTEST_SHARD_INDEX and GTEST_TOTAL_SHARDS must be removed from the environment |
| 16 # otherwise it will be picked up by the binary, causing a bug where only tests | 16 # otherwise it will be picked up by the binary, causing a bug where only tests |
| 17 # in the firsh shard are executed. | 17 # in the firsh shard are executed. |
| 18 test_env = os.environ.copy() | 18 test_env = os.environ.copy() |
| 19 gtest_shard_index = test_env.pop('GTEST_SHARD_INDEX', '0') | 19 gtest_shard_index = test_env.pop('GTEST_SHARD_INDEX', '0') |
| 20 gtest_total_shards = test_env.pop('GTEST_TOTAL_SHARDS', '1') | 20 gtest_total_shards = test_env.pop('GTEST_TOTAL_SHARDS', '1') |
| 21 | 21 |
| 22 gtest_parallel_path = os.path.dirname(os.path.abspath(__file__)) | 22 gtest_parallel_path = os.path.dirname(os.path.abspath(__file__)) |
| 23 gtest_parallel_path = os.path.join(gtest_parallel_path, 'gtest-parallel') | 23 gtest_parallel_path = os.path.join(gtest_parallel_path, 'gtest-parallel') |
| 24 | 24 |
| 25 gtest_args = [ | |
| 26 '--shard_count', | |
| 27 gtest_total_shards, | |
| 28 '--shard_index', | |
| 29 gtest_shard_index, | |
| 30 ] | |
| 31 | |
| 32 # --isolated-script-test-output is used to upload results to the flakiness | |
| 33 # dashboard. This translation is made because gtest-parallel expects the flag to | |
| 34 # be called --dump_json_test_results instead. | |
| 35 for i in range(len(sys.argv)): | |
| 36 if sys.argv[i].startswith('--isolated-script-test-output'): | |
|
kjellander_webrtc
2016/12/07 12:36:09
Can you use argparse and add --isolated-script-tes
| |
| 37 gtest_args += [ | |
| 38 '--dump_json_test_results', | |
| 39 sys.argv[i][sys.argv[i].find('=')+1:] | |
| 40 ] | |
| 41 del sys.argv[i] | |
| 42 break | |
| 43 | |
| 25 command = [ | 44 command = [ |
| 26 sys.executable, | 45 sys.executable, |
| 27 gtest_parallel_path, | 46 gtest_parallel_path, |
| 28 '--shard_count', | 47 ] + gtest_args + sys.argv[1:] |
| 29 gtest_total_shards, | |
| 30 '--shard_index', | |
| 31 gtest_shard_index, | |
| 32 ] + sys.argv[1:] | |
| 33 | 48 |
| 34 print 'gtest-parallel-wrapper: Executing command %s' % ' '.join(command) | 49 print 'gtest-parallel-wrapper: Executing command %s' % ' '.join(command) |
| 35 sys.stdout.flush() | 50 sys.stdout.flush() |
| 36 | 51 |
| 37 sys.exit(subprocess.call(command, env=test_env, cwd=os.getcwd())) | 52 sys.exit(subprocess.call(command, env=test_env, cwd=os.getcwd())) |
| OLD | NEW |