diff --git a/src/config.rs b/src/config.rs index 96cdd71b..5209f3b5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -27,6 +27,8 @@ use crate::Result; #[derive(Debug, Default, Clone, Deserialize)] #[serde(default, deny_unknown_fields)] pub struct Config { + /// Pass `--cap-lints` to rustc. + pub cap_lints: bool, /// Generate these error values from functions returning Result. pub error_values: Vec, /// Generate mutants from source files matching these globs. diff --git a/src/main.rs b/src/main.rs index 5f91e44c..18b11417 100644 --- a/src/main.rs +++ b/src/main.rs @@ -117,8 +117,8 @@ pub struct Args { baseline: BaselineStrategy, /// Turn off all rustc lints, so that denied warnings won't make mutants unviable. - #[arg(long, action = ArgAction::Set, default_value_t = false, help_heading = "Build")] - cap_lints: bool, + #[arg(long, action = ArgAction::Set, help_heading = "Build")] + cap_lints: Option, /// Print mutants that were caught by tests. #[arg(long, short = 'v', help_heading = "Output")] diff --git a/src/options.rs b/src/options.rs index 34422e39..170851a7 100644 --- a/src/options.rs +++ b/src/options.rs @@ -199,7 +199,7 @@ impl Options { &config.additional_cargo_test_args, ), baseline: args.baseline, - cap_lints: args.cap_lints, + cap_lints: args.cap_lints.unwrap_or(config.cap_lints), check_only: args.check, colors: args.colors, emit_json: args.json, @@ -274,6 +274,7 @@ mod test { let options = Options::new(&args, &Config::default()).unwrap(); assert!(!options.check_only); assert_eq!(options.test_tool, TestTool::Cargo); + assert!(!options.cap_lints); } #[test] @@ -362,9 +363,10 @@ mod test { } #[test] - fn test_tool_from_config() { + fn from_config() { let config = indoc! { r#" test_tool = "nextest" + cap_lints = true "#}; let mut config_file = NamedTempFile::new().unwrap(); config_file.write_all(config.as_bytes()).unwrap(); @@ -372,6 +374,7 @@ mod test { let config = Config::read_file(config_file.path()).unwrap(); let options = Options::new(&args, &config).unwrap(); assert_eq!(options.test_tool, TestTool::Nextest); + assert!(options.cap_lints); } #[test]