Skip to content

fix(tests): use an OS-absolute APM_HOME in the scripts log path test - #3707

Merged
Daniel Meppiel (danielmeppiel) merged 2 commits into
mainfrom
danielmeppiel-fix-windows-apm-home-log-path-test
Nov 13, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 2 commits into
mainfrom
danielmeppiel-fix-windows-apm-home-log-path-test

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

build-release.yml run 43322423829 on main fails the Windows x86_64 unit lane:

tests/unit/core/test_script_executors.py::TestGetScriptsLogPath::test_respects_apm_home
AssertionError: assert 'D:\\custom\\apm\\logs\\scripts.log' == '\\custom\\apm\\logs\\scripts.log'

Root cause: the test is wrong, not the product. Since #3614, get_apm_home() anchors a non-absolute APM_HOME to the startup directory. On Windows /custom/apm has no drive, so Path.is_absolute() is False, and D:\a\apm\apm / "\custom\apm" correctly resolves to D:\custom\apm (the startup drive's root), which matches how Windows itself treats a drive-relative path. The test compared against the un-anchored string, which is only absolute on POSIX.

Change (test only):

  • Use a tmp_path-based APM_HOME that is absolute on every OS, and compare Path objects instead of strings.
  • Mark the test windows_compat so the PR-time Windows Compatibility Gate in ci.yml covers it. Before this change, the failure only showed up post-merge in build-release.yml.

Issue and approved scope

Issue: Refs #2884

Human scope-approval comment: #2884 (comment)

This PR repairs a test regression from #3614, which delivered the #2884 scope (APM_HOME as the single root, with logs under it). It adds no new scope. #2884 is otherwise complete.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Commands (macOS, Python 3.12):

  • .venv/bin/python -m pytest -p no:xdist -q tests/unit/core/test_script_executors.py -k "GetScriptsLogPath or AppendToScriptLog": 7 passed.
  • .venv/bin/python -m pytest -p no:xdist -q -m windows_compat tests/unit/core/test_script_executors.py: 1 passed (the test is now selected by the Windows gate).
  • Reproduced the Windows semantics with PureWindowsPath: PureWindowsPath('/custom/apm').is_absolute() is False and PureWindowsPath(r'D:\a\apm\apm') / '/custom/apm' is D:\custom\apm, which matches the CI value.
  • Lint contract: ruff check and ruff format --check (ruff 0.15.12, the version pinned in uv.lock), pylint R0801, and scripts/lint-auth-signals.sh all pass.
  • I have not run this on Windows locally. The PR's Windows Compatibility Gate now runs this test, and the next build-release.yml run on main will confirm it.

Spec conformance (OpenAPM v0.1)

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

On Windows '/custom/apm' is drive-relative, so get_apm_home() (since #3614)
correctly anchors it to the startup drive (D:\custom\apm). The test compared
against the un-anchored string and failed on the Windows release lane. Use a
tmp_path-based APM_HOME, compare Path objects, and mark the test windows_compat
so the PR-time Windows gate covers it.

Refs #2884

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 23:11
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_now

Fixes the Windows release blocker by making the scripts-log-path test use an OS-absolute APM_HOME via tmp_path, unblocking the 0.36.0 release pipeline.

panel-mode=lean; personas=test-coverage-expert,apm-ceo

cc Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

The lean panel (test-coverage-expert and the CEO synthesizer) agrees on this narrow test-only fix. tmp_path gives an absolute path on every OS, comparing Path objects removes the string-level platform difference, and the new windows_compat marker puts this test in the PR-time Windows gate. Since #3614, get_apm_home() anchors a non-absolute APM_HOME to the startup cwd. /custom/apm is drive-relative on Windows, so D:\custom\apm is correct product behavior, and the old string assertion did not account for it.

The one finding (recommended, with passing evidence): the 5 get_apm_home() tests in test_scope.py have no windows_compat marker, so the Windows gate never runs them on Windows. That is a real coverage gap on a platform-sensitive surface, but it is outside this PR's scope. The CHANGELOG folds #3707 into the #3614 line. Nothing breaks and nothing needs arbitration.

Aligned with: Multi-harness / multi-host: the CI gate now runs the scripts-log-path check on Windows. OSS community-driven: unblocks the 0.36.0 release.

Panel summary

Persona B R N Takeaway
Test Coverage Expert 0 1 0 Regression trap is correct: OS-absolute tmp_path, Path comparison, windows_compat marker. Follow-up: test_scope.py APM_HOME tests lack the marker.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top 1 follow-ups

  1. [Test Coverage Expert] Add @pytest.mark.windows_compat to the 5 APM_HOME tests in TestGetApmDir (tests/unit/core/test_scope.py) so the Windows gate runs get_apm_home() on Windows. -- Drive-relative APM_HOME is a Windows-only case. These tests pass on macOS, but without the marker the Windows Compatibility Gate never runs them.

Recommendation

This is a minimal test fix for a CI failure that blocks the release. It changes no product code and breaks nothing. Ship now to unblock 0.36.0. Adding the windows_compat markers to test_scope.py can follow after merge: it widens Windows gate coverage and does not affect whether this fix is correct.


Full per-persona findings

Test Coverage Expert

  • [recommended] test_scope.py APM_HOME tests lack @pytest.mark.windows_compat, so they do not run in the Windows gate. At tests/unit/core/test_scope.py.
    Drive-relative APM_HOME is a Windows-only case. TestGetApmDir has 5 get_apm_home() tests (absolute, relative anchoring, empty, tilde, fail-closed). All pass on macOS, but none carries windows_compat, so the ci.yml Windows Compatibility Gate never runs get_apm_home() on Windows. This is outside this PR's minimal scope.
    Suggested: Add @pytest.mark.windows_compat to the 5 APM_HOME tests in TestGetApmDir. They already use tmp_path and monkeypatch.
    Proof (passed): tests/unit/core/test_scope.py::TestGetApmDir::test_relative_apm_home_is_anchored_to_startup_cwd -- proves: a relative APM_HOME is anchored to the startup directory, but the Windows gate does not run this check on Windows.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.

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.

🟢 Approval recommended

No active review issues are recorded for the test-only Windows path portability fix.

No open issues 🎉

What changed in this PR

This test-only fix corrects a Windows path assumption introduced after #3614 centralized APM_HOME resolution. Production behavior is unchanged.

Changes:

  • Use an OS-absolute tmp_path for APM_HOME and compare Path objects.
  • Mark the regression test windows_compat so the PR-time Windows gate includes it.
  • Add #3707 to the existing APM_HOME changelog entry.
File Description
tests/​unit/​core/​test_script_executors.py Makes the log-path test portable and includes it in Windows regression coverage.
CHANGELOG.md Links this fix to the existing APM_HOME entry.

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 11ec914 into main Nov 13, 2026
23 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-fix-windows-apm-home-log-path-test branch November 13, 2026 06:49
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