Skip to content

Commit 2345ac4

Browse files
test: shadow jq so the broken-python3 fallback test actually exercises it
the test claimed it dropped jq so the parser chain would reach python3 and then grep/sed, but it only prepended the python3 stub dir to PATH. on a runner with jq installed, read_feature_json_feature_directory parses via jq and never reaches the fallback the test is meant to cover. add a failing jq stub alongside the python3 stub so the chain is forced through jq -> python3 -> grep/sed regardless of what the runner has installed.
1 parent a56d4aa commit 2345ac4

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎tests/test_setup_plan_feature_json.py‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,23 @@ def test_setup_plan_survives_broken_python3_stub(plan_repo: Path) -> None:
159159
)
160160
stub.chmod(0o755)
161161

162+
# A stub jq that shadows any real jq on PATH and also fails, so the parser
163+
# cannot short-circuit on jq and must reach the broken python3 stub and then
164+
# fall through to grep/sed. Without this, a runner that has jq installed
165+
# would parse feature.json via jq and never exercise the fallback this test
166+
# is meant to cover.
167+
jq_stub = stub_dir / "jq"
168+
jq_stub.write_text(
169+
"#!/bin/sh\n"
170+
'echo "jq: simulated failure" >&2\n'
171+
"exit 1\n",
172+
encoding="utf-8",
173+
)
174+
jq_stub.chmod(0o755)
175+
162176
env = _clean_env()
163-
# Prepend the stub dir; also drop jq so the chain must reach python3 then
164-
# fall through to grep/sed. PATH still needs the real bash utilities.
177+
# Prepend the stub dir so the failing jq and python3 stubs take precedence
178+
# over any real ones; PATH still needs the real bash utilities for grep/sed.
165179
env["PATH"] = f"{stub_dir}{os.pathsep}{env.get('PATH', '')}"
166180

167181
script = plan_repo / ".specify" / "scripts" / "bash" / "setup-plan.sh"

0 commit comments

Comments
 (0)