spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

chore: add scripts/dev/test.sh — chunked FIFO local test wrapper (~1.75x faster)

Open LahkLeKey opened this issue 6 months ago • 4 comments

Description

Adds a single-file local DX wrapper, scripts/dev/test.sh, that runs the existing pytest suite faster on developer machines without touching production code or CI.

What it does

  • Collects node ids once via pytest --collect-only -q, then dispatches them in fixed-size chunks (default 200) through pytest-xdist with -n auto --dist=load.
  • Persists a cursor at .pytest_cache/fast-test-cursor after every successful chunk, so a crash or Ctrl-C can be resumed exactly where it left off with --resume.
  • Supports --chunk-size N, --reset, --bench, and -- pass-through to pytest.

Why this shape

  • Bounded in-flight memory (one chunk's worth of tests held by xdist workers at a time).
  • Natural FIFO progression inside each chunk via --dist=load.
  • Crash recovery without any new Python module — pure bash around the existing uv run pytest entrypoint.

Measured impact (local, Windows + Git Bash, 16-core)

Run Wallclock
Baseline uv run pytest (serial) ~2m 37s
bash scripts/dev/test.sh --bench 1m 29.85s

~1.75x speedup end-to-end with no production source changes.

Testing

  • [x] Tested locally with uv run specify --help
  • [x] Ran existing tests with uv sync && uv run pytest
  • [ ] Tested with a sample project (if applicable)

Additional validation:

  • Full suite executed via the new wrapper end-to-end: bash scripts/dev/test.sh --bench → 1m 29.85s wallclock.
  • Crash recovery verified by injecting a synthetic failing test, observing the cursor pinned at the failing chunk boundary, fixing the test, and confirming --resume continued from exactly that point with only the remaining tests executed.
  • --reset clears the cursor file; --chunk-size and -- pass-through both exercised.
  • 7 pre-existing Windows-only failures (MSYS path format + MAX_PATH) are unchanged by this PR — they reproduce identically with and without the wrapper.

AI Disclosure

  • [ ] I did not use AI assistance for this contribution
  • [x] I did use AI assistance (describe below)

GitHub Copilot (Claude) assisted with drafting scripts/dev/test.sh, iterating on the chunked-FIFO dispatch design, and producing the benchmark comparison. All design decisions, validation runs, and the final wrapper shape were reviewed and accepted by the author.

LahkLeKey avatar May 27 '26 05:05 LahkLeKey

========================================================================================== short test summary info =========================================================================================== FAILED tests/test_setup_tasks.py::test_setup_tasks_bash_core_template_resolved - AssertionError: TASKS_TEMPLATE must be an absolute path FAILED tests/test_setup_tasks.py::test_setup_tasks_bash_extension_wins_over_core - AssertionError: TASKS_TEMPLATE must be an absolute path FAILED tests/test_timestamp_branches.py::TestTimestampBranch::test_long_name_truncation - AssertionError: [specify] Warning: Branch name exceeded GitHub's 244-byte limit FAILED tests/test_setup_tasks.py::test_setup_tasks_bash_override_wins - AssertionError: TASKS_TEMPLATE must be an absolute path FAILED tests/test_setup_tasks.py::test_setup_tasks_bash_preset_wins_over_extension - AssertionError: TASKS_TEMPLATE must be an absolute path FAILED tests/test_timestamp_branches.py::TestGetFeaturePathsSinglePrefix::test_bash_specify_feature_prefixed_resolves_by_prefix - AssertionError: assert '/tmp/pytest-...1-target-spec' == 'C:\Users\Z...1-target-spec' FAILED tests/test_setup_tasks.py::test_setup_tasks_bash_preset_priority_order - AssertionError: TASKS_TEMPLATE must be an absolute path 7 failed, 193 passed in 15.42s [fast-test] chunk failed — cursor preserved at test #2600 (use --resume to retry)

LahkLeKey avatar May 27 '26 05:05 LahkLeKey

Visual feedback kinda meh during runtime, looking into making some dx tools prettier and test runtimes faster. looping in @mnriem incase you want to provide early feedback

LahkLeKey avatar May 27 '26 05:05 LahkLeKey

This was fine, rip my overage. @mnriem ready for review please trigger a fresh copilot

LahkLeKey avatar May 27 '26 06:05 LahkLeKey

looking into new comments, didn't realize I could trigger the co-pilot review

LahkLeKey avatar Jun 04 '26 22:06 LahkLeKey

hmm seems like a feedback loop for some of these now

LahkLeKey avatar Jun 05 '26 02:06 LahkLeKey

ill turn this into a feat when ready

LahkLeKey avatar Jun 05 '26 03:06 LahkLeKey