Issue #25220, libregrtest: Call setup_python(ns) in the slaves

Slaves (child processes running tests for regrtest -jN) now inherit
--memlimit/-M, --threshold/-t and --nowindows/-n options.

* -M, -t and -n are now supported with -jN
* Factorize code to run tests.
* run_test_in_subprocess() now pass the whole "ns" namespace to the child
  process.
This commit is contained in:
Victor Stinner 2015-09-30 01:39:28 +02:00
parent 8bb19f094b
commit ecef622fec
4 changed files with 7 additions and 9 deletions

View File

@ -295,8 +295,6 @@ def _parse_args(args, **kwargs):
parser.error("-T and -j don't go together!")
if ns.use_mp and ns.findleaks:
parser.error("-l and -j don't go together!")
if ns.use_mp and ns.memlimit:
parser.error("-M and -j don't go together!")
if ns.failfast and not (ns.verbose or ns.verbose3):
parser.error("-G/--failfast needs either -v or -W")

View File

@ -354,14 +354,15 @@ class Regrtest:
def main(self, tests=None, **kwargs):
self.ns = self.parse_args(kwargs)
setup_python(self.ns)
if self.ns.slaveargs is not None:
from test.libregrtest.runtest_mp import run_tests_slave
run_tests_slave(self.ns.slaveargs)
if self.ns.wait:
input("Press any key to continue...")
setup_python(self.ns)
self.find_tests(tests)
self.run_tests()

View File

@ -13,7 +13,8 @@ except ImportError:
print("Multiprocess option requires thread support")
sys.exit(2)
from test.libregrtest.runtest import runtest, INTERRUPTED, CHILD_ERROR
from test.libregrtest.runtest import runtest_ns, INTERRUPTED, CHILD_ERROR
from test.libregrtest.setup import setup_python
# Minimum duration of a test to display its duration or to mention that
@ -58,11 +59,10 @@ def run_tests_slave(slaveargs):
ns_dict, testname = json.loads(slaveargs)
ns = types.SimpleNamespace(**ns_dict)
if ns.huntrleaks:
unittest.BaseTestSuite._cleanup = False
setup_python(ns)
try:
result = runtest_ns(testname, ns.verbose, ns.quiet, ns,
result = runtest_ns(testname, ns.verbose, ns,
use_resources=ns.use_resources,
output_on_failure=ns.verbose3,
failfast=ns.failfast,

View File

@ -214,7 +214,6 @@ class ParseArgsTestCase(unittest.TestCase):
self.checkError([opt, 'foo'], 'invalid int value')
self.checkError([opt, '2', '-T'], "don't go together")
self.checkError([opt, '2', '-l'], "don't go together")
self.checkError([opt, '2', '-M', '4G'], "don't go together")
def test_coverage(self):
for opt in '-T', '--coverage':