Skip to content

Commit

Permalink
Don't make ui test annotations madatory for ui-cargo
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Feb 15, 2025
1 parent 3053bad commit 0841f6e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/compile-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl TestContext {
}
}

fn base_config(&self, test_dir: &str) -> Config {
fn base_config(&self, test_dir: &str, mandatory_annotations: bool) -> Config {
let target_dir = PathBuf::from(var_os("CARGO_TARGET_DIR").unwrap_or_else(|| "target".into()));
let mut config = Config {
output_conflict_handling: OutputConflictHandling::Error,
Expand All @@ -153,7 +153,11 @@ impl TestContext {
};
let defaults = config.comment_defaults.base();
defaults.exit_status = None.into();
defaults.require_annotations = Some(Spanned::dummy(true)).into();
if mandatory_annotations {
defaults.require_annotations = Some(Spanned::dummy(true)).into();
} else {
defaults.require_annotations = None.into();
}
defaults.diagnostic_code_prefix = Some(Spanned::dummy("clippy::".into())).into();
defaults.set_custom("rustfix", RustfixMode::Everything);
if let Some(collector) = self.diagnostic_collector.clone() {
Expand Down Expand Up @@ -197,7 +201,7 @@ impl TestContext {
}

fn run_ui(cx: &TestContext) {
let mut config = cx.base_config("ui");
let mut config = cx.base_config("ui", true);
config
.program
.envs
Expand All @@ -216,7 +220,7 @@ fn run_internal_tests(cx: &TestContext) {
if !RUN_INTERNAL_TESTS {
return;
}
let mut config = cx.base_config("ui-internal");
let mut config = cx.base_config("ui-internal", true);
config.bless_command = Some("cargo uitest --features internal -- -- --bless".into());

ui_test::run_tests_generic(
Expand All @@ -229,7 +233,7 @@ fn run_internal_tests(cx: &TestContext) {
}

fn run_ui_toml(cx: &TestContext) {
let mut config = cx.base_config("ui-toml");
let mut config = cx.base_config("ui-toml", true);

config
.comment_defaults
Expand Down Expand Up @@ -259,7 +263,7 @@ fn run_ui_cargo(cx: &TestContext) {
return;
}

let mut config = cx.base_config("ui-cargo");
let mut config = cx.base_config("ui-cargo", false);
config.program.input_file_flag = CommandBuilder::cargo().input_file_flag;
config.program.out_dir_flag = CommandBuilder::cargo().out_dir_flag;
config.program.args = vec!["clippy".into(), "--color".into(), "never".into(), "--quiet".into()];
Expand Down

0 comments on commit 0841f6e

Please sign in to comment.