Repository navigation
fix(tests): use an OS-absolute APM_HOME in the scripts log path test - #3707
Daniel Meppiel (danielmeppiel) merged 2 commits into
Conversation
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]>
Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| 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
- [Test Coverage Expert] Add
@pytest.mark.windows_compatto the 5 APM_HOME tests inTestGetApmDir(tests/unit/core/test_scope.py) so the Windows gate runsget_apm_home()on Windows. -- Drive-relativeAPM_HOMEis 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.TestGetApmDirhas 5get_apm_home()tests (absolute, relative anchoring, empty, tilde, fail-closed). All pass on macOS, but none carrieswindows_compat, so the ci.yml Windows Compatibility Gate never runsget_apm_home()on Windows. This is outside this PR's minimal scope.
Suggested: Add@pytest.mark.windows_compatto the 5 APM_HOME tests inTestGetApmDir. 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.
There was a problem hiding this comment.
🟢 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_pathforAPM_HOMEand comparePathobjects. - Mark the regression test
windows_compatso the PR-time Windows gate includes it. - Add #3707 to the existing
APM_HOMEchangelog 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
Description
build-release.ymlrun 43322423829 on main fails the Windows x86_64 unit lane:Root cause: the test is wrong, not the product. Since #3614,
get_apm_home()anchors a non-absoluteAPM_HOMEto the startup directory. On Windows/custom/apmhas no drive, soPath.is_absolute()isFalse, andD:\a\apm\apm / "\custom\apm"correctly resolves toD:\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):
tmp_path-basedAPM_HOMEthat is absolute on every OS, and comparePathobjects instead of strings.windows_compatso the PR-time Windows Compatibility Gate inci.ymlcovers it. Before this change, the failure only showed up post-merge inbuild-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
Testing
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).PureWindowsPath:PureWindowsPath('/custom/apm').is_absolute()isFalseandPureWindowsPath(r'D:\a\apm\apm') / '/custom/apm'isD:\custom\apm, which matches the CI value.ruff checkandruff format --check(ruff 0.15.12, the version pinned inuv.lock), pylint R0801, andscripts/lint-auth-signals.shall pass.build-release.ymlrun on main will confirm it.Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.