OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2012 Google Inc. All rights reserved. | 3 # Copyright (c) 2012 Google Inc. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
| 7 from __future__ import print_function |
| 8 |
7 __doc__ = """ | 9 __doc__ = """ |
8 gyptest.py -- test runner for GYP tests. | 10 gyptest.py -- test runner for GYP tests. |
9 """ | 11 """ |
10 | 12 |
11 import os | 13 import os |
12 import optparse | 14 import optparse |
13 import subprocess | 15 import subprocess |
14 import sys | 16 import sys |
15 | 17 |
16 class CommandRunner(object): | 18 class CommandRunner(object): |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 sys.stderr.write('Specify -a to get all tests.\n') | 185 sys.stderr.write('Specify -a to get all tests.\n') |
184 return 1 | 186 return 1 |
185 args = ['test'] | 187 args = ['test'] |
186 | 188 |
187 tests = [] | 189 tests = [] |
188 for arg in args: | 190 for arg in args: |
189 if os.path.isdir(arg): | 191 if os.path.isdir(arg): |
190 tests.extend(find_all_gyptest_files(os.path.normpath(arg))) | 192 tests.extend(find_all_gyptest_files(os.path.normpath(arg))) |
191 else: | 193 else: |
192 if not is_test_name(os.path.basename(arg)): | 194 if not is_test_name(os.path.basename(arg)): |
193 print >>sys.stderr, arg, 'is not a valid gyp test name.' | 195 print(arg, 'is not a valid gyp test name.', file=sys.stderr) |
194 sys.exit(1) | 196 sys.exit(1) |
195 tests.append(arg) | 197 tests.append(arg) |
196 | 198 |
197 if opts.list: | 199 if opts.list: |
198 for test in tests: | 200 for test in tests: |
199 print test | 201 print(test) |
200 sys.exit(0) | 202 sys.exit(0) |
201 | 203 |
202 CommandRunner.verbose = not opts.quiet | 204 CommandRunner.verbose = not opts.quiet |
203 CommandRunner.active = not opts.no_exec | 205 CommandRunner.active = not opts.no_exec |
204 cr = CommandRunner() | 206 cr = CommandRunner() |
205 | 207 |
206 os.environ['PYTHONPATH'] = os.path.abspath('test/lib') | 208 os.environ['PYTHONPATH'] = os.path.abspath('test/lib') |
207 if not opts.quiet: | 209 if not opts.quiet: |
208 sys.stdout.write('PYTHONPATH=%s\n' % os.environ['PYTHONPATH']) | 210 sys.stdout.write('PYTHONPATH=%s\n' % os.environ['PYTHONPATH']) |
209 | 211 |
210 passed = [] | 212 passed = [] |
211 failed = [] | 213 failed = [] |
212 no_result = [] | 214 no_result = [] |
213 | 215 |
214 if opts.format: | 216 if opts.format: |
215 format_list = opts.format.split(',') | 217 format_list = opts.format.split(',') |
216 else: | 218 else: |
217 # TODO: not duplicate this mapping from pylib/gyp/__init__.py | 219 # TODO: not duplicate this mapping from pylib/gyp/__init__.py |
218 format_list = { | 220 format_list = { |
219 'aix5': ['make'], | 221 'aix5': ['make'], |
220 'freebsd7': ['make'], | 222 'freebsd7': ['make'], |
221 'freebsd8': ['make'], | 223 'freebsd8': ['make'], |
222 'openbsd5': ['make'], | 224 'openbsd5': ['make'], |
223 'cygwin': ['msvs'], | 225 'cygwin': ['msvs'], |
224 'win32': ['msvs', 'ninja'], | 226 'win32': ['msvs', 'ninja'], |
| 227 'linux': ['make', 'ninja'], |
225 'linux2': ['make', 'ninja'], | 228 'linux2': ['make', 'ninja'], |
226 'linux3': ['make', 'ninja'], | 229 'linux3': ['make', 'ninja'], |
227 'darwin': ['make', 'ninja', 'xcode', 'xcode-ninja'], | 230 'darwin': ['make', 'ninja', 'xcode', 'xcode-ninja'], |
228 }[sys.platform] | 231 }[sys.platform] |
229 | 232 |
230 for format in format_list: | 233 for format in format_list: |
231 os.environ['TESTGYP_FORMAT'] = format | 234 os.environ['TESTGYP_FORMAT'] = format |
232 if not opts.quiet: | 235 if not opts.quiet: |
233 sys.stdout.write('TESTGYP_FORMAT=%s\n' % format) | 236 sys.stdout.write('TESTGYP_FORMAT=%s\n' % format) |
234 | 237 |
(...skipping 30 matching lines...) Expand all Loading... |
265 report("No result from", no_result) | 268 report("No result from", no_result) |
266 | 269 |
267 if failed: | 270 if failed: |
268 return 1 | 271 return 1 |
269 else: | 272 else: |
270 return 0 | 273 return 0 |
271 | 274 |
272 | 275 |
273 if __name__ == "__main__": | 276 if __name__ == "__main__": |
274 sys.exit(main()) | 277 sys.exit(main()) |
OLD | NEW |