Skip to content

Commit ceb9d00

Browse files
docs(tests/trash): warn future contributors about Windows MAPPING_FILE quirk
QA-recommended follow-up to df82528 (G6 batch 2). The Windows path-resolution bug (`/opt/splunk/...` → `C:/opt/splunk/...`) only shows up on re-run after a test forgets to patch MAPPING_FILE — the first run uses a clean tmp_path and passes, but subsequent runs hit stale state in the artifact directory and produce flake-style "rule already exists" failures. Adds a `⚠ Windows test-isolation note` docstring block to both TestRestoreCsvFromTrash and TestRestoreRuleFromTrash explaining: - Why MAPPING_FILE resolves to C:/opt/splunk/... on Windows - That every test MUST patch BOTH wl_trash.OWN_LOOKUPS AND wl_trash.MAPPING_FILE to tmp_path - Pointer to commit df82528 for full discovery context Pure documentation — no logic changes, no test count changes. 35/35 trash tests still passing. doc-drift OK against build 663.
1 parent ea9b8b6 commit ceb9d00

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

tests/unit/test_trash.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,19 @@ def test_restore_conflict(self, mock_restore):
629629
class TestRestoreCsvFromTrash:
630630
"""Tests for restore_csv_from_trash (covers lines 469-509 +
631631
_restore_mapping_for_csv helper, currently the biggest coverage gap
632-
in wl_trash.py)."""
632+
in wl_trash.py).
633+
634+
⚠ Windows test-isolation note:
635+
The `MAPPING_FILE` constant from `wl_constants` is
636+
`/opt/splunk/etc/apps/wl_manager/lookups/rule_csv_map.csv`. On
637+
Windows that resolves to `C:/opt/splunk/...` (leading-slash =
638+
current drive root), an artifact directory that persists between
639+
test runs. Tests in this class MUST `patch("wl_trash.MAPPING_FILE",
640+
str(<tmp_path mapping file>))` in addition to `OWN_LOOKUPS`,
641+
otherwise state leaks into `C:/opt/splunk/...` and causes
642+
flake-style "rule already exists" failures on re-run. See
643+
commit `df82528` for the discovery context.
644+
"""
633645

634646
def _make_trash_item(self, tmp_path, csv_name="test.csv",
635647
app_ctx="", rule_name=""):
@@ -731,7 +743,20 @@ def test_restore_csv_no_rule_skips_mapping_update(self, tmp_path):
731743

732744
@pytest.mark.unit
733745
class TestRestoreRuleFromTrash:
734-
"""Tests for restore_rule_from_trash (covers lines 575-647)."""
746+
"""Tests for restore_rule_from_trash (covers lines 575-647).
747+
748+
⚠ Windows test-isolation note (same constraint as
749+
TestRestoreCsvFromTrash above):
750+
`wl_trash.MAPPING_FILE` resolves to `C:/opt/splunk/...` on Windows
751+
because the constant is a leading-slash POSIX path that Python
752+
interprets as relative to the current drive root. Every test in
753+
this class MUST `patch("wl_trash.MAPPING_FILE", ...)` to a
754+
tmp_path file in addition to `patch("wl_trash.OWN_LOOKUPS", ...)`,
755+
otherwise mapping writes leak into `C:/opt/splunk/...` and cause
756+
flake-style "rule already exists" / cross-test contamination
757+
failures on re-run. See commit `df82528` for the discovery
758+
context and the matching warning on TestRestoreCsvFromTrash.
759+
"""
735760

736761
def _make_rule_trash_item(self, tmp_path, rule_name="DR_restored",
737762
csv_names=("DR_a.csv", "DR_b.csv")):

0 commit comments

Comments
 (0)