Skip to content

test(integration): fix 3 semantic-merge test breakages in merge queue#1834

Merged
danielmeppiel merged 1 commit into
mainfrom
danielmeppiel/curly-dollop
Jun 18, 2026
Merged

test(integration): fix 3 semantic-merge test breakages in merge queue#1834
danielmeppiel merged 1 commit into
mainfrom
danielmeppiel/curly-dollop

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

TL;DR

Six integration tests started failing in the merge queue (run 27680546218) across shards 1 and 4. None are flaky in the usual sense — they are stale tests broken by semantic merge conflicts: three recently-merged PRs each passed in isolation, but their combination on main left assertions/patches pointing at old behavior. This PR fixes all six.

Root causes & fixes

1. AttributeError: ... does not have the attribute '_get_gemini_dir'

tests/integration/test_wave2_adapters_coverage.py

PR #1770 renamed GeminiClientAdapter._get_gemini_dir()_get_config_dir(). PR #1788 added a test that still patches the old name. Updated the patch.object target.

2. assert 2 == 1 on unmanaged-files details

tests/integration/test_wave7_policy_registry_coverage.py

PR #1793 now appends a single trailing next-action hint ("Next: run 'apm install <ref>' ...") to any non-empty unmanaged-files report. test_unmanaged_file_deny asserted exactly one detail line. Changed it to assert on the flagged-file line itself ("not tracked in apm.lock.yaml" + stray.md) rather than the raw count, so it stays correct regardless of the hint.

3. Four SystemExit(1) failures in outdated / compile

tests/integration/test_commands_deep_coverage.py

These tests passed obj={"cwd": ...} — but no command ever reads that key (verified: zero obj["cwd"] reads in src/). outdated and compile resolve the project via Path.cwd() (get_apm_dir(PROJECT) returns Path.cwd()). The tests only passed because pytest's process CWD was the repo root (a valid APM project), never the fixture dir. Under CI's parallel xdist (-n 2 --dist loadgroup), a sibling test leaking os.chdir polluted the shared worker CWD and flipped these exit codes.

Fix: pin CWD deterministically with monkeypatch.chdir(fixture) (auto-restoring, so the tests can no longer be polluted or pollute others), and correct three assertions that never actually matched the commands' real behavior:

Test Old (accidental) Real behavior in fixture dir
test_outdated_no_lockfile exit 0 exit 1, No lockfile found
test_outdated_no_dependencies exit 0 exit 0, No locked dependencies (now deterministic)
test_compile_no_apm_yml exit 0 exit 1, Not an APM project
test_compile_no_agents_md exit 0 exit 1, No APM content found

Validation

  • All 6 originally-failing tests pass.
  • The 3 affected files (682 tests) pass under -n 2 --dist loadgroup.
  • Deep-coverage tests verified resilient to a simulated leaked os.chdir (the exact CI failure mode).
  • ruff check + ruff format --check clean on all edited files.
  • No src/ changes — test-only fix matching real, intended command behavior.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Three independent stale-test failures surfaced in the merge queue once
recently-merged PRs combined on main:

- test_wave2_adapters_coverage: patched GeminiClientAdapter._get_gemini_dir,
  which #1770 renamed to _get_config_dir. Update the patch target.

- test_wave7 test_unmanaged_file_deny: asserted exactly one detail line,
  but #1793 appends a single trailing next-action hint to any non-empty
  unmanaged-files report. Assert on the flagged-file line instead of the
  raw detail count.

- test_commands_deep_coverage (outdated/compile): these tests passed
  obj={"cwd": ...}, which the commands never read -- they resolve the
  project via Path.cwd(). They only passed because pytest's cwd was the
  repo root (a valid APM project); under CI xdist a sibling test leaking
  os.chdir flipped their exit codes. Pin cwd with monkeypatch.chdir and
  assert the commands' real behavior (no-lockfile and no-content exit 1).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 18, 2026 13:57
@danielmeppiel danielmeppiel merged commit feab133 into main Jun 18, 2026
19 checks passed
@danielmeppiel danielmeppiel deleted the danielmeppiel/curly-dollop branch June 18, 2026 13:58

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

Fixes stale integration tests that broke in the merge queue due to upstream behavior changes landing in separate PRs, bringing the integration suite back to green without changing src/ behavior.

Changes:

  • Update a Gemini adapter test to patch the renamed helper (_get_gemini_dir -> _get_config_dir).
  • Make unmanaged-files policy test resilient to an added trailing “next action” hint by asserting on the per-file detail line.
  • Make outdated/compile deep-coverage tests deterministic under xdist by pinning process CWD via monkeypatch.chdir(...) and aligning assertions with actual command behavior.
Show a summary per file
File Description
tests/integration/test_wave7_policy_registry_coverage.py Avoids brittle details count assertion; checks the unmanaged-file detail line content instead.
tests/integration/test_wave2_adapters_coverage.py Patches the correct renamed method on GeminiClientAdapter to prevent AttributeError.
tests/integration/test_commands_deep_coverage.py Pins Path.cwd()-based project resolution via monkeypatch.chdir and updates exit-code/output expectations to match real command behavior.

Copilot's findings

  • Files reviewed: 3/3 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