Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changelog/2026/06/19/native-test-expression-passthrough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Native Test Expression Passthrough

Date: 2026-06-19

## Changed

- Route `rtk test -d ...` and similar native `test` expressions to the system `test` command instead of `sh -c`.

## Files

- `src/main.rs`: detects native `test` expressions before using the RTK test-output wrapper.

## Validation

- `rtk cargo +1.91.0 fmt --all && rtk cargo +1.91.0 clippy --all-targets && rtk cargo +1.91.0 test --all`
- `rtk cargo +1.91.0 build`
- `rtk proxy ./target/debug/rtk test -d .`
- `rtk proxy ./target/debug/rtk test -d graphify-out`
- `rtk proxy ./target/debug/rtk test true`
27 changes: 25 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,12 @@ where
}
}

fn is_native_test_expression(command: &[String]) -> bool {
command
.first()
.is_some_and(|arg| arg == "!" || arg == "(" || arg.starts_with('-'))
}

fn run_cli() -> Result<i32> {
// Fire-and-forget telemetry ping (1/day, non-blocking)
core::telemetry::maybe_ping();
Expand Down Expand Up @@ -1726,8 +1732,13 @@ fn run_cli() -> Result<i32> {
}

Commands::Test { command } => {
let cmd = command.join(" ");
runner::run_test(&cmd, cli.verbose)?
if is_native_test_expression(&command) {
let args: Vec<OsString> = command.into_iter().map(OsString::from).collect();
core::runner::run_passthrough("test", &args, cli.verbose)?
} else {
let cmd = command.join(" ");
runner::run_test(&cmd, cli.verbose)?
}
}

Commands::Json {
Expand Down Expand Up @@ -2852,6 +2863,18 @@ mod tests {
}
}

#[test]
fn test_dash_d_routes_to_native_test_expression() {
let command = vec!["-d".to_string(), "graphify-out".to_string()];
assert!(is_native_test_expression(&command));
}

#[test]
fn test_cargo_test_stays_test_runner() {
let command = vec!["cargo".to_string(), "test".to_string()];
assert!(!is_native_test_expression(&command));
}

#[test]
fn test_try_parse_git_with_dash_c_succeeds() {
let result = Cli::try_parse_from(["rtk", "git", "-C", "/path", "status"]);
Expand Down