Commit 4da04314 authored by Kirill Smelkov's avatar Kirill Smelkov

gpython: tests: Factorize test_Xruntime

Factor-out subroutine to run tfunc in subprocess interpreter spawned with
`-X xopt=xval`. This helps clarity and later in addition to `-X
gpython.runtime` we will also need it to verify `-X gpython.strings`.

/proposed-for-review-on nexedi/pygolang!25
parent 1e6c876f
......@@ -355,20 +355,26 @@ def test_pymain_run_via_relpath():
out2 = pyout(['./__init__.py'] + argv, pyexe=sys._gpy_underlying_executable, cwd=here)
assert out1 == out2
# verify -X gpython.runtime=...
@gpython_only
def test_Xruntime(runtime):
_xopt_assert_in_subprocess('gpython.runtime', runtime,
assert_gevent_activated if runtime != 'threads' else \
assert_gevent_not_activated)
# _xopt_assert_in_subprocess runs tfunc in subprocess interpreter spawned with
# `-X xopt=xval` and checks that there is no error.
def _xopt_assert_in_subprocess(xopt, xval, tfunc):
XOPT = xopt.upper().replace('.','_') # gpython.runtime -> GPYTHON_RUNTIME
env = os.environ.copy()
env.pop('GPYTHON_RUNTIME', None) # del
env.pop(XOPT, None) # del
argv = []
if runtime != '':
argv += ['-X', 'gpython.runtime='+runtime]
if xval != '':
argv += ['-X', xopt+'='+xval]
prog = 'from gpython import gpython_test as t; '
if runtime != 'threads':
prog += 't.assert_gevent_activated(); '
else:
prog += 't.assert_gevent_not_activated(); '
prog += 't.%s(); ' % tfunc.__name__
prog += 'print("ok")'
argv += ['-c', prog]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment