diff options
| -rw-r--r-- | mesonbuild/mdevenv.py | 11 | ||||
| -rw-r--r-- | unittests/allplatformstests.py | 4 |
2 files changed, 13 insertions, 2 deletions
diff --git a/mesonbuild/mdevenv.py b/mesonbuild/mdevenv.py index 4962d96c6..e9974fe86 100644 --- a/mesonbuild/mdevenv.py +++ b/mesonbuild/mdevenv.py @@ -4,6 +4,7 @@ import os, subprocess import argparse import tempfile import shutil +import sys import itertools import typing as T @@ -226,8 +227,14 @@ def run(options: argparse.Namespace) -> int: args[0] = abs_path or args[0] try: - os.chdir(workdir) - os.execvpe(args[0], args, env=devenv) + if is_windows(): + # execvpe doesn't return exit code on Windows + # see https://github.com/python/cpython/issues/63323 + result = subprocess.run(args, env=devenv, cwd=workdir) + sys.exit(result.returncode) + else: + os.chdir(workdir) + os.execvpe(args[0], args, env=devenv) except FileNotFoundError: raise MesonException(f'Command not found: {args[0]}') except OSError as e: diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 0618b20ee..b983f341c 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -4453,6 +4453,10 @@ class AllPlatformTests(BasePlatformTests): self.assertIn(f'TEST_C="{expected}"', o) self.assertIn('export TEST_C', o) + cmd = self.meson_command + ['devenv', '-C', self.builddir] + python_command + ['-c', 'import sys; sys.exit(42)'] + result = subprocess.run(cmd, encoding='utf-8') + self.assertEqual(result.returncode, 42) + def test_clang_format_check(self): if self.backend is not Backend.ninja: raise SkipTest(f'Skipping clang-format tests with {self.backend.name} backend') |
