Update gtest-parallel and introduce gtest-parallel-wrapper.
Now gtest-parallel is the same as in the github repo. A wrapper script was created to handle the environment variables. TBR=pbos@webrtc.org BUG=chromium:497757 NOTRY=True Review-Url: https://codereview.webrtc.org/2513073002 Cr-Commit-Position: refs/heads/master@{#15170}
This commit is contained in:
parent
de609b26c5
commit
ab102f1632
8
third_party/gtest-parallel/README.webrtc
vendored
8
third_party/gtest-parallel/README.webrtc
vendored
@ -1,9 +1,13 @@
|
||||
URL: https://github.com/google/gtest-parallel
|
||||
Version: d0cebaba01c5dbf3af8a1c89b64eed7596c2b56c
|
||||
Version: 89b859c1412089468599a3366a72a1e774ce5c2c
|
||||
License: Apache 2.0
|
||||
License File: LICENSE
|
||||
|
||||
Description:
|
||||
Parallelization script for gtest binaries.
|
||||
|
||||
Local Modifications: None
|
||||
Local Modifications:
|
||||
Added gtest-parallel-wrapper.py to convert the GTEST_SHARD_INDEX and
|
||||
GTEST_TOTAL_SHARDS environment variables to flags, since gtest-parallel takes
|
||||
flags as arguments, and delete them afterwards, since letting them set
|
||||
introduces a bug where only tests in the first shard are executed.
|
||||
|
||||
31
third_party/gtest-parallel/gtest-parallel
vendored
31
third_party/gtest-parallel/gtest-parallel
vendored
@ -265,16 +265,13 @@ parser.add_option('--gtest_also_run_disabled_tests', action='store_true',
|
||||
parser.add_option('--format', type='string', default='filter',
|
||||
help='output format (raw,filter)')
|
||||
parser.add_option('--print_test_times', action='store_true', default=False,
|
||||
help='When done, list the run time of each test')
|
||||
parser.add_option('--shard_count', type='int',
|
||||
default=int(os.environ.pop('GTEST_TOTAL_SHARDS', 1)),
|
||||
help=('Total number of shards (for sharding test execution '
|
||||
'between multiple machines). Default: %default'))
|
||||
parser.add_option('--shard_index', type='int',
|
||||
default=int(os.environ.pop('GTEST_SHARD_INDEX', 0)),
|
||||
help=('Zero-indexed number identifying this shard (for '
|
||||
'sharding test execution between multiple machines). '
|
||||
'Default: %default'))
|
||||
help='list the run time of each test at the end of execution')
|
||||
parser.add_option('--shard_count', type='int', default=1,
|
||||
help='total number of shards (for sharding test execution '
|
||||
'between multiple machines)')
|
||||
parser.add_option('--shard_index', type='int', default=0,
|
||||
help='zero-indexed number identifying this shard (for '
|
||||
'sharding test execution between multiple machines)')
|
||||
|
||||
(options, binaries) = parser.parse_args()
|
||||
|
||||
@ -288,15 +285,15 @@ if options.format == 'raw':
|
||||
elif options.format == 'filter':
|
||||
logger = FilterFormat()
|
||||
else:
|
||||
sys.exit("Unknown output format: " + options.format)
|
||||
parser.error("Unknown output format: " + options.format)
|
||||
|
||||
if options.shard_count < 1:
|
||||
sys.exit("Invalid number of shards: %d. Must be at least 1." %
|
||||
options.shard_count)
|
||||
if options.shard_index < 0 or options.shard_count <= options.shard_index:
|
||||
sys.exit("Invalid shard index: %d. Must be between 0 and %d." %
|
||||
(options.shard_index, options.shard_count - 1))
|
||||
|
||||
parser.error("Invalid number of shards: %d. Must be at least 1." %
|
||||
options.shard_count)
|
||||
if not (0 <= options.shard_index < options.shard_count):
|
||||
parser.error("Invalid shard index: %d. Must be between 0 and %d "
|
||||
"(less than the number of shards)." %
|
||||
(options.shard_index, options.shard_count - 1))
|
||||
|
||||
# Find tests.
|
||||
save_file = os.path.join(os.path.expanduser("~"), ".gtest-parallel-times")
|
||||
|
||||
37
third_party/gtest-parallel/gtest-parallel-wrapper.py
vendored
Executable file
37
third_party/gtest-parallel/gtest-parallel-wrapper.py
vendored
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# GTEST_SHARD_INDEX and GTEST_TOTAL_SHARDS must be removed from the environment
|
||||
# otherwise it will be picked up by the binary, causing a bug where only tests
|
||||
# in the firsh shard are executed.
|
||||
test_env = os.environ.copy()
|
||||
gtest_shard_index = test_env.pop('GTEST_SHARD_INDEX', '0')
|
||||
gtest_total_shards = test_env.pop('GTEST_TOTAL_SHARDS', '1')
|
||||
|
||||
gtest_parallel_path = os.path.dirname(os.path.abspath(__file__))
|
||||
gtest_parallel_path = os.path.join(gtest_parallel_path, 'gtest-parallel')
|
||||
|
||||
command = [
|
||||
sys.executable,
|
||||
gtest_parallel_path,
|
||||
'--shard_count',
|
||||
gtest_total_shards,
|
||||
'--shard_index',
|
||||
gtest_shard_index,
|
||||
] + sys.argv[1:]
|
||||
|
||||
print 'gtest-parallel-wrapper: Executing command %s' % ' '.join(command)
|
||||
sys.stdout.flush()
|
||||
|
||||
sys.exit(subprocess.call(command, env=test_env, cwd=os.getcwd()))
|
||||
@ -1117,22 +1117,22 @@ class MetaBuildWrapper(object):
|
||||
'../../testing/test_env.py',
|
||||
'../../testing/xvfb.py',
|
||||
'../../third_party/gtest-parallel/gtest-parallel',
|
||||
'../../third_party/gtest-parallel/gtest-parallel-wrapper.py',
|
||||
]
|
||||
cmdline = [
|
||||
'../../testing/xvfb.py',
|
||||
'.',
|
||||
'python',
|
||||
'../../third_party/gtest-parallel/gtest-parallel',
|
||||
'../../testing/xvfb.py',
|
||||
'.',
|
||||
'../../third_party/gtest-parallel/gtest-parallel-wrapper.py',
|
||||
] + common_cmdline
|
||||
elif test_type in ('windowed_test_launcher', 'console_test_launcher'):
|
||||
extra_files = [
|
||||
'../../testing/test_env.py',
|
||||
'../../third_party/gtest-parallel/gtest-parallel',
|
||||
'../../third_party/gtest-parallel/gtest-parallel-wrapper.py',
|
||||
]
|
||||
cmdline = [
|
||||
'../../testing/test_env.py',
|
||||
'python',
|
||||
'../../third_party/gtest-parallel/gtest-parallel',
|
||||
'../../third_party/gtest-parallel/gtest-parallel-wrapper.py',
|
||||
] + common_cmdline
|
||||
elif test_type == 'non_parallel_console_test_launcher':
|
||||
extra_files = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user