8000 test_judge: 3 end-to-end tests fail on Windows (sh not on PATH; fixture paths lose backslashes in sh -c) · Issue #300 · ayghri/i-have-adhd · GitHub
[go: up one dir, main page]

Skip to content

test_judge: 3 end-to-end tests fail on Windows (sh not on PATH; fixture paths lose backslashes in sh -c) #300

Backlog

Description

@Teaz7

Summary

Three end-to-end tests in tests/test_judge.py fail on Windows. Their stub judge runners are sh -c "..." commands, and that breaks in two ways depending on the shell:

  1. PowerShell (no sh on PATH): the tests crash with FileNotFoundError: [WinError 2] because sh doesn't exist. Other test files already guard against this (test_opencode_plugin.py uses skipUnless(shutil.which("node")), test_always_on_hooks.py only runs runtimes it finds), but test_judge.py doesn't.
  2. Git Bash (sh available): the fixture paths are interpolated unquoted into the sh -c string, so sh treats the backslashes in C:\Users\... as escapes. cat receives C:Users...verdict.json and fails.

This is a test-fixture bug, not a bug in scripts/judge.py. It's never been caught because CI only runs tests.test_always_on_hooks on windows-latest (.github/workflows/plugin-load-check.yml); test_judge runs on Linux only.

Environment

  • Windows 11, Python 3.14.3
  • Case 1: Windows PowerShell, no sh on PATH
  • Case 2: Git for Windows bash 5.2.26 (x86_64-pc-msys)
  • main at f3e783b

Reproduction

python -m unittest tests.test_judge

Case 1, PowerShell:

ERROR: test_a_malformed_verdict_skips_its_group_instead_of_killing_the_run (tests.test_judge.EndToEndTest...)
ERROR: test_judging_produces_paired_rows_the_scorer_accepts (tests.test_judge.EndToEndTest...)
ERROR: test_runner_failure_skips_its_group_and_continues (tests.test_judge.EndToEndTest...)
  File "...\scripts\judge.py", line 184, in invoke_judge
    completed = subprocess.run(
FileNotFoundError: [WinError 2] The system cannot find the file specified

Ran 17 tests in 0.186s
FAILED (errors=3)

Case 2, Git Bash:

cat: 'C:UsersHPAppDataLocalTemptmp4p9mf55ggood.json': No such file or directory
cat: 'C:UsersHPAppDataLocalTemptmpnk2er58qverdict.json': No such file or directory
cat: 'C:UsersHPAppDataLocalTemptmpieep6fceverdict.json': No such file or directory
FAIL: test_a_malformed_verdict_skips_its_group_instead_of_killing_the_run (tests.test_judge.EndToEndTest...)
FAIL: test_judging_produces_paired_rows_the_scorer_accepts (tests.test_judge.EndToEndTest...)
FAIL: test_runner_failure_skips_its_group_and_continues (tests.test_judge.EndToEndTest...)
FAILED (failures=3)

Cause

The affected fixtures (around lines 226, 294 and 390 of tests/test_judge.py):

"command": ["sh", "-c", f"cat > {captured}; cat {payload}"],
...
f" *) cat {good};; esac",
...
f'p=$(cat); case "$p" in *direct-answer*) exit 7;; *) cat {verdict};; esac',

Each requires sh, and each {path} is an unquoted pathlib.Path.

Proposed fix

Both changes go in tests/test_judge.py only:

  1. Skip the stub-runner tests when sh is unavailable, matching the existing pattern:
    @unittest.skipUnless(shutil.which("sh"), "sh is required for the stub judge runner")
  2. Pass paths as positional arguments so the shell never parses them:
    "command": ["sh", "-c", 'cat > "$1"; cat "$2"', "sh", str(captured), str(payload)],

Minimal check of (2) under Git Bash on the same machine:

sh -c f"cat {p}"              -> cat: 'C:UsersHPAppDataLocalTemp...verdict.json': No such file or directory
sh -c 'cat "$1"' sh str(p)    -> {}   (file contents, as expected)

scripts/judge.py runs the command list as given and sends the prompt on stdin, so the extra arguments don't interfere. Behavior on Linux/macOS stays the same. I'm happy to open the PR.

Out of scope: running the full unittest suite on windows-latest in CI would have caught this, but that's a separate workflow change.


Provenance: drafted with Claude Code (Claude Opus 5.5) and reviewed by me. I ran the PowerShell reproduction myself; the Git Bash reproduction and the minimal check were run by the agent on the same machine.

Activity

  1. Teaz7 commented on Nov 30, 2026

    @Teaz7
    Author

    I missed #287 when filing this. It fixes both halves: it runs the stub runners with sys.executable, so the three tests actually run on Windows without sh instead of skipping. #287 should close this issue.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0