Skip to content

Commit 0974f03

Browse files
committed
ENH: raise SystemExit when calling meson fails
Fixes #228.
1 parent 21e9288 commit 0974f03

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
@@ -680,7 +680,9 @@ def _get_config_key(self, key: str) -> Any:
680680
def _proc(self, *args: str) -> None:
681681
"""Invoke a subprocess."""
682682
print('{cyan}{bold}+ {}{reset}'.format(' '.join(args), **_STYLES))
683-
subprocess.check_call(list(args), env=self._env)
683+
r = subprocess.run(list(args), env=self._env)
684+
if r.returncode != 0:
685+
raise SystemExit(r.returncode)
684686

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

tests/test_pep517.py

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

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

3839
monkeypatch.setattr(shutil, 'which', which)
3940
monkeypatch.setattr(subprocess, 'run', run)

0 commit comments

Comments
 (0)