Skip to content

fix: Windows test failures in config command and agents compiler#410

Merged
danielmeppiel merged 1 commit intomainfrom
fix/windows-test-failures
Mar 22, 2026
Merged

fix: Windows test failures in config command and agents compiler#410
danielmeppiel merged 1 commit intomainfrom
fix/windows-test-failures

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

Summary

Fixes 7 pre-existing Windows CI test failures (unrelated to #407).

Config command tests (5 failures)

Root cause: PermissionError [WinError 32]os.chdir(tmp_dir) inside TemporaryDirectory() context. On Windows, the OS holds a handle on the CWD, preventing __exit__ from deleting the directory.

Fix: Wrap test body in try/finally to os.chdir(self.original_dir) before the TemporaryDirectory context exits.

Agents compiler summary tests (2 failures)

Root cause: Path.relative_to() returns OS-native separators (sub\AGENTS.md on Windows). Assertions check for forward-slash paths.

Fix: Use .as_posix() in production code (_generate_placement_summary and _generate_distributed_summary) for consistent cross-platform output.

Changes

  • src/apm_cli/compilation/agents_compiler.py.as_posix() on relative paths in summary generation
  • tests/unit/test_config_command.pytry/finally to restore CWD before temp dir cleanup

Testing

  • All 2594 unit tests pass locally
  • Both fixes target Windows-specific issues (path separators, file locking)

Fix 7 pre-existing Windows CI test failures:

- test_config_command.py (5 failures): PermissionError [WinError 32] when
  TemporaryDirectory cleanup runs while CWD is still inside it. Windows
  holds a handle on the CWD directory. Fix: os.chdir() back to original
  dir inside try/finally before the TemporaryDirectory context exits.

- test_agents_compiler_coverage.py (2 failures): Path separator mismatch.
  relative_to() returns Path with OS-native separators (backslash on
  Windows), but assertions check for forward slashes. Fix: use .as_posix()
  in production code for consistent cross-platform summary output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 22, 2026 16:46
@danielmeppiel danielmeppiel merged commit 1f9e231 into main Mar 22, 2026
14 checks passed
@danielmeppiel danielmeppiel deleted the fix/windows-test-failures branch March 22, 2026 16:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes Windows-specific unit test failures by ensuring temporary directories can be cleaned up (restoring CWD before TemporaryDirectory exit) and by normalizing path separators in distributed compilation summaries to be stable across platforms.

Changes:

  • Update apm config unit tests to always chdir back to the original working directory before temp directory cleanup.
  • Normalize relative path formatting in AgentsCompiler distributed summary generation via Path.as_posix().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/unit/test_config_command.py Wraps test bodies in try/finally to restore CWD before TemporaryDirectory() cleanup on Windows.
src/apm_cli/compilation/agents_compiler.py Uses .as_posix() for relative paths in distributed placement/summary output to avoid Windows backslash separators in summaries.

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