Skip to content

Flaky test_plugin_version_bump.py — non-deterministic CWD-leak under full-suite ordering #1007

Description

@michael-wojcik

Summary

tests/test_plugin_version_bump.py exhibits a non-deterministic, order-dependent failure of its 4 version-consistency tests (test_plugin_json_version, test_marketplace_json_version, test_root_readme_version, test_pact_plugin_readme_version) — observed failing ~1 in 4 full-suite runs (python -m pytest tests/), always passing in isolation and at a clean HEAD.

Mechanism (partial)

These 4 tests resolve paths via REPO_ROOT = Path(__file__).resolve()..., which is CWD-sensitive when __file__ is relative (as under python -m pytest tests/). A test that leaks a changed CWD (e.g. a raw os.chdir() not restored on an assertion-raise) would cause a later __file__.resolve() to resolve against the wrong root → stale plugin.json read → these 4 assertions fail.

Investigation so far (during PR #1006 review remediation)

  • Grepped all raw os.chdir across tests/exactly one file uses it (test_working_memory_worktree_sync.py, 22 sites, 0 monkeypatch.chdir).
  • Audited all enter-sites → every restore is inside a finally block → assertion-safe → this file is NOT the leaker (initial suspicion falsified).
  • Ran the full suite 5× back-to-back (8 total in-session) → zero recurrence; could not reproduce to bisect.

Recommended next step

A dedicated repro harness is needed to find the true leaker: a pytest-randomly seed sweep + a per-test autouse fixture asserting CWD is unchanged after each test. Non-trivial; deferred from PR #1006 (pre-existing, unrelated to #962).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions