diff --git a/src/main.rs b/src/main.rs index 79bb165..8747c08 100644 --- a/src/main.rs +++ b/src/main.rs @@ -477,6 +477,8 @@ impl InputAction { } else { return Err(MainError::OtherOwned("Could not execute cargo".to_string())); } + } else { + cmd.args(script_args.iter()); } Ok(cmd) diff --git a/tests/data/script-test-extra-args.rs b/tests/data/script-test-extra-args.rs new file mode 100644 index 0000000..2fad4ea --- /dev/null +++ b/tests/data/script-test-extra-args.rs @@ -0,0 +1,4 @@ +fn main() {} + +#[test] +fn test() { println!("Hello, world!"); } diff --git a/tests/tests/script.rs b/tests/tests/script.rs index 73bdb51..cddde8e 100644 --- a/tests/tests/script.rs +++ b/tests/tests/script.rs @@ -91,6 +91,20 @@ fn test_script_test() { assert!(out.success()); } +#[test] +fn test_script_test_extra_args_for_cargo() { + let out = rust_script!("--test", "tests/data/script-test-extra-args.rs", "--help").unwrap(); + assert!(out.success()); + assert!(out.stdout.contains("Usage: cargo test ")); +} + +#[test] +fn test_script_test_extra_args_for_test() { + let out = rust_script!("--test", "tests/data/script-test-extra-args.rs", "--", "--nocapture").unwrap(); + assert!(out.success()); + assert!(out.stdout.contains("Hello, world!")); +} + #[test] fn test_script_hyphens() { use scan_rules::scanner::QuotedString;