[PATCH 2 of 6] run-tests: add support for marking tests as very slow
Augie Fackler
raf at durin42.com
Thu Aug 27 23:26:54 UTC 2015
# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1440469425 14400
# Mon Aug 24 22:23:45 2015 -0400
# Node ID 70a90bb7d98eb587dc69818ae0e421f2dc70be17
# Parent cb466eee7cbde50de90b8324c644d7136a0b9c70
run-tests: add support for marking tests as very slow
I want to add tests for our packaging rules, but those necessarily run
a whole build, or possibly two if both native packaging and docker are
available. This lets us flag such tests with a `#require slow` so that
they don't unnecessarily slow down normal test runs.
diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -427,3 +427,7 @@ def has_py3k():
@check("pure", "running with pure Python code")
def has_pure():
return os.environ.get("HGTEST_RUN_TESTS_PURE") == "--pure"
+
+ at check("slow", "allow slow tests")
+def has_slow():
+ return os.environ.get('HGTEST_SLOW') == 'slow'
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -259,6 +259,8 @@ def getparser():
help='run tests in random order')
parser.add_option('--profile-runner', action='store_true',
help='run statprof on run-tests')
+ parser.add_option('--allow-slow-tests', action='store_true',
+ help='allow extremely slow tests')
for option, (envvar, default) in defaults.items():
defaults[option] = type(default)(os.environ.get(envvar, default))
@@ -1835,6 +1837,11 @@ class TestRunner(object):
if self.options.pure:
os.environ["HGTEST_RUN_TESTS_PURE"] = "--pure"
+ if self.options.allow_slow_tests:
+ os.environ["HGTEST_SLOW"] = "slow"
+ elif 'HGTEST_SLOW' in os.environ:
+ del os.environ['HGTEST_SLOW']
+
self._coveragefile = os.path.join(self._testdir, b'.coverage')
vlog("# Using TESTDIR", self._testdir)
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -621,3 +621,17 @@ test that TESTDIR is referred in PATH
# Ran 1 tests, 0 skipped, 0 warned, 0 failed.
#endif
+
+test support for --allow-slow-tests
+ $ cat > test-very-slow-test.t <<EOF
+ > #require slow
+ > $ echo pass
+ > pass
+ > EOF
+ $ run-tests.py test-very-slow-test.t
+ s
+ Skipped test-very-slow-test.t: skipped
+ # Ran 0 tests, 1 skipped, 0 warned, 0 failed.
+ $ run-tests.py --allow-slow-tests test-very-slow-test.t
+ .
+ # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
More information about the Mercurial-devel
mailing list