Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-33873: Backport regrtest from master to 3.7 #7935

Merged
merged 3 commits into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
bpo-33873: Fix bug in runtest.py and add checks for invalid -R pa…
…rameters (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.

(cherry picked from commit 58ed730)
  • Loading branch information
pablogsal authored and vstinner committed Jun 26, 2018
commit 62b588eb338744e0097663637dfdb829c3dd1789
9 changes: 9 additions & 0 deletions Lib/test/libregrtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,15 @@ 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:
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)
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/libregrtest/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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).