summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2018-06-26 14:17:26 (GMT)
committerGitHub <noreply@github.com>2018-06-26 14:17:26 (GMT)
commit58ed7307ea0b5c5aa052291ebc3030f314f938d8 (patch)
tree8dd98ecb282b6e71b2f07cab9ee69c3b40134234 /Lib/test
parent866c168a5f9330d8a3ae109fa8baab2509f35cc7 (diff)
downloadcpython-58ed7307ea0b5c5aa052291ebc3030f314f938d8.zip
cpython-58ed7307ea0b5c5aa052291ebc3030f314f938d8.tar.gz
cpython-58ed7307ea0b5c5aa052291ebc3030f314f938d8.tar.bz2
bpo-33873: Fix bug in `runtest.py` and add checks for invalid `-R` parameters (GH-7735)
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.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/libregrtest/main.py9
-rw-r--r--Lib/test/libregrtest/runtest.py3
2 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index 569d034..e262a7a 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -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)
diff --git a/Lib/test/libregrtest/runtest.py b/Lib/test/libregrtest/runtest.py
index 12bf422..3e1afd4 100644
--- a/Lib/test/libregrtest/runtest.py
+++ b/Lib/test/libregrtest/runtest.py
@@ -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: