Skip to content

fix(sbt): filter selective test tasks (testOnly, testQuick) - #3139

Closed
randomBrainstormer wants to merge 2 commits into
rtk-ai:developfrom
randomBrainstormer:feat/sbt/filter-testonly
Closed

randomBrainstormer wants to merge 2 commits into
rtk-ai:developfrom
randomBrainstormer:feat/sbt/filter-testonly

Conversation

@randomBrainstormer

@randomBrainstormer randomBrainstormer commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

What

Follow-up to #752. sbt testOnly <spec> and sbt testQuick — the commands you run to execute a single test or the just-changed tests, the tightest inner loop for a Scala dev — were passed through unfiltered, even though they emit the exact same ScalaTest/munit output that filter_sbt_test already handles.

Reported by @greenhost87 on #752:

Minor problem - single test execution via sbt testOnly falls into rtk sbt <other>

Why it slipped through

Two layers, both missing the task:

  1. Rewrite rule (src/discover/rules.rs): the subcommand alternation listed test but not testOnly/testQuick. With the (?:\s|$) anchor, test cannot match testOnly, so sbt testOnly … was never rewritten to rtk sbt ….
  2. Routing (src/cmds/scala/sbt_cmd.rs): even as rtk sbt testOnly …, run_other only recognized integration-test tasks (:test / /test suffixes) and fell through to run_passthrough.

Change

  • Add testOnly/testQuick to the rewrite alternation, keeping the (?:\s|$) anchor so custom tasks like testify are still not rewritten.
  • New is_test_cmd() helper recognizes testOnly/testQuick and their scoped forms (Test/testOnly, it:testQuick, …) in addition to the existing integration-test tasks.
  • run_other routes all test-producing tasks through runner::run_filtered with filter_sbt_test, so the never_worse cap and tee hint apply (Transparency) — same shared-runner shape as the rest of the module.

No new output format; the filter itself is unchanged and already covered by fixtures.

Tests

  • test_is_test_cmd — bare + scoped testOnly/testQuick, integration tasks, and negatives (compile, assembly, update, testable).
  • test_rewrite_sbt_test_only / test_rewrite_sbt_does_not_match_unrelated_tasks.

cargo fmt --all --check ✅ · cargo clippy --all-targets (no warnings) ✅ · cargo test --all (2520 passed) ✅

🤖 Generated with Claude Code

`sbt testOnly <spec>` and `sbt testQuick` emit standard ScalaTest/munit
output but were passed through unfiltered:

- The rewrite rule's subcommand alternation didn't list them, so
  `sbt testOnly ...` was never rewritten to `rtk sbt ...`.
- Even when invoked as `rtk sbt testOnly ...`, run_other only recognized
  integration-test tasks (:test / /test), so these fell through to
  run_passthrough.

Recognize testOnly/testQuick (and scoped forms like Test/testOnly) as
test-producing tasks and route them through runner::run_filtered with
filter_sbt_test, so the never_worse cap and tee hint apply. Add the
tasks to the rewrite rule, keeping the (?:\s|$) anchor so custom tasks
like `testify` are not rewritten.
- Inline the selective-test task check as matches!(...) to mirror
  is_integration_test_cmd instead of a separate const + contains().
- Reorder run_other so subcommand moves into args_display (drop the
  clone), computing the tee label first.
- Document sbt testOnly in the README supported-commands list.
@randomBrainstormer

Copy link
Copy Markdown
Contributor Author

closing in favor of #3140

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.

1 participant