Skip to content

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

Open
LahkLeKey wants to merge 2 commits into
github:mainfrom
LahkLeKey:main
Open

chore: add scripts/dev/test.sh — chunked FIFO local test wrapper (~1.75x faster)#2719
LahkLeKey wants to merge 2 commits into
github:mainfrom
LahkLeKey:main

Conversation

@LahkLeKey
Copy link
Copy Markdown
Contributor

@LahkLeKey LahkLeKey commented May 27, 2026

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

  • Tested locally with uv run specify --help
  • 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
  • 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 added 2 commits May 26, 2026 23:58
feat: add scripts/dev/test.sh — chunked FIFO local test wrapper (~1.75x faster)
@LahkLeKey LahkLeKey requested a review from mnriem as a code owner May 27, 2026 05:06
Copilot AI review requested due to automatic review settings May 27, 2026 05:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a local “fast test” wrapper to run pytest in bounded-size chunks using pytest-xdist, and updates pytest defaults to run in parallel by default.

Changes:

  • Added scripts/dev/test.sh to collect node IDs once and execute them in fixed-size FIFO chunks with resume/reset support.
  • Added pytest-xdist to test dependencies.
  • Enabled xdist parallel execution by default via pyproject.toml pytest addopts.

Reviewed changes

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

File Description
scripts/dev/test.sh New chunked pytest runner with cursor-based resume/reset and xdist execution per chunk
pyproject.toml Adds pytest-xdist and enables -n auto / --dist=worksteal in default pytest options

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

Comment thread pyproject.toml
Comment thread scripts/dev/test.sh
Comment thread scripts/dev/test.sh
Comment thread scripts/dev/test.sh
@LahkLeKey LahkLeKey marked this pull request as draft May 27, 2026 05:11
@LahkLeKey
Copy link
Copy Markdown
Contributor Author

========================================================================================== 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
Copy link
Copy Markdown
Contributor Author

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 LahkLeKey marked this pull request as ready for review May 27, 2026 05:59
@LahkLeKey
Copy link
Copy Markdown
Contributor Author

LahkLeKey commented May 27, 2026

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 5

Comment thread pyproject.toml
Comment on lines 62 to 66
"--strict-markers",
"--tb=short",
"-n=auto",
"--dist=worksteal",
]
Comment thread pyproject.toml
"-v",
"--strict-markers",
"--tb=short",
"-n=auto",
Comment thread scripts/dev/test.sh
Comment on lines +58 to +61
mapfile -t NODES < <(
uv run pytest -o addopts= --collect-only -q "${PASSTHROUGH[@]}" \
2>/dev/null | grep -E '::' || true
)
Comment thread scripts/dev/test.sh
Comment on lines +88 to +91
PYTEST_FLAGS=(-o addopts= -n auto --dist=load --tb=short)
(( BENCH )) && PYTEST_FLAGS+=(-q) || PYTEST_FLAGS+=(--no-header -q)

if ! uv run pytest "${PYTEST_FLAGS[@]}" "${NODES[@]:i:CHUNK_SIZE}"; then
Comment thread scripts/dev/test.sh
Comment on lines +70 to +73
if (( RESUME )) && [[ -f "$CURSOR_FILE" ]]; then
START="$(cat "$CURSOR_FILE")"
echo "[fast-test] resuming from chunk cursor: test #$START"
fi
Copy link
Copy Markdown
Collaborator

@mnriem mnriem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address Copilot feedback

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.

3 participants