Skip to content

Commit

Permalink
Config option for cap_lints
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcefrog committed Jul 14, 2024
1 parent cb6ab91 commit 670aa14
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
/// Generate mutants from source files matching these globs.
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>,

/// Print mutants that were caught by tests.
#[arg(long, short = 'v', help_heading = "Output")]
Expand Down
7 changes: 5 additions & 2 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -362,16 +363,18 @@ 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();
let args = Args::parse_from(["mutants"]);
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]
Expand Down

0 comments on commit 670aa14

Please sign in to comment.