Skip to content

Commit df47808

Browse files
committed
tests: 3 more Windows fixes — pnpm ignore-scripts, security_controls brew, uv tool shim
- test_pnpmprovider.py::test_install_args_win_for_ignore_scripts_and_min_release_age: same pattern as npm/bun — Windows .cmd wrappers return 0 for the --ignore-scripts postinstall-missing case but emit the is not recognized error to stderr. Accept either signal. - test_security_controls.py::test_nullable_provider_security_fields_resolve_before_handlers_run: skip the BrewProvider leg on Windows (brew is in UNIX_ONLY_PROVIDER_NAMES there and its INSTALLER_BINARY lookup raises BinProviderUnavailableError on hosts without brew, which is unrelated to what this security-field test is verifying). - test_uvprovider.py::test_global_tool_mode_can_load_and_uninstall_without_bin_shim: hardcoded tool_bin_dir / 'cowsay' misses the Windows cowsay.exe shim. Resolve via bin_abspath which honors PATHEXT so both POSIX and Windows layouts match.
1 parent 7354500 commit df47808

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

tests/test_pnpmprovider.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ def test_install_args_win_for_ignore_scripts_and_min_release_age(self):
3636
assert installed.loaded_abspath.exists()
3737
# The wrapper exists but the postinstall download was skipped via
3838
# explicit --ignore-scripts, so the vendored binary is missing.
39+
# POSIX shells propagate the failing vendor binary's exit code;
40+
# Windows ``.cmd`` wrappers return 0 but emit the ``is not
41+
# recognized`` error to stderr — accept either as proof the
42+
# postinstall was skipped.
3943
proc = installed.exec(cmd=("--version",), quiet=True)
40-
assert proc.returncode != 0
44+
assert proc.returncode != 0 or "not recognized" in (proc.stderr or "")
4145
# The provider's strict 100-year min_release_age was overridden
4246
# by the explicit --config.minimumReleaseAge=0 in install_args,
4347
# so the resolver was able to pick a real version.

tests/test_security_controls.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
SemVer,
1515
)
1616
from abxpkg.exceptions import BinaryInstallError, BinaryLoadError
17+
from abxpkg.windows_compat import IS_WINDOWS
1718

1819

1920
class TestSecurityControls:
@@ -147,10 +148,15 @@ def test_nullable_provider_security_fields_resolve_before_handlers_run(self):
147148
).install("zx", no_cache=True)
148149
is not None
149150
)
150-
assert (
151-
BrewProvider(
152-
dry_run=True,
153-
postinstall_scripts=None,
154-
).install("node", no_cache=True)
155-
is not None
156-
)
151+
# Brew is in UNIX_ONLY_PROVIDER_NAMES on Windows — its
152+
# ``INSTALLER_BINARY`` lookup raises
153+
# ``BinProviderUnavailableError`` on hosts without ``brew``,
154+
# which is exactly what this test is not verifying.
155+
if not IS_WINDOWS:
156+
assert (
157+
BrewProvider(
158+
dry_run=True,
159+
postinstall_scripts=None,
160+
).install("node", no_cache=True)
161+
is not None
162+
)

tests/test_uvprovider.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,13 @@ def test_global_tool_mode_can_load_and_uninstall_without_bin_shim(
571571
assert_version_command=False,
572572
)
573573
assert installed is not None
574-
shim_path = tool_bin_dir / "cowsay"
575-
assert shim_path.exists()
574+
# POSIX writes ``bin_dir/cowsay`` while Windows writes
575+
# ``bin_dir/cowsay.exe`` — resolve the actual shim via
576+
# ``bin_abspath`` (PATHEXT-aware) so both layouts match.
577+
from abxpkg.base_types import bin_abspath as _ba
578+
579+
shim_path = _ba("cowsay", PATH=str(tool_bin_dir))
580+
assert shim_path is not None and shim_path.exists()
576581
shim_path.unlink()
577582

578583
reloaded = provider.load("cowsay", quiet=True, no_cache=True)

0 commit comments

Comments
 (0)