diff options
-rwxr-xr-x | run_tests.py | 3 | ||||
-rwxr-xr-x | run_unittests.py | 20 |
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', |