aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2021-05-08 01:56:58 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2021-05-08 01:56:58 +0300
commit0793bae06ff30c80871cb3f8a85211190f79802f (patch)
tree5c602fbb93e7504862271345d54139fd3c956f54
parentd433abf89cfe6be640d7a913bfdd4ae723f8b573 (diff)
downloadmeson-unittestarg.zip
meson-unittestarg.tar.gz
meson-unittestarg.tar.bz2
Set unittest backend with an argument rather than an envvar.unittestarg
-rwxr-xr-xrun_tests.py3
-rwxr-xr-xrun_unittests.py20
2 files changed, 18 insertions, 5 deletions
diff --git a/run_tests.py b/run_tests.py
index b2a25f0..1d755a8 100755
--- a/run_tests.py
+++ b/run_tests.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)
diff --git a/run_unittests.py b/run_unittests.py
index 1556b10..89b00f6 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -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',