Skip to content

Commit ae6e2b4

Browse files
leemarsfornwall
authored andcommitted
Allow passing additional args to cargo test/bench
1 parent 7275656 commit ae6e2b4

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ impl InputAction {
480480
} else {
481481
return Err(MainError::OtherOwned("Could not execute cargo".to_string()));
482482
}
483+
} else {
484+
cmd.args(script_args.iter());
483485
}
484486

485487
Ok(cmd)

tests/data/script-test-extra-args.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {}
2+
3+
#[test]
4+
fn test() { println!("Hello, world!"); }

tests/tests/script.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ fn test_script_test() {
9292
assert!(out.stdout.contains("running 1 test"));
9393
}
9494

95+
#[test]
96+
fn test_script_test_extra_args_for_cargo() {
97+
let out = rust_script!("--test", "tests/data/script-test-extra-args.rs", "--help").unwrap();
98+
assert!(out.success());
99+
assert!(out.stdout.contains("Usage: cargo test "));
100+
}
101+
102+
#[test]
103+
fn test_script_test_extra_args_for_test() {
104+
let out = rust_script!("--test", "tests/data/script-test-extra-args.rs", "--", "--nocapture").unwrap();
105+
assert!(out.success());
106+
assert!(out.stdout.contains("Hello, world!"));
107+
}
108+
95109
#[test]
96110
fn test_script_hyphens() {
97111
use scan_rules::scanner::QuotedString;

0 commit comments

Comments
 (0)