Skip to content

test: fix Windows-only CI failures across 8 unit tests#1752

Merged
danielmeppiel merged 1 commit into
mainfrom
danielmeppiel/fantastic-guide
Jun 11, 2026
Merged

test: fix Windows-only CI failures across 8 unit tests#1752
danielmeppiel merged 1 commit into
mainfrom
danielmeppiel/fantastic-guide

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

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 == 0o600 cannot hold on Windows, which does not honor POSIX file modes (it reports 0o666/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) and tests/unit/integration/test_kiro_target.py (3) — guarded just the mode assertion with if 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.py shells out to install.sh, whose OS guard rejects MINGW64_NT-10.0-... with Unsupported operating system before the APM_NO_DIRECT_FALLBACK fail-closed checks run, so the asserted error string never appears. Skipped on win32 — install.sh is the Unix installer; install.ps1 has its own coverage.

3. self-update mirror request list (1 test)test_self_update_uses_mirrors_without_public_hosts asserts an exact 2-item request list, but the CLI-startup update notifier (_check_and_notify_updates) adds a cache-gated latest.json fetch. On a cold windows-latest runner cache the gate opens and fires an extra request (3 total); on a warm Unix cache it stays closed (2 total). Setting APM_E2E_TESTS=1 disables the notifier so the request list is deterministic across platforms.

Validation

  • Reproduced the exact Windows double-fetch locally by forcing the cache gate open: ['/apm/latest.json', '/apm/latest.json', '/apm/installers/install.sh'] → with APM_E2E_TESTS=1: ['/apm/latest.json', '/apm/installers/install.sh'].
  • All 65 tests in the 5 affected files pass on macOS.
  • ruff check src/ tests/ and ruff format --check are clean.

How to test

uv run --extra dev pytest \
  tests/unit/deps/test_revision_pin_resolver.py \
  tests/unit/test_kiro_mcp.py \
  tests/unit/integration/test_kiro_target.py \
  tests/unit/test_enterprise_bootstrap_installers.py \
  tests/unit/commands/test_self_update_air_gapped.py -q

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>
Copilot AI review requested due to automatic review settings June 11, 2026 16:19
@danielmeppiel danielmeppiel merged commit 3943ec9 into main Jun 11, 2026
19 checks passed
@danielmeppiel danielmeppiel deleted the danielmeppiel/fantastic-guide branch June 11, 2026 16:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.sh OS guards prevent reaching the expected fail-closed branches.
  • Make self-update request assertions deterministic across platforms by setting APM_E2E_TESTS=1 to 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

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.

2 participants