Skip to content

Commit 59d91e6

Browse files
committed
tests: better printout on failure
Signed-off-by: Henry Schreiner <[email protected]>
1 parent cdafa51 commit 59d91e6

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

test/utils.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@
3535
}.get(detect_ci_provider(), True)
3636

3737

38+
def _subprocess_run(command: list[str], **kwargs: Any) -> None:
39+
result = subprocess.run(
40+
command,
41+
capture_output=True,
42+
check=False,
43+
text=True,
44+
**kwargs,
45+
)
46+
if result.returncode != 0:
47+
msg = (
48+
f"Subprocess failed with exit code {result.returncode}\n"
49+
f"Command: {' '.join(command)}\n"
50+
f"--- stdout ---\n{result.stdout}\n"
51+
f"--- stderr ---\n{result.stderr}"
52+
)
53+
raise AssertionError(msg)
54+
55+
3856
def get_platform() -> str:
3957
"""Return the current platform as determined by CIBW_PLATFORM or sys.platform."""
4058
platform = os.environ.get("CIBW_PLATFORM", "")
@@ -137,7 +155,7 @@ def cibuildwheel_run(
137155
env["CIBW_BUILD"] = "cp{}{}-*".format(*SINGLE_PYTHON_VERSION)
138156

139157
with TemporaryDirectory() as tmp_output_dir:
140-
subprocess.run(
158+
_subprocess_run(
141159
[
142160
sys.executable,
143161
"-m",
@@ -149,7 +167,6 @@ def cibuildwheel_run(
149167
],
150168
env=env,
151169
cwd=project_path,
152-
check=True,
153170
)
154171
wheels = sorted(p.name for p in (output_dir or Path(tmp_output_dir)).iterdir())
155172
return wheels

0 commit comments

Comments
 (0)