Show More
@@ -45,11 +45,11 b'' | |||||
45 |
|
45 | |||
46 | from __future__ import absolute_import, print_function |
|
46 | from __future__ import absolute_import, print_function | |
47 |
|
47 | |||
|
48 | import argparse | |||
48 | import difflib |
|
49 | import difflib | |
49 | import distutils.version as version |
|
50 | import distutils.version as version | |
50 | import errno |
|
51 | import errno | |
51 | import json |
|
52 | import json | |
52 | import optparse |
|
|||
53 | import os |
|
53 | import os | |
54 | import random |
|
54 | import random | |
55 | import re |
|
55 | import re | |
@@ -296,123 +296,126 b' def parsettestcases(path):' | |||||
296 |
|
296 | |||
297 | def getparser(): |
|
297 | def getparser(): | |
298 | """Obtain the OptionParser used by the CLI.""" |
|
298 | """Obtain the OptionParser used by the CLI.""" | |
299 |
parser = |
|
299 | parser = argparse.ArgumentParser(usage='%(prog)s [options] [tests]') | |
300 |
|
300 | |||
301 | # keep these sorted |
|
301 | # keep these sorted | |
302 |
parser.add_ |
|
302 | parser.add_argument("--blacklist", action="append", | |
303 | help="skip tests listed in the specified blacklist file") |
|
303 | help="skip tests listed in the specified blacklist file") | |
304 |
parser.add_ |
|
304 | parser.add_argument("--whitelist", action="append", | |
305 | help="always run tests listed in the specified whitelist file") |
|
305 | help="always run tests listed in the specified whitelist file") | |
306 |
parser.add_ |
|
306 | parser.add_argument("--test-list", action="append", | |
307 |
|
|
307 | help="read tests to run from the specified file") | |
308 |
parser.add_ |
|
308 | parser.add_argument("--changed", | |
309 | help="run tests that are changed in parent rev or working directory") |
|
309 | help="run tests that are changed in parent rev or working directory") | |
310 |
parser.add_ |
|
310 | parser.add_argument("-C", "--annotate", action="store_true", | |
311 | help="output files annotated with coverage") |
|
311 | help="output files annotated with coverage") | |
312 |
parser.add_ |
|
312 | parser.add_argument("-c", "--cover", action="store_true", | |
313 | help="print a test coverage report") |
|
313 | help="print a test coverage report") | |
314 |
parser.add_ |
|
314 | parser.add_argument("--color", choices=["always", "auto", "never"], | |
315 | default=os.environ.get('HGRUNTESTSCOLOR', 'auto'), |
|
315 | default=os.environ.get('HGRUNTESTSCOLOR', 'auto'), | |
316 | help="colorisation: always|auto|never (default: auto)") |
|
316 | help="colorisation: always|auto|never (default: auto)") | |
317 |
parser.add_ |
|
317 | parser.add_argument("-d", "--debug", action="store_true", | |
318 | help="debug mode: write output of test scripts to console" |
|
318 | help="debug mode: write output of test scripts to console" | |
319 | " rather than capturing and diffing it (disables timeout)") |
|
319 | " rather than capturing and diffing it (disables timeout)") | |
320 |
parser.add_ |
|
320 | parser.add_argument("-f", "--first", action="store_true", | |
321 | help="exit on the first test failure") |
|
321 | help="exit on the first test failure") | |
322 |
parser.add_ |
|
322 | parser.add_argument("-H", "--htmlcov", action="store_true", | |
323 | help="create an HTML report of the coverage of the files") |
|
323 | help="create an HTML report of the coverage of the files") | |
324 |
parser.add_ |
|
324 | parser.add_argument("-i", "--interactive", action="store_true", | |
325 | help="prompt to accept changed output") |
|
325 | help="prompt to accept changed output") | |
326 |
parser.add_ |
|
326 | parser.add_argument("-j", "--jobs", type=int, | |
327 | help="number of jobs to run in parallel" |
|
327 | help="number of jobs to run in parallel" | |
328 | " (default: $%s or %d)" % defaults['jobs']) |
|
328 | " (default: $%s or %d)" % defaults['jobs']) | |
329 |
parser.add_ |
|
329 | parser.add_argument("--keep-tmpdir", action="store_true", | |
330 | help="keep temporary directory after running tests") |
|
330 | help="keep temporary directory after running tests") | |
331 |
parser.add_ |
|
331 | parser.add_argument("-k", "--keywords", | |
332 | help="run tests matching keywords") |
|
332 | help="run tests matching keywords") | |
333 |
parser.add_ |
|
333 | parser.add_argument("--list-tests", action="store_true", | |
334 | help="list tests instead of running them") |
|
334 | help="list tests instead of running them") | |
335 |
parser.add_ |
|
335 | parser.add_argument("-l", "--local", action="store_true", | |
336 | help="shortcut for --with-hg=<testdir>/../hg, " |
|
336 | help="shortcut for --with-hg=<testdir>/../hg, " | |
337 | "and --with-chg=<testdir>/../contrib/chg/chg if --chg is set") |
|
337 | "and --with-chg=<testdir>/../contrib/chg/chg if --chg is set") | |
338 |
parser.add_ |
|
338 | parser.add_argument("--loop", action="store_true", | |
339 | help="loop tests repeatedly") |
|
339 | help="loop tests repeatedly") | |
340 |
parser.add_ |
|
340 | parser.add_argument("--runs-per-test", type=int, dest="runs_per_test", | |
341 | help="run each test N times (default=1)", default=1) |
|
341 | help="run each test N times (default=1)", default=1) | |
342 |
parser.add_ |
|
342 | parser.add_argument("-n", "--nodiff", action="store_true", | |
343 | help="skip showing test changes") |
|
343 | help="skip showing test changes") | |
344 |
parser.add_ |
|
344 | parser.add_argument("--outputdir", | |
345 | help="directory to write error logs to (default=test directory)") |
|
345 | help="directory to write error logs to (default=test directory)") | |
346 |
parser.add_ |
|
346 | parser.add_argument("-p", "--port", type=int, | |
347 | help="port on which servers should listen" |
|
347 | help="port on which servers should listen" | |
348 | " (default: $%s or %d)" % defaults['port']) |
|
348 | " (default: $%s or %d)" % defaults['port']) | |
349 |
parser.add_ |
|
349 | parser.add_argument("--compiler", | |
350 | help="compiler to build with") |
|
350 | help="compiler to build with") | |
351 |
parser.add_ |
|
351 | parser.add_argument("--pure", action="store_true", | |
352 | help="use pure Python code instead of C extensions") |
|
352 | help="use pure Python code instead of C extensions") | |
353 |
parser.add_ |
|
353 | parser.add_argument("-R", "--restart", action="store_true", | |
354 | help="restart at last error") |
|
354 | help="restart at last error") | |
355 |
parser.add_ |
|
355 | parser.add_argument("-r", "--retest", action="store_true", | |
356 | help="retest failed tests") |
|
356 | help="retest failed tests") | |
357 |
parser.add_ |
|
357 | parser.add_argument("-S", "--noskips", action="store_true", | |
358 | help="don't report skip tests verbosely") |
|
358 | help="don't report skip tests verbosely") | |
359 |
parser.add_ |
|
359 | parser.add_argument("--shell", | |
360 | help="shell to use (default: $%s or %s)" % defaults['shell']) |
|
360 | help="shell to use (default: $%s or %s)" % defaults['shell']) | |
361 |
parser.add_ |
|
361 | parser.add_argument("-t", "--timeout", type=int, | |
362 | help="kill errant tests after TIMEOUT seconds" |
|
362 | help="kill errant tests after TIMEOUT seconds" | |
363 | " (default: $%s or %d)" % defaults['timeout']) |
|
363 | " (default: $%s or %d)" % defaults['timeout']) | |
364 |
parser.add_ |
|
364 | parser.add_argument("--slowtimeout", type=int, | |
365 | help="kill errant slow tests after SLOWTIMEOUT seconds" |
|
365 | help="kill errant slow tests after SLOWTIMEOUT seconds" | |
366 | " (default: $%s or %d)" % defaults['slowtimeout']) |
|
366 | " (default: $%s or %d)" % defaults['slowtimeout']) | |
367 |
parser.add_ |
|
367 | parser.add_argument("--time", action="store_true", | |
368 | help="time how long each test takes") |
|
368 | help="time how long each test takes") | |
369 |
parser.add_ |
|
369 | parser.add_argument("--json", action="store_true", | |
370 |
|
|
370 | help="store test result data in 'report.json' file") | |
371 |
parser.add_ |
|
371 | parser.add_argument("--tmpdir", | |
372 | help="run tests in the given temporary directory" |
|
372 | help="run tests in the given temporary directory" | |
373 | " (implies --keep-tmpdir)") |
|
373 | " (implies --keep-tmpdir)") | |
374 |
parser.add_ |
|
374 | parser.add_argument("-v", "--verbose", action="store_true", | |
375 | help="output verbose messages") |
|
375 | help="output verbose messages") | |
376 |
parser.add_ |
|
376 | parser.add_argument("--xunit", | |
377 |
|
|
377 | help="record xunit results at specified path") | |
378 |
parser.add_ |
|
378 | parser.add_argument("--view", | |
379 | help="external diff viewer") |
|
379 | help="external diff viewer") | |
380 |
parser.add_ |
|
380 | parser.add_argument("--with-hg", | |
381 | metavar="HG", |
|
381 | metavar="HG", | |
382 | help="test using specified hg script rather than a " |
|
382 | help="test using specified hg script rather than a " | |
383 | "temporary installation") |
|
383 | "temporary installation") | |
384 |
parser.add_ |
|
384 | parser.add_argument("--chg", action="store_true", | |
385 | help="install and use chg wrapper in place of hg") |
|
385 | help="install and use chg wrapper in place of hg") | |
386 |
parser.add_ |
|
386 | parser.add_argument("--with-chg", metavar="CHG", | |
387 | help="use specified chg wrapper in place of hg") |
|
387 | help="use specified chg wrapper in place of hg") | |
388 |
parser.add_ |
|
388 | parser.add_argument("--ipv6", action="store_true", | |
389 | help="prefer IPv6 to IPv4 for network related tests") |
|
389 | help="prefer IPv6 to IPv4 for network related tests") | |
390 |
parser.add_ |
|
390 | parser.add_argument("-3", "--py3k-warnings", action="store_true", | |
391 | help="enable Py3k warnings on Python 2.7+") |
|
391 | help="enable Py3k warnings on Python 2.7+") | |
392 | # This option should be deleted once test-check-py3-compat.t and other |
|
392 | # This option should be deleted once test-check-py3-compat.t and other | |
393 | # Python 3 tests run with Python 3. |
|
393 | # Python 3 tests run with Python 3. | |
394 |
parser.add_ |
|
394 | parser.add_argument("--with-python3", metavar="PYTHON3", | |
395 | help="Python 3 interpreter (if running under Python 2)" |
|
395 | help="Python 3 interpreter (if running under Python 2)" | |
396 | " (TEMPORARY)") |
|
396 | " (TEMPORARY)") | |
397 |
parser.add_ |
|
397 | parser.add_argument('--extra-config-opt', action="append", | |
398 | help='set the given config opt in the test hgrc') |
|
398 | help='set the given config opt in the test hgrc') | |
399 |
parser.add_ |
|
399 | parser.add_argument('--random', action="store_true", | |
400 | help='run tests in random order') |
|
400 | help='run tests in random order') | |
401 |
parser.add_ |
|
401 | parser.add_argument('--profile-runner', action='store_true', | |
402 | help='run statprof on run-tests') |
|
402 | help='run statprof on run-tests') | |
403 |
parser.add_ |
|
403 | parser.add_argument('--allow-slow-tests', action='store_true', | |
404 | help='allow extremely slow tests') |
|
404 | help='allow extremely slow tests') | |
405 |
parser.add_ |
|
405 | parser.add_argument('--showchannels', action='store_true', | |
406 | help='show scheduling channels') |
|
406 | help='show scheduling channels') | |
407 |
parser.add_ |
|
407 | parser.add_argument('--known-good-rev', | |
408 | metavar="known_good_rev", |
|
408 | metavar="known_good_rev", | |
409 | help=("Automatically bisect any failures using this " |
|
409 | help=("Automatically bisect any failures using this " | |
410 | "revision as a known-good revision.")) |
|
410 | "revision as a known-good revision.")) | |
411 |
parser.add_ |
|
411 | parser.add_argument('--bisect-repo', | |
412 | metavar='bisect_repo', |
|
412 | metavar='bisect_repo', | |
413 | help=("Path of a repo to bisect. Use together with " |
|
413 | help=("Path of a repo to bisect. Use together with " | |
414 | "--known-good-rev")) |
|
414 | "--known-good-rev")) | |
415 |
|
415 | |||
|
416 | parser.add_argument('tests', metavar='TESTS', nargs='*', | |||
|
417 | help='Tests to run') | |||
|
418 | ||||
416 | for option, (envvar, default) in defaults.items(): |
|
419 | for option, (envvar, default) in defaults.items(): | |
417 | defaults[option] = type(default)(os.environ.get(envvar, default)) |
|
420 | defaults[option] = type(default)(os.environ.get(envvar, default)) | |
418 | parser.set_defaults(**defaults) |
|
421 | parser.set_defaults(**defaults) | |
@@ -421,7 +424,7 b' def getparser():' | |||||
421 |
|
424 | |||
422 | def parseargs(args, parser): |
|
425 | def parseargs(args, parser): | |
423 | """Parse arguments with our OptionParser and validate results.""" |
|
426 | """Parse arguments with our OptionParser and validate results.""" | |
424 |
|
|
427 | options = parser.parse_args(args) | |
425 |
|
428 | |||
426 | # jython is always pure |
|
429 | # jython is always pure | |
427 | if 'java' in sys.platform or '__pypy__' in sys.modules: |
|
430 | if 'java' in sys.platform or '__pypy__' in sys.modules: | |
@@ -550,7 +553,7 b' def parseargs(args, parser):' | |||||
550 | if options.showchannels: |
|
553 | if options.showchannels: | |
551 | options.nodiff = True |
|
554 | options.nodiff = True | |
552 |
|
555 | |||
553 |
return |
|
556 | return options | |
554 |
|
557 | |||
555 | def rename(src, dst): |
|
558 | def rename(src, dst): | |
556 | """Like os.rename(), trade atomicity and opened files friendliness |
|
559 | """Like os.rename(), trade atomicity and opened files friendliness | |
@@ -2298,18 +2301,16 b' class TestRunner(object):' | |||||
2298 | oldmask = os.umask(0o22) |
|
2301 | oldmask = os.umask(0o22) | |
2299 | try: |
|
2302 | try: | |
2300 | parser = parser or getparser() |
|
2303 | parser = parser or getparser() | |
2301 |
options |
|
2304 | options = parseargs(args, parser) | |
2302 | # positional arguments are paths to test files to run, so |
|
2305 | tests = [_bytespath(a) for a in options.tests] | |
2303 | # we make sure they're all bytestrings |
|
|||
2304 | args = [_bytespath(a) for a in args] |
|
|||
2305 | if options.test_list is not None: |
|
2306 | if options.test_list is not None: | |
2306 | for listfile in options.test_list: |
|
2307 | for listfile in options.test_list: | |
2307 | with open(listfile, 'rb') as f: |
|
2308 | with open(listfile, 'rb') as f: | |
2308 |
|
|
2309 | tests.extend(t for t in f.read().splitlines() if t) | |
2309 | self.options = options |
|
2310 | self.options = options | |
2310 |
|
2311 | |||
2311 | self._checktools() |
|
2312 | self._checktools() | |
2312 |
testdescs = self.findtests( |
|
2313 | testdescs = self.findtests(tests) | |
2313 | if options.profile_runner: |
|
2314 | if options.profile_runner: | |
2314 | import statprof |
|
2315 | import statprof | |
2315 | statprof.start() |
|
2316 | statprof.start() |
@@ -32,8 +32,7 b' error paths' | |||||
32 | #if execbit |
|
32 | #if execbit | |
33 | $ touch hg |
|
33 | $ touch hg | |
34 | $ run-tests.py --with-hg=./hg |
|
34 | $ run-tests.py --with-hg=./hg | |
35 |
|
|
35 | usage: run-tests.py [options] [tests] | |
36 |
|
||||
37 | run-tests.py: error: --with-hg must specify an executable hg script |
|
36 | run-tests.py: error: --with-hg must specify an executable hg script | |
38 | [2] |
|
37 | [2] | |
39 | $ rm hg |
|
38 | $ rm hg | |
@@ -1383,8 +1382,7 b' support bisecting a separate repo' | |||||
1383 | [1] |
|
1382 | [1] | |
1384 |
|
1383 | |||
1385 | $ rt --bisect-repo=../test-bisect test-bisect-dependent.t |
|
1384 | $ rt --bisect-repo=../test-bisect test-bisect-dependent.t | |
1386 |
|
|
1385 | usage: run-tests.py [options] [tests] | |
1387 |
|
||||
1388 | run-tests.py: error: --bisect-repo cannot be used without --known-good-rev |
|
1386 | run-tests.py: error: --bisect-repo cannot be used without --known-good-rev | |
1389 | [2] |
|
1387 | [2] | |
1390 |
|
1388 |
General Comments 0
You need to be logged in to leave comments.
Login now