Skip to content

Commit a74ea01

Browse files
committed
ENH: raise SystemExit when calling meson fails
Fixes mesonbuild#228.
1 parent 47363b5 commit a74ea01

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

mesonpy/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,9 @@ def _get_config_key(self, key: str) -> Any:
649649
def _proc(self, *args: str) -> None:
650650
"""Invoke a subprocess."""
651651
print('{cyan}{bold}+ {}{reset}'.format(' '.join(args), **_STYLES))
652-
subprocess.check_call(list(args), env=self._env)
652+
r = subprocess.run(list(args), env=self._env)
653+
if r.returncode != 0:
654+
raise SystemExit(r.returncode)
653655

654656
def _meson(self, *args: str) -> None:
655657
"""Invoke Meson."""

tests/test_pep517.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ def which(prog: str) -> bool:
2727
# smoke check for the future if we add another usage
2828
raise AssertionError(f'Called with {prog}, tests not expecting that usage')
2929

30+
subprocess_run = subprocess.run
31+
3032
def run(cmd: List[str], *args: object, **kwargs: object) -> subprocess.CompletedProcess:
31-
if cmd != ['ninja', '--version']:
32-
# smoke check for the future if we add another usage
33-
raise AssertionError(f'Called with {cmd}, tests not expecting that usage')
34-
return subprocess.CompletedProcess(cmd, 0, f'{ninja}\n', '')
33+
if cmd == ['ninja', '--version']:
34+
return subprocess.CompletedProcess(cmd, 0, f'{ninja}\n', '')
35+
return subprocess_run(cmd, *args, **kwargs)
3536

3637
monkeypatch.setattr(shutil, 'which', which)
3738
monkeypatch.setattr(subprocess, 'run', run)

0 commit comments

Comments
 (0)