Mercurial > hg-stable
changeset 27141:a4e3dec3010e
run-tests: add --slowtimeout and use it for slow tests
author | timeless <timeless@mozdev.org> |
---|---|
date | Wed, 25 Nov 2015 00:39:05 +0000 |
parents | dfdac09b57dd |
children | 060f83d219b9 |
files | tests/run-tests.py tests/test-run-tests.t |
diffstat | 2 files changed, 50 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sat Oct 31 22:17:05 2015 +0900 +++ b/tests/run-tests.py Wed Nov 25 00:39:05 2015 +0000 @@ -154,6 +154,7 @@ defaults = { 'jobs': ('HGTEST_JOBS', 1), 'timeout': ('HGTEST_TIMEOUT', 180), + 'slowtimeout': ('HGTEST_SLOWTIMEOUT', 500), 'port': ('HGTEST_PORT', 20059), 'shell': ('HGTEST_SHELL', 'sh'), } @@ -236,6 +237,9 @@ parser.add_option("-t", "--timeout", type="int", help="kill errant tests after TIMEOUT seconds" " (default: $%s or %d)" % defaults['timeout']) + parser.add_option("--slowtimeout", type="int", + help="kill errant slow tests after SLOWTIMEOUT seconds" + " (default: $%s or %d)" % defaults['slowtimeout']) parser.add_option("--time", action="store_true", help="time how long each test takes") parser.add_option("--json", action="store_true", @@ -327,7 +331,11 @@ if options.timeout != defaults['timeout']: sys.stderr.write( 'warning: --timeout option ignored with --debug\n') + if options.slowtimeout != defaults['slowtimeout']: + sys.stderr.write( + 'warning: --slowtimeout option ignored with --debug\n') options.timeout = 0 + options.slowtimeout = 0 if options.py3k_warnings: if PYTHON3: parser.error( @@ -430,7 +438,8 @@ debug=False, timeout=defaults['timeout'], startport=defaults['port'], extraconfigopts=None, - py3kwarnings=False, shell=None): + py3kwarnings=False, shell=None, + slowtimeout=defaults['slowtimeout']): """Create a test from parameters. path is the full path to the file defining the test. @@ -444,7 +453,9 @@ output. timeout controls the maximum run time of the test. It is ignored when - debug is True. + debug is True. See slowtimeout for tests with #require slow. + + slowtimeout overrides timeout if the test has #require slow. startport controls the starting port number to use for this test. Each test will reserve 3 port numbers for execution. It is the caller's @@ -469,6 +480,7 @@ self._keeptmpdir = keeptmpdir self._debug = debug self._timeout = timeout + self._slowtimeout = slowtimeout self._startport = startport self._extraconfigopts = extraconfigopts or [] self._py3kwarnings = py3kwarnings @@ -922,7 +934,12 @@ print(stdout) sys.exit(1) - return ret == 0 + if ret != 0: + return False + + if 'slow' in reqs: + self._timeout = self._slowtimeout + return True def _parsetest(self, lines): # We generate a shell script which outputs unique markers to line
--- a/tests/test-run-tests.t Sat Oct 31 22:17:05 2015 +0900 +++ b/tests/test-run-tests.t Wed Nov 25 00:39:05 2015 +0000 @@ -401,6 +401,36 @@ . # Ran 1 tests, 0 skipped, 0 warned, 0 failed. +timeouts +======== + $ cat > test-timeout.t <<EOF + > $ sleep 2 + > $ echo pass + > pass + > EOF + > echo '#require slow' > test-slow-timeout.t + > cat test-timeout.t >> test-slow-timeout.t + $ run-tests.py --with-hg=`which hg` --timeout=1 --slowtimeout=3 \ + > test-timeout.t test-slow-timeout.t + s + ERROR: test-timeout.t output changed + ! + Skipped test-slow-timeout.t: skipped + Failed test-timeout.t: timed out + # Ran 1 tests, 1 skipped, 0 warned, 1 failed. + python hash seed: * (glob) + [1] + $ run-tests.py --with-hg=`which hg` --timeout=1 --slowtimeout=3 \ + > test-timeout.t test-slow-timeout.t --allow-slow-tests + . + ERROR: test-timeout.t output changed + ! + Failed test-timeout.t: timed out + # Ran 2 tests, 0 skipped, 0 warned, 1 failed. + python hash seed: * (glob) + [1] + $ rm test-timeout.t test-slow-timeout.t + test for --time ==================