The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(cli): trim npm mount-path coverage to two invariants
teknium1af0953985faf
diff --git a/tests/hermes_cli/test_node_runtime_npm_resolution.py b/tests/hermes_cli/test_node_runtime_npm_resolution.pyindex e2532701eb9..80d6eaf97e1 100644--- a/tests/hermes_cli/test_node_runtime_npm_resolution.py+++ b/tests/hermes_cli/test_node_runtime_npm_resolution.py@@ -1,50 +1,34 @@-"""Regression coverage for POSIX npm path classification."""+"""POSIX npm path classification: only Windows shims are refused (#112041, #30271)."""from __future__ import annotations+import osfrom unittest.mock import patch-from hermes_cli.main_install_repair import (- _is_windows_npm_path,- _resolve_node_runtime_npm,-)+from hermes_cli.main_install_repair import _is_windows_npm_path, _resolve_node_runtime_npm-def test_windows_npm_path_classifies_only_windows_drive_mounts():- assert _is_windows_npm_path("/mnt/c/nodejs/npm")- assert not _is_windows_npm_path("/mnt/data/node/bin/npm")+def test_windows_npm_path_refuses_windows_shims_but_not_native_data_mounts():+ """A ``/mnt/<drive>`` WSL interop path or a ``.cmd`` shim is Windows npm; a native Linux+ data mount such as ``/mnt/data`` is not — a folder prefix alone is not a Windows tell."""+ assert _is_windows_npm_path("/mnt/c/Program Files/nodejs/npm")+ assert _is_windows_npm_path("/mnt/d/nodejs/npm")+ assert _is_windows_npm_path("C:\\nodejs\\npm.cmd")+ assert not _is_windows_npm_path("/mnt/data/hermes/home/.local/bin/npm")+ assert not _is_windows_npm_path("/usr/bin/npm")-def test_resolve_node_runtime_npm_accepts_native_mnt_data_path():+def test_resolve_node_runtime_npm_rescans_past_windows_drive_to_native_mount(monkeypatch):+ """When PATH interop hands back a Windows npm first, the re-scan skips the Windows drive+ mount but still accepts a native npm living under ``/mnt/data``."""native_npm = "/mnt/data/node/bin/npm"- with (- patch("hermes_cli.main._is_windows", return_value=False),- patch("hermes_constants.find_node_executable", return_value=native_npm),- ):- assert _resolve_node_runtime_npm() == native_npm-+ monkeypatch.setenv("PATH", os.pathsep.join(["/mnt/c/Program Files/nodejs", "/mnt/data/node/bin"]))-def test_resolve_node_runtime_npm_rejects_windows_drive_mount(monkeypatch):- monkeypatch.setenv("PATH", "/mnt/c/Program Files/nodejs")- with (- patch("hermes_cli.main._is_windows", return_value=False),- patch(- "hermes_constants.find_node_executable",- return_value="/mnt/c/nodejs/npm",- ),- ):- assert _resolve_node_runtime_npm() is None+ def fake_which(cmd, path=None):+ return native_npm if path == "/mnt/data/node/bin" else None--def test_resolve_node_runtime_npm_rescans_native_mnt_data_path(monkeypatch):- native_npm = "/mnt/data/node/bin/npm"- monkeypatch.setenv("PATH", "/mnt/data/node/bin")with (- patch("hermes_cli.main._is_windows", return_value=False),- patch(- "hermes_constants.find_node_executable",- return_value="/mnt/c/nodejs/npm",- ),- patch("hermes_cli.main_install_repair.shutil.which", return_value=native_npm),+ patch("hermes_constants.find_node_executable", return_value="/mnt/c/Program Files/nodejs/npm"),+ patch("hermes_cli.main_install_repair.shutil.which", side_effect=fake_which),):assert _resolve_node_runtime_npm() == native_npm