Skip to content

Commit 25b6aff

Browse files
committed
test: use runtime bash check instead of platform check
Replace sys.platform == 'win32' with an actual bash invocation test to handle environments where bash exists but is non-functional (e.g., WSL stub on Windows without an installed distro).
1 parent daf6986 commit 25b6aff

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

tests/conftest.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
"""Shared test helpers for the Spec Kit test suite."""
22

33
import re
4-
import sys
4+
import shutil
5+
import subprocess
56

67
import pytest
78

89
_ANSI_ESCAPE_RE = re.compile(r"\x1b\[[0-?]*[ -/]*[@-~]")
910

11+
12+
def _has_working_bash() -> bool:
13+
"""Check whether a functional bash is available (not just a WSL stub)."""
14+
if shutil.which("bash") is None:
15+
return False
16+
try:
17+
r = subprocess.run(
18+
["bash", "-c", "echo ok"],
19+
capture_output=True, text=True, timeout=5,
20+
)
21+
return r.returncode == 0 and "ok" in r.stdout
22+
except (OSError, subprocess.TimeoutExpired):
23+
return False
24+
25+
1026
requires_bash = pytest.mark.skipif(
11-
sys.platform == "win32", reason="bash not available on Windows"
27+
not _has_working_bash(), reason="working bash not available"
1228
)
1329

1430

0 commit comments

Comments
 (0)