Skip to content

[#509] Cross-platform stormtest + serve-this-worktree pathing#516

Open
dsarno wants to merge 4 commits into
mainfrom
claude/vibrant-keller-nGpvP
Open

[#509] Cross-platform stormtest + serve-this-worktree pathing#516
dsarno wants to merge 4 commits into
mainfrom
claude/vibrant-keller-nGpvP

Conversation

@dsarno

@dsarno dsarno commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes the stormtest invocation surface platform-agnostic so a Windows agent can copy-paste one command and run, removing the POSIX-only steps (.venv/bin/python, bash-only serve-this-worktree) called out in #509.

  • script/_dev_env.py — new, stdlib-only, import-safe shared helpers: venv interpreter resolution (bin/python vs Scripts\python.exe), git worktree/root-repo resolution, a venv re-exec decision, and cross-platform port freeing (lsof vs netstat/taskkill).
  • script/stormtest.py — re-execs into the project .venv on launch, so python script/stormtest.py works identically on every OS. Opt out with SS_NO_REEXEC=1.
  • script/serve-this-worktree.py — new cross-platform (no bash/lsof) companion to the bash serve-this-worktree; extra args (e.g. --ws-port) pass straight through. The bash script is retained for POSIX.
  • Host-side path construction in the harness already goes through tempfile.gettempdir() / os.path.join — audited and confirmed resilient; only the invocation surface needed work (issue item 3).
  • docs/STRESS_TESTING.md + AGENTS.md — document the OS-agnostic commands and trim the invocation/serve-script parts of the Windows heads-up.

Test plan

  • ruff check + ruff format --check on all changed/new files — clean.
  • pytest -q full suite — 1158 passed, 2 skipped.
  • tests/unit/test_dev_env.py (new, 18 tests) — venv layout for both OSes (Windows branch exercised on POSIX via an explicit flag, no global os.name flip), worktree/root-repo resolution, --port extraction, lsof/netstat PID parsing, the re-exec decision (no-op when already in-venv / guarded / opted-out / no venv; execs otherwise), and a py_compile smoke of all three scripts.
  • script/ci-check-gdscript — "All GDScript files OK" (no GDScript touched; run for safety).
  • Manual smoke: find_venv_python() resolves the real .venv; serve-this-worktree.py resolves worktree src/ + venv and parses args; re-exec is a no-op when already running the venv interpreter.
  • n/a Live-editor test_run / self-update / write-tool-undo smokes — this change is Python tooling + docs only; it touches no plugin/GDScript, self-update, or write-tool code.

Deviations / notes

Closes #509


Generated by Claude Code

The stormtest invocation surface assumed POSIX. Make the documented commands
identical on every OS so a Windows agent can copy-paste and run.

- script/_dev_env.py: shared, stdlib-only, import-safe helpers — venv
  interpreter resolution (bin/python vs Scripts\python.exe), git worktree/
  root-repo resolution, a venv re-exec decision, and cross-platform port
  freeing (lsof vs netstat/taskkill).
- script/stormtest.py: re-exec into the project .venv on launch so
  `python script/stormtest.py` works everywhere (no .venv/bin/python vs
  .venv\Scripts\python.exe split). Opt out with SS_NO_REEXEC=1.
- script/serve-this-worktree.py: cross-platform (no bash/lsof) companion to
  the bash serve-this-worktree; extra args like --ws-port pass straight
  through. The bash script is retained for POSIX.
- Host-side path construction in stormtest already goes through
  tempfile.gettempdir()/os.path.join — confirmed resilient; only the
  invocation surface needed work.
- docs/STRESS_TESTING.md + AGENTS.md: document the OS-agnostic commands and
  trim the invocation/serve-script parts of the Windows heads-up. The
  reload-churn caveats (#513, and #514's kill-on-reload product decision)
  are unrelated and deliberately left in place.

Tests: tests/unit/test_dev_env.py covers the platform branches (Windows
layout exercised on POSIX CI), port/arg parsing, the re-exec decision, and a
compile smoke of all three scripts.

https://claude.ai/code/session_01FAB4kCYfQNGP4LQTVbPRTM
Drop the O(n) `not in pids` membership checks in parse_lsof_pids /
parse_netstat_pids; dedup once at return, preserving order.

https://claude.ai/code/session_01FAB4kCYfQNGP4LQTVbPRTM
@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

_port_listening only probed 127.0.0.1, so a dev server bound to ::1 (common
on Windows, the platform this targets — see #511) would go undetected and
free_port would no-op, leaving the external server unable to bind. Probe both
AF_INET and AF_INET6. Adds a test for the listening probe.

https://claude.ai/code/session_01FAB4kCYfQNGP4LQTVbPRTM

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.

Pull request overview

This PR makes the stormtest/dev-server workflow cross-platform by moving OS-specific logic (venv interpreter pathing and port freeing) into a shared stdlib-only helper module, updating the runner to auto re-exec into the project .venv, and adding a Python equivalent of the existing POSIX-only serve-this-worktree bash script. It also updates docs to advertise OS-agnostic invocation and adds unit tests for the new helper behaviors.

Changes:

  • Add script/_dev_env.py with helpers for worktree/root-repo resolution, venv interpreter resolution, venv re-exec, and cross-platform port freeing.
  • Update script/stormtest.py to re-exec into .venv automatically so python script/stormtest.py works on all OSes.
  • Add script/serve-this-worktree.py as a cross-platform (non-bash) way to run the dev server from the current worktree’s src/, and update docs/tests accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
script/_dev_env.py New shared helper module for cross-platform dev-script behavior (venv pathing, worktree/root-repo detection, port freeing, re-exec).
script/stormtest.py Adds auto re-exec into the project venv before importing third-party deps; updates documented invocation.
script/serve-this-worktree.py New Python entrypoint to launch the dev server from the current worktree with --reload, freeing the chosen port first.
tests/unit/test_dev_env.py New unit tests covering OS-branching logic, parsing helpers, and the venv re-exec decision.
docs/STRESS_TESTING.md Updates invocation instructions to python ... and refreshes Windows/cross-platform guidance.
AGENTS.md Updates the script inventory and stormtest section to reference the new cross-platform invocation/serve script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread script/_dev_env.py
Comment thread docs/STRESS_TESTING.md
Address Copilot review feedback on PR #516:
- extract_port now raises ValueError on a missing/non-integer --port instead
  of silently using the default (a typo'd port would otherwise start the
  server on 8000 while the editor waits on the intended port). serve-this-
  worktree.py catches it and exits 1 with a clear message.
- docs/STRESS_TESTING.md: note the SS_* examples use POSIX inline-env syntax
  and give the PowerShell equivalent ($env:SS_FOO=...; python ...).

https://claude.ai/code/session_01FAB4kCYfQNGP4LQTVbPRTM
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.

stormtest: make runner pathing platform-agnostic (Windows)

3 participants