changeset 26109:bad09bd22b6a

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.
author Augie Fackler <augie@google.com>
date Mon, 24 Aug 2015 22:23:45 -0400
parents 05306b9359d3
children 2dcfb98c5314
files tests/hghave.py tests/run-tests.py tests/test-run-tests.t
diffstat 3 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/hghave.py	Tue Aug 25 00:02:44 2015 -0400
+++ b/tests/hghave.py	Mon Aug 24 22:23:45 2015 -0400
@@ -427,3 +427,7 @@
 @check("pure", "running with pure Python code")
 def has_pure():
     return os.environ.get("HGTEST_RUN_TESTS_PURE") == "--pure"
+
+@check("slow", "allow slow tests")
+def has_slow():
+    return os.environ.get('HGTEST_SLOW') == 'slow'
--- a/tests/run-tests.py	Tue Aug 25 00:02:44 2015 -0400
+++ b/tests/run-tests.py	Mon Aug 24 22:23:45 2015 -0400
@@ -259,6 +259,8 @@
                       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 @@
         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)
--- a/tests/test-run-tests.t	Tue Aug 25 00:02:44 2015 -0400
+++ b/tests/test-run-tests.t	Mon Aug 24 22:23:45 2015 -0400
@@ -621,3 +621,17 @@
   # 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.