Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: googletest/shard_test_cases.py

Issue 19917006: Move all googletest related scripts into googletest/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/swarm_client
Patch Set: Remove unnecessary pylint warning disable Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « googletest/run_test_cases.py ('k') | googletest/tests/fix_test_cases_smoke_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Runs a google-test shard. 6 """Runs a google-test shard.
7 7
8 This makes a simple interface to run a shard on the command line independent of 8 This makes a simple interface to run a shard on the command line independent of
9 the interpreter, e.g. cmd.exe vs bash. 9 the interpreter, e.g. cmd.exe vs bash.
10 """ 10 """
11 11
12 import optparse 12 import optparse
13 import os 13 import os
14 import subprocess 14 import subprocess
15 import sys 15 import sys
16 16
17 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
18 if not ROOT_DIR in sys.path:
19 sys.path.insert(0, ROOT_DIR)
20
17 import run_isolated 21 import run_isolated
18 22
19 23
20 def fix_python_path(cmd):
21 """Returns the fixed command line to call the right python executable."""
22 out = cmd[:]
23 if out[0] == 'python':
24 out[0] = sys.executable
25 elif out[0].endswith('.py'):
26 out.insert(0, sys.executable)
27 return out
28
29
30 def main(): 24 def main():
31 run_isolated.disable_buffering() 25 run_isolated.disable_buffering()
32 parser = optparse.OptionParser(usage='%prog <options> [gtest]') 26 parser = optparse.OptionParser(usage='%prog <options> [gtest]')
33 parser.disable_interspersed_args() 27 parser.disable_interspersed_args()
34 parser.add_option( 28 parser.add_option(
35 '-I', '--index', 29 '-I', '--index',
36 type='int', 30 type='int',
37 default=os.environ.get('GTEST_SHARD_INDEX'), 31 default=os.environ.get('GTEST_SHARD_INDEX'),
38 help='Shard index to run') 32 help='Shard index to run')
39 parser.add_option( 33 parser.add_option(
40 '-S', '--shards', 34 '-S', '--shards',
41 type='int', 35 type='int',
42 default=os.environ.get('GTEST_TOTAL_SHARDS'), 36 default=os.environ.get('GTEST_TOTAL_SHARDS'),
43 help='Total number of shards to calculate from the --index to run') 37 help='Total number of shards to calculate from the --index to run')
44 options, args = parser.parse_args() 38 options, args = parser.parse_args()
45 env = os.environ.copy() 39 env = os.environ.copy()
46 env['GTEST_TOTAL_SHARDS'] = str(options.shards) 40 env['GTEST_TOTAL_SHARDS'] = str(options.shards)
47 env['GTEST_SHARD_INDEX'] = str(options.index) 41 env['GTEST_SHARD_INDEX'] = str(options.index)
48 return subprocess.call(fix_python_path(args), env=env) 42 return subprocess.call(run_isolated.fix_python_path(args), env=env)
49 43
50 44
51 if __name__ == '__main__': 45 if __name__ == '__main__':
52 sys.exit(main()) 46 sys.exit(main())
OLDNEW
« no previous file with comments | « googletest/run_test_cases.py ('k') | googletest/tests/fix_test_cases_smoke_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698