Skip to content

bpo-34605, libregrtest: Avoid master/slave terms #9099

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

Merged
merged 1 commit into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Lib/test/libregrtest/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _create_parser():
group.add_argument('--wait', action='store_true',
help='wait for user input, e.g., allow a debugger '
'to be attached')
group.add_argument('--slaveargs', metavar='ARGS')
group.add_argument('--worker-args', metavar='ARGS')
group.add_argument('-S', '--start', metavar='START',
help='the name of the test at which to start.' +
more_details)
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/libregrtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,9 @@ def _main(self, tests, kwargs):
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)
if self.ns.worker_args is not None:
from test.libregrtest.runtest_mp import run_tests_worker
run_tests_worker(self.ns.worker_args)

if self.ns.wait:
input("Press any key to continue...")
Expand Down
14 changes: 7 additions & 7 deletions Lib/test/libregrtest/runtest_mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@


def run_test_in_subprocess(testname, ns):
"""Run the given test in a subprocess with --slaveargs.
"""Run the given test in a subprocess with --worker-args.

ns is the option Namespace parsed from command-line arguments. regrtest
is invoked in a subprocess with the --slaveargs argument; when the
is invoked in a subprocess with the --worker-args argument; when the
subprocess exits, its return code, stdout and stderr are returned as a
3-tuple.
"""
from subprocess import Popen, PIPE

ns_dict = vars(ns)
slaveargs = (ns_dict, testname)
slaveargs = json.dumps(slaveargs)
worker_args = (ns_dict, testname)
worker_args = json.dumps(worker_args)

cmd = [sys.executable, *support.args_from_interpreter_flags(),
'-u', # Unbuffered stdout and stderr
'-m', 'test.regrtest',
'--slaveargs', slaveargs]
'--worker-args', worker_args]
if ns.pgo:
cmd += ['--pgo']

Expand All @@ -58,8 +58,8 @@ def run_test_in_subprocess(testname, ns):
return retcode, stdout, stderr


def run_tests_slave(slaveargs):
ns_dict, testname = json.loads(slaveargs)
def run_tests_worker(worker_args):
ns_dict, testname = json.loads(worker_args)
ns = types.SimpleNamespace(**ns_dict)

setup_tests(ns)
Expand Down
8 changes: 4 additions & 4 deletions Lib/test/test_regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ def test_wait(self):
ns = libregrtest._parse_args(['--wait'])
self.assertTrue(ns.wait)

def test_slaveargs(self):
ns = libregrtest._parse_args(['--slaveargs', '[[], {}]'])
self.assertEqual(ns.slaveargs, '[[], {}]')
self.checkError(['--slaveargs'], 'expected one argument')
def test_worker_args(self):
ns = libregrtest._parse_args(['--worker-args', '[[], {}]'])
self.assertEqual(ns.worker_args, '[[], {}]')
self.checkError(['--worker-args'], 'expected one argument')

def test_start(self):
for opt in '-S', '--start':
Expand Down