test(ci): stop the nightly guard leaving scripts/ci on the import path

Merged
TE
25d ago
+21-3

Follow-up to #13899, addressing the one actionable CodeRabbit finding on it.

tests/test_ci_nightly_push_throttle.py ran sys.path.insert(0, scripts/ci) inside a test and never took it back out. main() runs every test_* in this file in a single process, so that entry sat at the front of the import path for every test that ran afterwards โ€” whatever they imported would have resolved out of scripts/ci first. Nothing collides today; the point is that nothing stops one from colliding.

The import now goes through a helper that removes the entry in a finally.

Why not CodeRabbit's suggestion. It asked for monkeypatch.syspath_prepend. There is no pytest in this lane โ€” ci-guards.yml runs the file as python3 tests/test_ci_nightly_push_throttle.py, and the repo has no pytest config, no conftest.py, and no pytest dependency โ€” so there is no fixture to restore anything. The bot also marked the finding "โœ… Addressed in commit 32381d8"; it was not, the line was still on main.

Tradeoff: a helper instead of two plain import lines. That is the cost of not depending on a test runner this repo does not use.

Guard sweep: 172 of the 177 commands in ci-guards.yml pass locally; the 5 that fail need $RUNNER_TEMP, the ghostty/vendor/bonsplit submodules, or CI-provided arguments, and fail the same way on main.

๐Ÿค– Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Stops the nightly-guard test from leaving scripts/ci on the import path, which could make later tests in the same process resolve imports from the wrong directory. The CI scripts now load through a helper that restores the original path in a finally block.

  • Because nightly_build_inputs prepends the same directory on import, the helper saves and restores the whole path list instead of removing one entry.
  • The lane runs the file as plain python3 rather than under pytest, so there is no fixture to restore the path.

Summary by CodeRabbit

  • Tests
    • Improved isolation between CI-related tests by preventing temporary import-path changes from carrying over into later tests.
    • No user-facing behavior changes.