Skip to content

fix(windows): native Windows correctness fixes + green CLI test suite - #823

Open
hashbender wants to merge 1 commit into
mainfrom
mirror/pr-57016
Open

fix(windows): native Windows correctness fixes + green CLI test suite#823
hashbender wants to merge 1 commit into
mainfrom
mirror/pr-57016

Conversation

@hashbender

Copy link
Copy Markdown
Owner

What does this PR do?

Running the test suite natively on Windows (not WSL) surfaced 16 failures across tests/cli, tests/gateway, and tests/tools. Triaging them found 4 real product bugs plus a handful of POSIX assumptions in the tests themselves. With this PR, pytest tests/cli tests/gateway/test_status.py tests/tools/test_windows_native_support.py tests/test_windows_subprocess_no_window_flags.py is fully green on native Windows (1180 passed, 5 legitimately skipped) and stays green on POSIX.

Product fixes

  1. Gateway profile liveness mis-match on mixed path separators (gateway/status.py, hermes_cli/gateway.py): _command_line_belongs_to_profile compared str(Path) (backslashes on Windows) against HERMES_HOME= argv values that may carry forward slashes (wmic/CIM output, Git Bash, JSON configs) — a live named-profile gateway could be reported not-running by the dashboard's cross-profile check. Both sides now normalize to forward slashes.
  2. cprint crashes when stdout has no console (hermes_cli/banner.py): prompt_toolkit's Win32Output raises NoConsoleScreenBufferError under pythonw.exe, CI, or redirected stdout. A display helper should never crash its caller — it now degrades to plain print, matching the fallback cli._cprint already has.
  3. file:///C:/... drops don't resolve (cli.py): urlparse keeps the leading slash (/C:/...); it is now stripped for drive-letter paths so dragging a file into the CLI works on Windows.
  4. POSIX-literal paths joined with os.path.join (cli.py termux hint, hermes_cli/browser_connect.py WSL chrome candidates): produced /sdcard\Pictures\cat.png on native Windows. Joined with literal forward slashes / posixpath.join.

Test-suite fixes

  • New tests/cli/conftest.py: 9 test modules build a CLI via importlib.reload(cli) with prompt_toolkit stubbed in sys.modules. reload() re-executes into the same module dict, so the MagicMock bindings (_pt_print, _PT_ANSI, ...) survive the patch.dict context and silently swallow _cprint output in any later test (this is what made test_resume_quiet_stderr order-dependent). An autouse module-scoped fixture restores the real bindings when the pollution is detected.
  • Symlink tests skip when the process lacks symlink privileges (WinError 1314 without Developer Mode), reusing the existing _can_symlink() convention from test_symlink_prefix_confusion.py.
  • Tilde-expansion tests set USERPROFILE alongside HOME (ntpath.expanduser ignores HOME since Python 3.8).
  • test_windows_native_support.py: two tests violated the file's own "every test mocks the platform" contract — the no-op test now mocks is_windows(), and the real-SIGKILL assertion is skipped on win32.
  • Cross-platform regression test for the mixed-separator profile match.

Related Issue

Follow-up to the native-Windows work in NousResearch#43933 and NousResearch#54565.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✅ Tests (adding or improving test coverage)

Changes Made

  • gateway/status.py, hermes_cli/gateway.py — separator-normalized profile matching
  • hermes_cli/banner.py — cprint console fallback
  • cli.py — file URI drive-letter fix, termux hint posix join
  • hermes_cli/browser_connect.py — posixpath.join for WSL candidates
  • tests/cli/conftest.py (new) — un-pollute cli module after stubbed reloads
  • tests/cli/*, tests/gateway/test_status.py, tests/tools/test_windows_native_support.py — Windows-safe tests + regression coverage

How to Test

  1. On native Windows: python -m pytest tests/cli tests/gateway/test_status.py tests/tools/test_windows_native_support.py tests/test_windows_subprocess_no_window_flags.py → previously 16 failures, now green (1180 passed, 5 skipped).
  2. On Linux/macOS: same command — no behavior change (the new conftest fixture is a no-op when no pollution occurred; product changes only affect Windows-only or WSL-literal code paths).
  3. python scripts/check-windows-footguns.py --all → clean.

🤖 Generated with Claude Code


Mirror-of: NousResearch#57016
NousResearch#57016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant