Skip to content

Commit 0841f6e

Browse files
Don't make ui test annotations madatory for ui-cargo
1 parent 3053bad commit 0841f6e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/compile-test.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl TestContext {
139139
}
140140
}
141141

142-
fn base_config(&self, test_dir: &str) -> Config {
142+
fn base_config(&self, test_dir: &str, mandatory_annotations: bool) -> Config {
143143
let target_dir = PathBuf::from(var_os("CARGO_TARGET_DIR").unwrap_or_else(|| "target".into()));
144144
let mut config = Config {
145145
output_conflict_handling: OutputConflictHandling::Error,
@@ -153,7 +153,11 @@ impl TestContext {
153153
};
154154
let defaults = config.comment_defaults.base();
155155
defaults.exit_status = None.into();
156-
defaults.require_annotations = Some(Spanned::dummy(true)).into();
156+
if mandatory_annotations {
157+
defaults.require_annotations = Some(Spanned::dummy(true)).into();
158+
} else {
159+
defaults.require_annotations = None.into();
160+
}
157161
defaults.diagnostic_code_prefix = Some(Spanned::dummy("clippy::".into())).into();
158162
defaults.set_custom("rustfix", RustfixMode::Everything);
159163
if let Some(collector) = self.diagnostic_collector.clone() {
@@ -197,7 +201,7 @@ impl TestContext {
197201
}
198202

199203
fn run_ui(cx: &TestContext) {
200-
let mut config = cx.base_config("ui");
204+
let mut config = cx.base_config("ui", true);
201205
config
202206
.program
203207
.envs
@@ -216,7 +220,7 @@ fn run_internal_tests(cx: &TestContext) {
216220
if !RUN_INTERNAL_TESTS {
217221
return;
218222
}
219-
let mut config = cx.base_config("ui-internal");
223+
let mut config = cx.base_config("ui-internal", true);
220224
config.bless_command = Some("cargo uitest --features internal -- -- --bless".into());
221225

222226
ui_test::run_tests_generic(
@@ -229,7 +233,7 @@ fn run_internal_tests(cx: &TestContext) {
229233
}
230234

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

234238
config
235239
.comment_defaults
@@ -259,7 +263,7 @@ fn run_ui_cargo(cx: &TestContext) {
259263
return;
260264
}
261265

262-
let mut config = cx.base_config("ui-cargo");
266+
let mut config = cx.base_config("ui-cargo", false);
263267
config.program.input_file_flag = CommandBuilder::cargo().input_file_flag;
264268
config.program.out_dir_flag = CommandBuilder::cargo().out_dir_flag;
265269
config.program.args = vec!["clippy".into(), "--color".into(), "never".into(), "--quiet".into()];

0 commit comments

Comments
 (0)