Set unittest backend with an argument rather than an envvar.

pull/8750/head
Jussi Pakkanen 4 years ago
parent 247630b981
commit 1d06d4ca1a
  1. 3
      run_tests.py
  2. 20
      run_unittests.py

@ -346,7 +346,6 @@ def main():
# Run tests
# Can't pass arguments to unit tests, so set the backend to use in the environment
env = os.environ.copy()
env['MESON_UNIT_TEST_BACKEND'] = backend.name
with tempfile.TemporaryDirectory() as temp_dir:
# Enable coverage on all subsequent processes.
if enable_coverage:
@ -372,7 +371,7 @@ def main():
else:
print(mlog.bold('Running unittests.'))
print(flush=True)
cmd = mesonlib.python_command + ['run_unittests.py', '-v']
cmd = mesonlib.python_command + ['run_unittests.py', '--backend=' + backend.name, '-v']
if options.failfast:
cmd += ['--failfast']
returncode += subprocess.call(cmd, env=env)

@ -82,7 +82,6 @@ from run_tests import (
if T.TYPE_CHECKING:
from mesonbuild.compilers import Compiler
URLOPEN_TIMEOUT = 5
@contextmanager
@ -1704,8 +1703,7 @@ class BasePlatformTests(unittest.TestCase):
src_root = os.path.join(os.getcwd(), src_root)
self.src_root = src_root
# Get the backend
# FIXME: Extract this from argv?
self.backend = getattr(Backend, os.environ.get('MESON_UNIT_TEST_BACKEND', 'ninja'))
self.backend = getattr(Backend, os.environ['MESON_UNIT_TEST_BACKEND'])
self.meson_args = ['--backend=' + self.backend.name]
self.meson_native_file = None
self.meson_cross_file = None
@ -10010,8 +10008,24 @@ def running_single_tests(argv, cases):
got_test_arg = True
return got_test_arg
def setup_backend():
filtered = []
be = 'ninja'
for a in sys.argv:
if a.startswith('--backend'):
be = a.split('=')[1]
else:
filtered.append(a)
# Since we invoke the tests via unittest or xtest test runner
# we need to pass the backend to use to the spawned process via
# this side channel. Yes it sucks, but at least is is fully
# internal to this file.
os.environ['MESON_UNIT_TEST_BACKEND'] = be
sys.argv = filtered
def main():
unset_envs()
setup_backend()
cases = ['InternalTests', 'DataTests', 'AllPlatformTests', 'FailureTests',
'PythonTests', 'NativeFileTests', 'RewriterTests', 'CrossFileTests',
'TAPParserTests', 'SubprojectsCommandTests',

Loading…
Cancel
Save