test: fix Windows-only CI failures across 8 unit tests#1752
Merged
Conversation
Eight unit tests passed on macOS/Linux but failed on windows-latest: - 5 POSIX-permission assertions (st_mode & 0o777 == 0o600) cannot hold on Windows, which does not honor POSIX file modes. Skip the permission-only revision-pin test on win32; guard just the mode assertion (keeping functional coverage) in the Kiro MCP/target tests. - 2 enterprise-bootstrap tests shell out to install.sh, whose OS guard rejects MINGW/Windows before the env-var fail-closed checks run. Skip them on win32 (install.sh is the Unix installer; install.ps1 has its own coverage). - test_self_update_uses_mirrors_without_public_hosts asserted an exact request list but the CLI-startup update notifier adds a cache-gated metadata fetch that fires on a cold Windows runner cache (absent on a warm Unix one), yielding a duplicate latest.json. Set APM_E2E_TESTS=1 to disable the notifier so the request list is deterministic. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a set of unit tests that were passing on macOS/Linux but failing on windows-latest, by making the assertions resilient to Windows-specific filesystem and environment behavior (file mode bits, Unix installer behavior, and a cache-gated startup notifier).
Changes:
- Guard POSIX permission-bit assertions (
st_mode & 0o777 == 0o600) so they don’t fail on Windows. - Skip Unix-installer execution tests on Windows where
install.shOS guards prevent reaching the expected fail-closed branches. - Make
self-updaterequest assertions deterministic across platforms by settingAPM_E2E_TESTS=1to disable the CLI-startup update notifier side effect.
Show a summary per file
| File | Description |
|---|---|
tests/unit/test_kiro_mcp.py |
Skips file-mode assertions on Windows while keeping JSON content assertions. |
tests/unit/test_enterprise_bootstrap_installers.py |
Skips install.sh execution-based tests on Windows where the script’s OS guard short-circuits expected assertions. |
tests/unit/integration/test_kiro_target.py |
Skips file-mode assertions on Windows while keeping functional hook JSON assertions. |
tests/unit/deps/test_revision_pin_resolver.py |
Skips a permissions-only test on Windows where POSIX mode bits aren’t reliable. |
tests/unit/commands/test_self_update_air_gapped.py |
Sets APM_E2E_TESTS=1 to disable startup update notifications and stabilize the observed request list. |
Copilot's findings
- Files reviewed: 5/5 changed files
- Comments generated: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
Eight unit tests passed on macOS/Linux but failed only on
windows-latest(failing run). All three root causes are platform-environment artifacts, not production bugs, so the fixes are test-only.Root causes & fixes
1. POSIX permission assertions (5 tests) —
st_mode & 0o777 == 0o600cannot hold on Windows, which does not honor POSIX file modes (it reports0o666/33206).tests/unit/deps/test_revision_pin_resolver.py— the test asserts only the permission, so it gets a function-level@pytest.mark.skipif(sys.platform == "win32").tests/unit/test_kiro_mcp.py(2) andtests/unit/integration/test_kiro_target.py(3) — guarded just the mode assertion withif sys.platform != "win32":, so the functional JSON-content assertions still run on Windows.2. Unix installer execution tests (2 tests) —
tests/unit/test_enterprise_bootstrap_installers.pyshells out toinstall.sh, whose OS guard rejectsMINGW64_NT-10.0-...withUnsupported operating systembefore theAPM_NO_DIRECT_FALLBACKfail-closed checks run, so the asserted error string never appears. Skipped on win32 —install.shis the Unix installer;install.ps1has its own coverage.3. self-update mirror request list (1 test) —
test_self_update_uses_mirrors_without_public_hostsasserts an exact 2-item request list, but the CLI-startup update notifier (_check_and_notify_updates) adds a cache-gatedlatest.jsonfetch. On a coldwindows-latestrunner cache the gate opens and fires an extra request (3 total); on a warm Unix cache it stays closed (2 total). SettingAPM_E2E_TESTS=1disables the notifier so the request list is deterministic across platforms.Validation
['/apm/latest.json', '/apm/latest.json', '/apm/installers/install.sh']→ withAPM_E2E_TESTS=1:['/apm/latest.json', '/apm/installers/install.sh'].ruff check src/ tests/andruff format --checkare clean.How to test