]> granicus.if.org Git - python/commitdiff
bpo-33873: Fix bug in `runtest.py` and add checks for invalid `-R` parameters (GH...
authorPablo Galindo <Pablogsal@gmail.com>
Tue, 26 Jun 2018 14:17:26 +0000 (15:17 +0100)
committerGitHub <noreply@github.com>
Tue, 26 Jun 2018 14:17:26 +0000 (15:17 +0100)
Fix bug in `Lib/test/libregrtest/runtest.py` that makes running tests an extra time than the specified number of runs.

Add check for invalid --huntrleaks/-R parameters.

Lib/test/libregrtest/main.py
Lib/test/libregrtest/runtest.py
Misc/NEWS.d/next/Tests/2018-06-16-01-37-31.bpo-33873.d86vab.rst [new file with mode: 0644]

index 569d034af1a3389ba254dedb393de89e45636568..e262a7a172b93172bb2392c0950289ca51436cc3 100644 (file)
@@ -533,6 +533,15 @@ class Regrtest:
     def _main(self, tests, kwargs):
         self.ns = self.parse_args(kwargs)
 
+        if self.ns.huntrleaks:
+            warmup, repetitions, _ = self.ns.huntrleaks
+            if warmup < 1 or repetitions < 1:
+                msg = ("Invalid values for the --huntrleaks/-R parameters. The "
+                       "number of warmups and repetitions must be at least 1 "
+                       "each (1:1).")
+                print(msg, file=sys.stderr, flush=True)
+                sys.exit(2)
+
         if self.ns.slaveargs is not None:
             from test.libregrtest.runtest_mp import run_tests_slave
             run_tests_slave(self.ns.slaveargs)
index 12bf422c902dc1cd77b54f8b2dafd7ee2b1f85e7..3e1afd41997aad40e9881da2dbdbd64e2a2575e7 100644 (file)
@@ -173,9 +173,10 @@ def runtest_inner(ns, test, display_failure=True):
                     if loader.errors:
                         raise Exception("errors while loading tests")
                     support.run_unittest(tests)
-            test_runner()
             if ns.huntrleaks:
                 refleak = dash_R(the_module, test, test_runner, ns.huntrleaks)
+            else:
+                test_runner()
             test_time = time.time() - start_time
         post_test_cleanup()
     except support.ResourceDenied as msg:
diff --git a/Misc/NEWS.d/next/Tests/2018-06-16-01-37-31.bpo-33873.d86vab.rst b/Misc/NEWS.d/next/Tests/2018-06-16-01-37-31.bpo-33873.d86vab.rst
new file mode 100644 (file)
index 0000000..f4f4255
--- /dev/null
@@ -0,0 +1,4 @@
+Fix a bug in ``regrtest`` that caused an extra test to run if
+--huntrleaks/-R was used. Exit with error in case that invalid
+parameters are specified to --huntrleaks/-R (at least one warmup
+run and one repetition must be used).