Skip to content

Commit

Permalink
ENH: raise SystemExit when calling meson fails
Browse files Browse the repository at this point in the history
Fixes #228.
  • Loading branch information
dnicolodi committed Nov 24, 2022
1 parent 47363b5 commit a74ea01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,9 @@ def _get_config_key(self, key: str) -> Any:
def _proc(self, *args: str) -> None:
"""Invoke a subprocess."""
print('{cyan}{bold}+ {}{reset}'.format(' '.join(args), **_STYLES))
subprocess.check_call(list(args), env=self._env)
r = subprocess.run(list(args), env=self._env)
if r.returncode != 0:
raise SystemExit(r.returncode)

def _meson(self, *args: str) -> None:
"""Invoke Meson."""
Expand Down
9 changes: 5 additions & 4 deletions tests/test_pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ def which(prog: str) -> bool:
# smoke check for the future if we add another usage
raise AssertionError(f'Called with {prog}, tests not expecting that usage')

subprocess_run = subprocess.run

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

monkeypatch.setattr(shutil, 'which', which)
monkeypatch.setattr(subprocess, 'run', run)
Expand Down

0 comments on commit a74ea01

Please sign in to comment.