feat(node): handler for node --test (TAP summary) and node --check#1952
Open
thibault-monteiro wants to merge 2 commits into
Open
feat(node): handler for node --test (TAP summary) and node --check#1952thibault-monteiro wants to merge 2 commits into
node --test (TAP summary) and node --check#1952thibault-monteiro wants to merge 2 commits into
Conversation
Closes rtk-ai#1950 (the `node` half). ## What it does Adds a `rtk node` subcommand that filters the output of two specific modes of the `node` binary: - **`node --test [files...]`** — Forces `--test-reporter=tap`, parses the TAP 13 stream, emits a compact summary on success (`node --test: 42 passed in 1234ms`) and a summary + full failure blocks on failure (preserving the test name, error message and stack — the actionable signal). Skipped tests are reported. - **`node --check FILE`** — Silent "ok" on success; passes through the SyntaxError stack verbatim on failure (already compact, and the agent needs the location to fix the issue). - Other modes (`node script.js`, `node -e '...'`) are intentionally NOT routed by the rewriter — their stdout/stderr is the user's program's output, which we don't want to filter. ## Files - `src/cmds/js/node_cmd.rs` — new handler with `classify()`, `filter_node_test_output()`, `filter_node_check_output()`. Wired into `js/mod.rs` automatically via `automod`. - `src/main.rs` — `Commands::Node { args }` variant + dispatch + added to the deny-list match arm for command routing. - `src/discover/rules.rs` — new `RtkRule` matching `^node\s+(--test(=|\s|$)|--check\s|-c\s)`. Category `Tests`, estimated savings 80% (test) / 60% (check). - `src/discover/registry.rs` — three new tests: `test_classify_node_test`, `test_classify_node_check`, `test_classify_node_run_is_not_routed`. ## Tests `src/cmds/js/node_cmd.rs` ships 10 unit tests covering classify(), filter_node_check_output() (success/error), and filter_node_test_output() (all-passing, with-failure, with-skipped, zero-tests, no-summary-passthrough). I couldn't run `cargo test` locally on my Windows-GNU toolchain (the `ring` build requires gcc which I haven't installed). `cargo fmt -- --check` passes on all modified files. Counting on the Linux CI to validate.
Author
|
recheck |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1950 (the
nodehalf).What it does
Adds a
rtk nodesubcommand that filters the output of two specific modes of thenodebinary:node --test [files...]— Forces--test-reporter=tap, parses the TAP 13 stream, emits a compact summary on success (node --test: 42 passed in 1234ms) and a summary + full failure blocks on failure (preserving the test name, error message and stack — the actionable signal). Skipped tests are reported.node --check FILE— Silent "ok" on success; passes through the SyntaxError stack verbatim on failure (already compact, and the agent needs the location to fix the issue).node script.js,node -e '...') are intentionally NOT routed by the rewriter — their stdout/stderr is the user's program's output, which we don't want to filter.Files
src/cmds/js/node_cmd.rs— new handler withclassify(),filter_node_test_output(),filter_node_check_output(). Wired intojs/mod.rsautomatically viaautomod.src/main.rs—Commands::Node { args }variant + dispatch + added to the deny-list match arm for command routing.src/discover/rules.rs— newRtkRulematching^node\s+(--test(=|\s|$)|--check\s|-c\s). CategoryTests, estimated savings 80% (test) / 60% (check).src/discover/registry.rs— three new tests:test_classify_node_test,test_classify_node_check,test_classify_node_run_is_not_routed.Tests
src/cmds/js/node_cmd.rsships 10 unit tests covering classify(), filter_node_check_output() (success/error), andfilter_node_test_output() (all-passing, with-failure, with-skipped, zero-tests, no-summary-passthrough).
I couldn't run
cargo testlocally on my Windows-GNU toolchain (theringbuild requires gcc which I haven't installed).cargo fmt -- --checkpasses on all modified files. Counting on the Linux CI to validate.Summary
Test plan
cargo fmt --all && cargo clippy --all-targets && cargo testrtk <command>output inspected