Skip to content

feat(cli): add toolr project venv run#378

Merged
s0undt3ch merged 9 commits into
mainfrom
venv-run
Jul 13, 2026
Merged

feat(cli): add toolr project venv run#378
s0undt3ch merged 9 commits into
mainfrom
venv-run

Conversation

@s0undt3ch

Copy link
Copy Markdown
Owner

Summary

Adds toolr project venv run [--no-sync] [--quiet] -- <CMD> [ARGS...] — a first-class way to run any command inside the project's managed tools venv. Resolves #373.

The one-liner for running a command-package's tests becomes:

toolr project venv run -- pytest tools/

Rather than the issue's pytest-specific toolr test, this is a general runner: test is just one call of it, CI uses it verbatim, and there's zero runner lock-in because there is no runner concept. It lives under the reserved project venv group (never toolr run, which would collide with user-defined commands).

Behavior

  • Default: freshness-gated auto-sync (via ensure_venv_ready, exactly like venv shell and uv run), then runs the command with $VIRTUAL_ENV/$TOOLR_VENV/$PATH set so entry points resolve from the venv. Self-healing past the mtime freshness heuristic.
  • --no-sync: pure, uv-free path for deterministic CI — never touches the venv, errors fatally if it is missing or stale.
  • No command echo on the happy path (parity with uv run/poetry run/cargo run); child owns stdout/stderr; exit code passes straight through; caller's cwd preserved.
  • Command-not-found gives an actionable nudge (exit 127) for argv[0]; python -m missingmodule errors pass through untouched.
  • --quiet forwards to the auto-sync step only; --quiet only, no short -q.

Discoverability

project init next-steps and venv sync success output now advertise the one-liner.

Docs & skills

  • New docs/cli.md section + generated --help snippet.
  • toolr-command-authoring and toolr-ci-setup skills teach the new command (authoring for local test runs, CI for --no-sync deterministic runs).

Tests

  • New crates/toolr/tests/project_venv_run.rs: missing-venv / stale errors, exit-code passthrough, arg pass-through via --, command-not-found nudge, --no-sync gating. The not-found nudge runs on all platforms; an ignored real-venv test covers real Scripts\*.exe PATHEXT resolution + exit-code passthrough on the Windows CI leg.
  • Full mise run test and prek run --all-files green.

Design + plan archived under specs/archive/2026/.

…ands

Point the command-authoring and CI-setup skills at the new venv-run
one-liner instead of hand-built pytest invocations, and queue the
release note.
venv-run has shipped; move its design and plan to the 2026 archive
as the final implementation step.
Split the fake-venv fixture into a Unix-only runnable-interpreter builder
(kept for tests that actually execute the interpreter) and a new
cross-platform builder that writes an interpreter placeholder plus the
toolr package at the OS-correct site-packages layout. De-gate
not_found_command_gets_nudge and mark_fresh so the command-not-found
nudge + exit code 127 assertion runs on Windows too. Note on the ignored
runs_in_a_real_synced_venv test that it remains the vehicle for real
.exe/PATHEXT resolution and exit-code passthrough on Windows CI.
@s0undt3ch

Copy link
Copy Markdown
Owner Author

This change is part of the following stack:

Change managed by git-spice.

…t, runner-path-hygiene, remove-editable-install)
@s0undt3ch
s0undt3ch marked this pull request as ready for review July 13, 2026 17:17
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.04651% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.8%. Comparing base (3fcf63d) to head (6c20439).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/toolr/src/project.rs 80.6% 12 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #378   +/-   ##
=====================================
  Coverage   93.8%   93.8%           
=====================================
  Files         96      96           
  Lines      15939   16023   +84     
  Branches     118     118           
=====================================
+ Hits       14958   15039   +81     
- Misses       971     974    +3     
  Partials      10      10           
Flag Coverage Δ
3.11 93.8% <86.0%> (+<0.1%) ⬆️
3.12 93.8% <86.0%> (+<0.1%) ⬆️
3.13 93.8% <86.0%> (+<0.1%) ⬆️
3.14 93.8% <86.0%> (+<0.1%) ⬆️
macos-latest 93.8% <86.0%> (+<0.1%) ⬆️
ubuntu-latest 93.8% <86.0%> (+<0.1%) ⬆️
windows-latest 90.5% <80.2%> (+0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
toolr-core 94.3% <ø> (+<0.1%) ⬆️
toolr 92.8% <86.0%> (+<0.1%) ⬆️
toolr-py 96.0% <ø> (ø)
xtask 90.3% <ø> (ø)
Files with missing lines Coverage Δ
crates/toolr/src/builtin_completions.rs 99.5% <100.0%> (ø)
crates/toolr/src/cli.rs 94.5% <100.0%> (+0.1%) ⬆️
crates/toolr/src/project.rs 83.7% <80.6%> (+0.8%) ⬆️

... and 1 file with indirect coverage changes

@s0undt3ch
s0undt3ch merged commit 35b3d7e into main Jul 13, 2026
90 of 95 checks passed
@s0undt3ch
s0undt3ch deleted the venv-run branch July 13, 2026 21:51
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.

Add a toolr test command to run a package's tests in the managed venv

1 participant