Skip to content

Commit b83873e

Browse files
committed
fix(tests): use shutil.which for bash discovery, add ps parity tests
- _find_bash() now tries shutil.which('bash') first so non-standard install locations (Nix, custom CI images) are found - Parametrize parity test over both 'sh' and 'ps' script types to ensure PowerShell variant stays byte-for-byte identical to release script output (353 scaffold tests, 810 total)
1 parent 00756ab commit b83873e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

tests/test_core_pack_scaffold.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
import os
3333
import re
34+
import shutil
3435
import subprocess
3536
import zipfile
3637
from pathlib import Path
@@ -51,6 +52,10 @@
5152

5253
def _find_bash() -> str | None:
5354
"""Return the path to a usable bash on this machine, or None."""
55+
# Prefer PATH lookup so non-standard install locations (Nix, CI) are found.
56+
on_path = shutil.which("bash")
57+
if on_path:
58+
return on_path
5459
candidates = [
5560
"/opt/homebrew/bin/bash",
5661
"/usr/local/bin/bash",
@@ -487,10 +492,11 @@ def test_scaffold_powershell_variant(agent, scaffolded_ps, source_template_stems
487492
# 8. Parity: bundled vs. real create-release-packages.sh ZIP
488493
# ---------------------------------------------------------------------------
489494

495+
@pytest.mark.parametrize("script_type", ["sh", "ps"])
490496
@pytest.mark.parametrize("agent", _TESTABLE_AGENTS)
491-
def test_parity_bundled_vs_release_script(tmp_path, agent):
497+
def test_parity_bundled_vs_release_script(tmp_path, agent, script_type):
492498
"""scaffold_from_core_pack() file tree is identical to the ZIP produced by
493-
create-release-packages.sh for every agent (sh variant).
499+
create-release-packages.sh for every agent and script type.
494500
495501
This is the true end-to-end parity check: the Python offline path must
496502
produce exactly the same artifacts as the canonical shell release script.
@@ -506,15 +512,15 @@ def test_parity_bundled_vs_release_script(tmp_path, agent):
506512
# --- Release script path ---
507513
gen_dir = tmp_path / "genreleases"
508514
gen_dir.mkdir()
509-
zip_path = _run_release_script(agent, "sh", bash, gen_dir)
515+
zip_path = _run_release_script(agent, script_type, bash, gen_dir)
510516
script_dir = tmp_path / "extracted"
511517
script_dir.mkdir()
512518
with zipfile.ZipFile(zip_path) as zf:
513519
zf.extractall(script_dir)
514520

515521
# --- Bundled path ---
516522
bundled_dir = tmp_path / "bundled"
517-
ok = scaffold_from_core_pack(bundled_dir, agent, "sh")
523+
ok = scaffold_from_core_pack(bundled_dir, agent, script_type)
518524
assert ok
519525

520526
bundled_tree = _collect_relative_files(bundled_dir)
@@ -524,17 +530,17 @@ def test_parity_bundled_vs_release_script(tmp_path, agent):
524530
only_script = set(script_tree) - set(bundled_tree)
525531

526532
assert not only_bundled, (
527-
f"Agent '{agent}': files only in bundled output (not in release ZIP):\n "
533+
f"Agent '{agent}' ({script_type}): files only in bundled output (not in release ZIP):\n "
528534
+ "\n ".join(sorted(only_bundled))
529535
)
530536
assert not only_script, (
531-
f"Agent '{agent}': files only in release ZIP (not in bundled output):\n "
537+
f"Agent '{agent}' ({script_type}): files only in release ZIP (not in bundled output):\n "
532538
+ "\n ".join(sorted(only_script))
533539
)
534540

535541
for name in bundled_tree:
536542
assert bundled_tree[name] == script_tree[name], (
537-
f"Agent '{agent}': file '{name}' content differs between "
543+
f"Agent '{agent}' ({script_type}): file '{name}' content differs between "
538544
f"bundled output and release script ZIP"
539545
)
540546

0 commit comments

Comments
 (0)