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

Side by Side Diff: tools/isolate/fix_test_cases.py

Issue 10876080: Get fix_test_cases.py to run on Windows (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 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
« no previous file with comments | « no previous file | no next file » | 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 """Scripts to run a test, grab the failures and trace them.""" 6 """Scripts to run a test, grab the failures and trace them."""
7 7
8 import json 8 import json
9 import os 9 import os
10 import subprocess 10 import subprocess
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 Assumes run_test_cases.py is implicitly called. 56 Assumes run_test_cases.py is implicitly called.
57 """ 57 """
58 handle, result_file = tempfile.mkstemp(prefix='run_test_cases') 58 handle, result_file = tempfile.mkstemp(prefix='run_test_cases')
59 os.close(handle) 59 os.close(handle)
60 env = os.environ.copy() 60 env = os.environ.copy()
61 env['RUN_TEST_CASES_RESULT_FILE'] = result_file 61 env['RUN_TEST_CASES_RESULT_FILE'] = result_file
62 env['GTEST_SHARD_INDEX'] = str(shard_index) 62 env['GTEST_SHARD_INDEX'] = str(shard_index)
63 env['GTEST_TOTAL_SHARDS'] = str(shard_count) 63 env['GTEST_TOTAL_SHARDS'] = str(shard_count)
64 cmd = [sys.executable, 'isolate.py', 'run', '-r', result] 64 cmd = [sys.executable, 'isolate.py', 'run', '-r', result]
65 return_code = subprocess.call(cmd, env=env) 65 subprocess.call(cmd, env=env)
66 if not os.path.isfile(result_file): 66 if not os.path.isfile(result_file):
67 print >> sys.stderr, 'Failed to find %s' % result_file 67 print >> sys.stderr, 'Failed to find %s' % result_file
68 return None 68 return None
69 if return_code:
70 print >> sys.stderr, 'Failed to run isolate.py run'
71 return None
72 with open(result_file) as f: 69 with open(result_file) as f:
73 try: 70 try:
74 data = json.load(f) 71 data = json.load(f)
75 except ValueError as e: 72 except ValueError as e:
76 print >> sys.stderr, ('Unable to load json file, %s: %s' % 73 print >> sys.stderr, ('Unable to load json file, %s: %s' %
77 (result_file, str(e))) 74 (result_file, str(e)))
78 return None 75 return None
79 os.remove(result_file) 76 os.remove(result_file)
80 return [ 77 return [
81 test for test, runs in data.iteritems() 78 test for test, runs in data.iteritems()
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 158
162 print 'Test cases still failing (%d):' % len(failures) 159 print 'Test cases still failing (%d):' % len(failures)
163 for failure in failures: 160 for failure in failures:
164 print ' %s' % failure 161 print ' %s' % failure
165 return not failures 162 return not failures
166 163
167 164
168 def main(): 165 def main():
169 parser = run_test_cases.OptionParserWithTestSharding( 166 parser = run_test_cases.OptionParserWithTestSharding(
170 usage='%prog <option> [test]') 167 usage='%prog <option> [test]')
168 parser.add_option('-d', '--dir', default='../../out/Release',
M-A Ruel 2012/08/27 19:24:34 (Note that I use ninja on Windows)
169 help='The directory containing the the test executable and '
170 'result file. Defaults to %default')
171 options, args = parser.parse_args() 171 options, args = parser.parse_args()
172 172
173 if len(args) != 1: 173 if len(args) != 1:
174 parser.error('Use with the name of the test only, e.g. "unit_tests"') 174 parser.error('Use with the name of the test only, e.g. unit_tests')
175 175
176 basename = args[0] 176 basename = args[0]
177 executable = '../../out/Release/%s' % basename 177 executable = os.path.join(options.dir, basename)
178 result = '%s.results' % executable 178 result = '%s.results' % executable
179 if sys.platform == 'win32': 179 if sys.platform in('win32', 'cygwin'):
180 executable += '.exe' 180 executable += '.exe'
181 if not os.path.isfile(executable): 181 if not os.path.isfile(executable):
182 print >> sys.stderr, ( 182 print >> sys.stderr, (
183 '%s doesn\'t exist, please build %s_run' % (executable, basename)) 183 '%s doesn\'t exist, please build %s_run' % (executable, basename))
184 return 1 184 return 1
185 if not os.path.isfile(result): 185 if not os.path.isfile(result):
186 print >> sys.stderr, ( 186 print >> sys.stderr, (
187 '%s doesn\'t exist, please build %s_run' % (result, basename)) 187 '%s doesn\'t exist, please build %s_run' % (result, basename))
188 return 1 188 return 1
189 189
190 return not fix_all(result, options.index, options.shards) 190 return not fix_all(result, options.index, options.shards)
191 191
192 192
193 if __name__ == '__main__': 193 if __name__ == '__main__':
194 sys.exit(main()) 194 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698