diff --git a/NEWS.md b/NEWS.md index 34aa827f..6fc30dde 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,8 @@ - Changed: `--timeout-multiplier` now overrides `timeout_multiplier` from `.cargo/mutants.toml`. +- Changed: `--timeout` and `--timeout-multiplier` are now conflicting options. + ## 24.3.0 - Fixed: `cargo install cargo-mutants` without `--locked` was failing due to breaking API changes in some unstable dependencies. diff --git a/src/main.rs b/src/main.rs index e9418fff..deb22f86 100644 --- a/src/main.rs +++ b/src/main.rs @@ -287,7 +287,7 @@ pub struct Args { timeout: Option, /// test timeout multiplier (relative to base test time). - #[arg(long, help_heading = "Execution")] + #[arg(long, help_heading = "Execution", conflicts_with = "timeout")] timeout_multiplier: Option, /// maximum run time for cargo build command, in seconds. @@ -295,7 +295,7 @@ pub struct Args { build_timeout: Option, /// build timeout multiplier (relative to base build time). - #[arg(long, help_heading = "Execution")] + #[arg(long, help_heading = "Execution", conflicts_with = "build_timeout")] build_timeout_multiplier: Option, /// print mutations that failed to check or build. diff --git a/src/options.rs b/src/options.rs index 90bef6f9..6902eccd 100644 --- a/src/options.rs +++ b/src/options.rs @@ -337,6 +337,26 @@ mod test { assert_eq!(options.build_timeout_multiplier, Some(1.0)); } + #[test] + fn conflicting_timeout_options() { + let args = Args::try_parse_from(["mutants", "--timeout=1", "--timeout-multiplier=1"]) + .expect_err("--timeout and --timeout-multiplier should conflict"); + let rendered = format!("{}", args.render()); + assert!(rendered.contains("error: the argument '--timeout ' cannot be used with '--timeout-multiplier '")); + } + + #[test] + fn conflicting_build_timeout_options() { + let args = Args::try_parse_from([ + "mutants", + "--build-timeout=1", + "--build-timeout-multiplier=1", + ]) + .expect_err("--build-timeout and --build-timeout-multiplier should conflict"); + let rendered = format!("{}", args.render()); + assert!(rendered.contains("error: the argument '--build-timeout ' cannot be used with '--build-timeout-multiplier '")); + } + #[test] fn test_tool_from_config() { let config = indoc! { r#"