From 0f0ea7f94a223f7e8551d97a3f8741f963e50c97 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Fri, 15 Jun 2018 23:58:03 +0100 Subject: [PATCH 1/4] Fix bug in `Lib/test/libregrtest/runtest.py` that makes running tests an extra time than specified --- Lib/test/libregrtest/runtest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/libregrtest/runtest.py b/Lib/test/libregrtest/runtest.py index 12bf422c902dc1..3e1afd41997aad 100644 --- a/Lib/test/libregrtest/runtest.py +++ b/Lib/test/libregrtest/runtest.py @@ -173,9 +173,10 @@ def test_runner(): 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: From bc1c8741f77d0459b698629c388c6985e40022a1 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Sat, 16 Jun 2018 00:42:07 +0100 Subject: [PATCH 2/4] Add check for invalid --huntrleaks/-R parameters --- Lib/test/libregrtest/main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py index 3429b3726abe90..4911273ce06ac0 100644 --- a/Lib/test/libregrtest/main.py +++ b/Lib/test/libregrtest/main.py @@ -526,6 +526,13 @@ def main(self, tests=None, **kwargs): 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: + print("Invalid values for the --huntrleaks/-R parameters", + 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) From 7510359dff84e150d9c307083b8b71869c7bed4d Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Sat, 16 Jun 2018 01:32:21 +0100 Subject: [PATCH 3/4] fixup! Add check for invalid --huntrleaks/-R parameters --- Lib/test/libregrtest/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py index 4911273ce06ac0..26daa32dce3f35 100644 --- a/Lib/test/libregrtest/main.py +++ b/Lib/test/libregrtest/main.py @@ -529,8 +529,10 @@ def _main(self, tests, kwargs): if self.ns.huntrleaks: warmup, repetitions, _ = self.ns.huntrleaks if warmup < 1 or repetitions < 1: - print("Invalid values for the --huntrleaks/-R parameters", - file=sys.stderr, flush=True) + 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 7a5ffc3d942c92d7ae99a05aa614e9e0a0b4ef89 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Sat, 16 Jun 2018 01:37:45 +0100 Subject: [PATCH 4/4] Add News entry --- .../next/Tests/2018-06-16-01-37-31.bpo-33873.d86vab.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Tests/2018-06-16-01-37-31.bpo-33873.d86vab.rst 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 index 00000000000000..f4f425570267db --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2018-06-16-01-37-31.bpo-33873.d86vab.rst @@ -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).