Skip to content

Commit 9c48465

Browse files
committed
Update ui test crate to auto-detect aux build crate kind
1 parent 65aff11 commit 9c48465

File tree

144 files changed

+228
-327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+228
-327
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ tempfile = { version = "3.2", optional = true }
2727
termize = "0.1"
2828

2929
[dev-dependencies]
30-
ui_test = "0.12"
30+
ui_test = "0.13"
3131
tester = "0.9"
3232
regex = "1.5"
3333
toml = "0.7.3"

tests/compile-test.rs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const RUN_INTERNAL_TESTS: bool = cfg!(feature = "internal");
113113
fn base_config(test_dir: &str) -> (compiletest::Config, Args) {
114114
let args = Args::test();
115115
let mut config = compiletest::Config {
116-
mode: TestMode::Yolo,
116+
mode: TestMode::Yolo { rustfix: true },
117117
stderr_filters: vec![],
118118
stdout_filters: vec![],
119119
output_conflict_handling: if var_os("GITHUB_ACTION").is_none()
@@ -124,7 +124,10 @@ fn base_config(test_dir: &str) -> (compiletest::Config, Args) {
124124
OutputConflictHandling::Error("cargo uibless".into())
125125
},
126126
target: None,
127-
out_dir: PathBuf::from(std::env::var_os("CARGO_TARGET_DIR").unwrap_or("target".into())).join("ui_test"),
127+
out_dir: PathBuf::from(std::env::var_os("CARGO_TARGET_DIR").unwrap_or("target".into()))
128+
.join("ui_test")
129+
.canonicalize()
130+
.unwrap(),
128131
..compiletest::Config::rustc(Path::new("tests").join(test_dir))
129132
};
130133
let current_exe_path = env::current_exe().unwrap();
@@ -187,12 +190,18 @@ fn run_ui() {
187190

188191
let test_filter = test_filter();
189192

193+
let quiet = args.quiet;
194+
190195
compiletest::run_tests_generic(
191196
config,
192197
args,
193198
move |path, args| compiletest::default_file_filter(path, args) && test_filter(path),
194199
compiletest::default_per_file_config,
195-
status_emitter::Text::verbose(),
200+
if quiet {
201+
status_emitter::Text::quiet()
202+
} else {
203+
status_emitter::Text::verbose()
204+
},
196205
)
197206
.unwrap();
198207
}
@@ -207,13 +216,18 @@ fn run_internal_tests() {
207216
*err = "cargo uitest --features internal".into();
208217
}
209218
let test_filter = test_filter();
219+
let quiet = args.quiet;
210220

211221
compiletest::run_tests_generic(
212222
config,
213223
args,
214224
move |path, args| compiletest::default_file_filter(path, args) && test_filter(path),
215225
compiletest::default_per_file_config,
216-
status_emitter::Text::verbose(),
226+
if quiet {
227+
status_emitter::Text::quiet()
228+
} else {
229+
status_emitter::Text::verbose()
230+
},
217231
)
218232
.unwrap();
219233
}
@@ -235,6 +249,7 @@ fn run_ui_toml() {
235249
);
236250

237251
let test_filter = test_filter();
252+
let quiet = args.quiet;
238253

239254
ui_test::run_tests_generic(
240255
config,
@@ -248,7 +263,11 @@ fn run_ui_toml() {
248263
.push(("CLIPPY_CONF_DIR".into(), Some(path.parent().unwrap().into())));
249264
Some(config)
250265
},
251-
status_emitter::Text::verbose(),
266+
if quiet {
267+
status_emitter::Text::quiet()
268+
} else {
269+
status_emitter::Text::verbose()
270+
},
252271
)
253272
.unwrap();
254273
}
@@ -290,6 +309,7 @@ fn run_ui_cargo() {
290309
);
291310

292311
let test_filter = test_filter();
312+
let quiet = args.quiet;
293313

294314
ui_test::run_tests_generic(
295315
config,
@@ -300,7 +320,11 @@ fn run_ui_cargo() {
300320
config.out_dir = PathBuf::from("target/ui_test_cargo/").join(path.parent().unwrap());
301321
Some(config)
302322
},
303-
status_emitter::Text::verbose(),
323+
if quiet {
324+
status_emitter::Text::quiet()
325+
} else {
326+
status_emitter::Text::verbose()
327+
},
304328
)
305329
.unwrap();
306330
}

tests/ui-internal/collapsible_span_lint_calls.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#![deny(clippy::internal)]
32
#![allow(clippy::missing_clippy_version_attribute)]
43
#![feature(rustc_private)]

tests/ui-internal/collapsible_span_lint_calls.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
error: this call is collapsible
2-
--> $DIR/collapsible_span_lint_calls.rs:36:9
2+
--> $DIR/collapsible_span_lint_calls.rs:35:9
33
|
44
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
55
LL | | db.span_suggestion(expr.span, help_msg, sugg.to_string(), Applicability::MachineApplicable);
66
LL | | });
77
| |__________^ help: collapse into: `span_lint_and_sugg(cx, TEST_LINT, expr.span, lint_msg, help_msg, sugg.to_string(), Applicability::MachineApplicable)`
88
|
99
note: the lint level is defined here
10-
--> $DIR/collapsible_span_lint_calls.rs:2:9
10+
--> $DIR/collapsible_span_lint_calls.rs:1:9
1111
|
1212
LL | #![deny(clippy::internal)]
1313
| ^^^^^^^^^^^^^^^^
1414
= note: `#[deny(clippy::collapsible_span_lint_calls)]` implied by `#[deny(clippy::internal)]`
1515

1616
error: this call is collapsible
17-
--> $DIR/collapsible_span_lint_calls.rs:39:9
17+
--> $DIR/collapsible_span_lint_calls.rs:38:9
1818
|
1919
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
2020
LL | | db.span_help(expr.span, help_msg);
2121
LL | | });
2222
| |__________^ help: collapse into: `span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), help_msg)`
2323

2424
error: this call is collapsible
25-
--> $DIR/collapsible_span_lint_calls.rs:42:9
25+
--> $DIR/collapsible_span_lint_calls.rs:41:9
2626
|
2727
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
2828
LL | | db.help(help_msg);
2929
LL | | });
3030
| |__________^ help: collapse into: `span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, None, help_msg)`
3131

3232
error: this call is collapsible
33-
--> $DIR/collapsible_span_lint_calls.rs:45:9
33+
--> $DIR/collapsible_span_lint_calls.rs:44:9
3434
|
3535
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
3636
LL | | db.span_note(expr.span, note_msg);
3737
LL | | });
3838
| |__________^ help: collapse into: `span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), note_msg)`
3939

4040
error: this call is collapsible
41-
--> $DIR/collapsible_span_lint_calls.rs:48:9
41+
--> $DIR/collapsible_span_lint_calls.rs:47:9
4242
|
4343
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
4444
LL | | db.note(note_msg);

tests/ui-internal/interning_defined_symbol.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#![deny(clippy::internal)]
32
#![allow(clippy::missing_clippy_version_attribute, clippy::let_unit_value)]
43
#![feature(rustc_private)]

tests/ui-internal/interning_defined_symbol.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
error: interning a defined symbol
2-
--> $DIR/interning_defined_symbol.rs:18:13
2+
--> $DIR/interning_defined_symbol.rs:17:13
33
|
44
LL | let _ = Symbol::intern("f32");
55
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::f32`
66
|
77
note: the lint level is defined here
8-
--> $DIR/interning_defined_symbol.rs:2:9
8+
--> $DIR/interning_defined_symbol.rs:1:9
99
|
1010
LL | #![deny(clippy::internal)]
1111
| ^^^^^^^^^^^^^^^^
1212
= note: `#[deny(clippy::interning_defined_symbol)]` implied by `#[deny(clippy::internal)]`
1313

1414
error: interning a defined symbol
15-
--> $DIR/interning_defined_symbol.rs:21:13
15+
--> $DIR/interning_defined_symbol.rs:20:13
1616
|
1717
LL | let _ = sym!(f32);
1818
| ^^^^^^^^^ help: try: `rustc_span::sym::f32`
1919

2020
error: interning a defined symbol
21-
--> $DIR/interning_defined_symbol.rs:24:13
21+
--> $DIR/interning_defined_symbol.rs:23:13
2222
|
2323
LL | let _ = Symbol::intern("proc-macro");
2424
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::proc_dash_macro`
2525

2626
error: interning a defined symbol
27-
--> $DIR/interning_defined_symbol.rs:27:13
27+
--> $DIR/interning_defined_symbol.rs:26:13
2828
|
2929
LL | let _ = Symbol::intern("self");
3030
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::symbol::kw::SelfLower`

tests/ui-internal/invalid_msrv_attr_impl.fixed

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
#![deny(clippy::internal)]
42
#![allow(clippy::missing_clippy_version_attribute)]
53
#![feature(rustc_private)]

tests/ui-internal/invalid_msrv_attr_impl.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: `extract_msrv_attr!` macro missing from `LateLintPass` implementation
2-
--> $DIR/invalid_msrv_attr_impl.rs:30:1
2+
--> $DIR/invalid_msrv_attr_impl.rs:28:1
33
|
44
LL | impl LateLintPass<'_> for Pass {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
note: the lint level is defined here
8-
--> $DIR/invalid_msrv_attr_impl.rs:3:9
8+
--> $DIR/invalid_msrv_attr_impl.rs:1:9
99
|
1010
LL | #![deny(clippy::internal)]
1111
| ^^^^^^^^^^^^^^^^
@@ -17,7 +17,7 @@ LL + extract_msrv_attr!(LateContext);
1717
|
1818

1919
error: `extract_msrv_attr!` macro missing from `EarlyLintPass` implementation
20-
--> $DIR/invalid_msrv_attr_impl.rs:34:1
20+
--> $DIR/invalid_msrv_attr_impl.rs:32:1
2121
|
2222
LL | impl EarlyLintPass for Pass {
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui-internal/outer_expn_data.fixed

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
#![deny(clippy::internal)]
42
#![allow(clippy::missing_clippy_version_attribute)]
53
#![feature(rustc_private)]

tests/ui-internal/outer_expn_data.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: usage of `outer_expn().expn_data()`
2-
--> $DIR/outer_expn_data.rs:25:34
2+
--> $DIR/outer_expn_data.rs:23:34
33
|
44
LL | let _ = expr.span.ctxt().outer_expn().expn_data();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `outer_expn_data()`
66
|
77
note: the lint level is defined here
8-
--> $DIR/outer_expn_data.rs:3:9
8+
--> $DIR/outer_expn_data.rs:1:9
99
|
1010
LL | #![deny(clippy::internal)]
1111
| ^^^^^^^^^^^^^^^^

tests/ui-internal/unnecessary_def_path.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
//@aux-build:paths.rs
32
#![deny(clippy::internal)]
43
#![feature(rustc_private)]

tests/ui-internal/unnecessary_def_path.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,98 @@
11
error: use of a def path to a diagnostic item
2-
--> $DIR/unnecessary_def_path.rs:37:13
2+
--> $DIR/unnecessary_def_path.rs:36:13
33
|
44
LL | let _ = match_type(cx, ty, &OPTION);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Option)`
66
|
77
note: the lint level is defined here
8-
--> $DIR/unnecessary_def_path.rs:3:9
8+
--> $DIR/unnecessary_def_path.rs:2:9
99
|
1010
LL | #![deny(clippy::internal)]
1111
| ^^^^^^^^^^^^^^^^
1212
= note: `#[deny(clippy::unnecessary_def_path)]` implied by `#[deny(clippy::internal)]`
1313

1414
error: use of a def path to a diagnostic item
15-
--> $DIR/unnecessary_def_path.rs:38:13
15+
--> $DIR/unnecessary_def_path.rs:37:13
1616
|
1717
LL | let _ = match_type(cx, ty, RESULT);
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)`
1919

2020
error: use of a def path to a diagnostic item
21-
--> $DIR/unnecessary_def_path.rs:39:13
21+
--> $DIR/unnecessary_def_path.rs:38:13
2222
|
2323
LL | let _ = match_type(cx, ty, &["core", "result", "Result"]);
2424
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)`
2525

2626
error: use of a def path to a diagnostic item
27-
--> $DIR/unnecessary_def_path.rs:43:13
27+
--> $DIR/unnecessary_def_path.rs:42:13
2828
|
2929
LL | let _ = clippy_utils::ty::match_type(cx, ty, rc_path);
3030
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Rc)`
3131

3232
error: use of a def path to a diagnostic item
33-
--> $DIR/unnecessary_def_path.rs:45:13
33+
--> $DIR/unnecessary_def_path.rs:44:13
3434
|
3535
LL | let _ = match_type(cx, ty, &paths::OPTION);
3636
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Option)`
3737

3838
error: use of a def path to a diagnostic item
39-
--> $DIR/unnecessary_def_path.rs:46:13
39+
--> $DIR/unnecessary_def_path.rs:45:13
4040
|
4141
LL | let _ = match_type(cx, ty, paths::RESULT);
4242
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)`
4343

4444
error: use of a def path to a `LangItem`
45-
--> $DIR/unnecessary_def_path.rs:48:13
45+
--> $DIR/unnecessary_def_path.rs:47:13
4646
|
4747
LL | let _ = match_type(cx, ty, &["alloc", "boxed", "Box"]);
4848
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_lang_item(cx, ty, LangItem::OwnedBox)`
4949

5050
error: use of a def path to a diagnostic item
51-
--> $DIR/unnecessary_def_path.rs:49:13
51+
--> $DIR/unnecessary_def_path.rs:48:13
5252
|
5353
LL | let _ = match_type(cx, ty, &["core", "mem", "maybe_uninit", "MaybeUninit", "uninit"]);
5454
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::maybe_uninit_uninit)`
5555

5656
error: use of a def path to a `LangItem`
57-
--> $DIR/unnecessary_def_path.rs:51:13
57+
--> $DIR/unnecessary_def_path.rs:50:13
5858
|
5959
LL | let _ = match_def_path(cx, did, &["alloc", "boxed", "Box"]);
6060
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.lang_items().get(LangItem::OwnedBox) == Some(did)`
6161

6262
error: use of a def path to a diagnostic item
63-
--> $DIR/unnecessary_def_path.rs:52:13
63+
--> $DIR/unnecessary_def_path.rs:51:13
6464
|
6565
LL | let _ = match_def_path(cx, did, &["core", "option", "Option"]);
6666
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.is_diagnostic_item(sym::Option, did)`
6767

6868
error: use of a def path to a `LangItem`
69-
--> $DIR/unnecessary_def_path.rs:53:13
69+
--> $DIR/unnecessary_def_path.rs:52:13
7070
|
7171
LL | let _ = match_def_path(cx, did, &["core", "option", "Option", "Some"]);
7272
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.lang_items().get(LangItem::OptionSome) == Some(did)`
7373
|
7474
= help: if this `DefId` came from a constructor expression or pattern then the parent `DefId` should be used instead
7575

7676
error: use of a def path to a diagnostic item
77-
--> $DIR/unnecessary_def_path.rs:55:13
77+
--> $DIR/unnecessary_def_path.rs:54:13
7878
|
7979
LL | let _ = match_trait_method(cx, expr, &["core", "convert", "AsRef"]);
8080
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_trait_method(cx, expr, sym::AsRef)`
8181

8282
error: use of a def path to a diagnostic item
83-
--> $DIR/unnecessary_def_path.rs:57:13
83+
--> $DIR/unnecessary_def_path.rs:56:13
8484
|
8585
LL | let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option"]);
8686
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_path_diagnostic_item(cx, expr, sym::Option)`
8787

8888
error: use of a def path to a `LangItem`
89-
--> $DIR/unnecessary_def_path.rs:58:13
89+
--> $DIR/unnecessary_def_path.rs:57:13
9090
|
9191
LL | let _ = is_expr_path_def_path(cx, expr, &["core", "iter", "traits", "Iterator", "next"]);
9292
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `path_res(cx, expr).opt_def_id().map_or(false, |id| cx.tcx.lang_items().get(LangItem::IteratorNext) == Some(id))`
9393

9494
error: use of a def path to a `LangItem`
95-
--> $DIR/unnecessary_def_path.rs:59:13
95+
--> $DIR/unnecessary_def_path.rs:58:13
9696
|
9797
LL | let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option", "Some"]);
9898
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_res_lang_ctor(cx, path_res(cx, expr), LangItem::OptionSome)`

tests/ui-internal/unnecessary_symbol_str.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#![feature(rustc_private)]
32
#![deny(clippy::internal)]
43
#![allow(

0 commit comments

Comments
 (0)