Skip to content

Windows: re-enable shell-subprocess tests via Git Bash on PATH #79

Closed

Description

@fdaviddpt

Context

In #78 we marked several test modules skipif(win32) to get the new 3-OS CI matrix green:

  • tests/test_log_sh.py — bash dispatch + ownership checks
  • tests/test_migration.py — bash bootstrap-dirs.sh
  • tests/test_security_fixes.py — RCE prevention in safe_eval, path-with-space cleanup, _jq_fallback quoting
  • tests/test_path_resolution.py — POSIX path layouts + bash subprocess capture

Three of these (test_log_sh, test_migration, test_security_fixes) test logic that does run on Windows when Claude Code invokes hooks via Git Bash. Skipping them means we ship no Windows security/regression coverage for those code paths.

Root cause of the skip

The GitHub Actions Windows runner's bash on PATH resolves to the WSL launcher (C:\Windows\System32\bash.exe), not Git Bash. WSL isn't installed on the runner, so every subprocess.run(["bash", "-c", script], ...) emits a UTF-16-encoded "no distributions installed" error and returns exit 1. The tests see garbage output and fail.

Proposed fix

In .github/workflows/tests.yml, on the Windows row, prepend Git Bash to PATH so subprocess.run(["bash", ...]) resolves to C:\Program Files\Git\bin\bash.exe:

- name: Use Git Bash on Windows
  if: runner.os == 'Windows'
  shell: pwsh
  run: echo "C:\Program Files\Git\bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8

Then revert the pytestmark = pytest.mark.skipif(sys.platform == "win32", ...) blocks added in #78 on:

  • tests/test_log_sh.py
  • tests/test_migration.py
  • tests/test_security_fixes.py

Leave test_umask.py skipped — POSIX mode bits genuinely can't exist on NTFS. Possibly test_path_resolution.py too — /c/Users vs C:\Users path-form assumptions may need targeted per-test fixes.

Out of scope

  • Per-test debugging once Git Bash runs — may surface real Windows bugs in the scripts that need actual fixes (path normalization, line endings, etc.).
  • test_umask.py — NTFS lacks Unix permission bits, not a CI configuration problem.

Test plan

  • Workflow PATH shim added.
  • Skip marks removed from the 3 files above.
  • Each file passes on windows-latest × 3.9/3.10/3.11/3.12.
  • If any individual test surfaces a real Windows bug, file a targeted follow-up rather than re-skipping the whole module.

Activity

  1. added
    bug
    on May 25, 2026
  2. fdaviddpt commented on Jun 19, 2026

    @fdaviddpt
    ContributorAuthor

    Resolved in #105 (merged) — all three modules now run green on windows-latest × 3.9–3.12.

    Three layers, two of them deeper than the original PATH-shim plan anticipated:

    1. Git Bash by explicit path, not PATH. The proposed GITHUB_PATH shim can't work: Windows CreateProcess searches System32 before PATH, so subprocess.run(["bash", …]) always resolves to System32\bash.exe (the WSL launcher) regardless of PATH order. Tests now invoke bash via the explicit Git-for-Windows path (_find_bash(), mirroring test_hooks_json._find_git_bash).
    2. Forward-slash drive paths. Paths injected into the bash scripts are normalized to C:/x (not MSYS /c/x) — forward-slash drive form is accepted by both Git Bash and the Windows python3 the scripts shell out to (jq fallback, migration's Path() round-trip), where /c/x is not.
    3. A real bug the tests caught — lib-memory-dir.sh only treated /…/~… as absolute when resolving REMEMBER_DIR from a data_dir, so a Windows drive-path data_dir (C:/…/{slug}) was wrongly treated as relative and prepended to PROJECT_DIR (path doubling + {slug} never substituted). Fixed to recognize C:/… and C:\…. This affected real Windows users on external mode, not just the tests — exactly why re-enabling them was worth it.

    TestDispatchOwnershipChecks stays skipif(win32): POSIX ownership + world-writable (0o777) semantics genuinely don't map to NTFS (Git Bash fakes mode bits), so the dispatch() guard is a no-op there — a real platform limitation, not a CI gap.

  3. added a commit that references this issue on Jun 19, 2026
  4. added a commit that references this issue on Sep 25, 2026
  5. added 4 commits that reference this issue on Oct 6, 2026
  6. added 3 commits that reference this issue on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions