Skip to content

Bump ui_test to 0.22 #12198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ color-print = "0.3.4"
anstream = "0.5.0"

[dev-dependencies]
ui_test = "0.21.2"
ui_test = "0.22.1"
tester = "0.9"
regex = "1.5"
toml = "0.7.3"
Expand Down
41 changes: 24 additions & 17 deletions tests/compile-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#![warn(rust_2018_idioms, unused_lifetimes)]
#![allow(unused_extern_crates)]

use ui_test::{status_emitter, Args, CommandBuilder, Config, Match, Mode, OutputConflictHandling};
use ui_test::spanned::Spanned;
use ui_test::{status_emitter, Args, CommandBuilder, Config, Match, Mode};

use std::collections::BTreeMap;
use std::env::{self, set_var, var_os};
Expand Down Expand Up @@ -112,20 +113,21 @@ fn base_config(test_dir: &str) -> (Config, Args) {

let target_dir = PathBuf::from(var_os("CARGO_TARGET_DIR").unwrap_or_else(|| "target".into()));
let mut config = Config {
mode: Mode::Yolo {
rustfix: ui_test::RustfixMode::Everything,
},
filter_files: env::var("TESTNAME")
.map(|filters| filters.split(',').map(str::to_string).collect())
.unwrap_or_default(),
target: None,
bless_command: Some("cargo uibless".into()),
out_dir: target_dir.join("ui_test"),
..Config::rustc(Path::new("tests").join(test_dir))
};
config.with_args(&args, /* bless by default */ false);
if let OutputConflictHandling::Error(err) = &mut config.output_conflict_handling {
*err = "cargo uibless".into();
}
config.comment_defaults.base().mode = Some(Spanned::dummy(Mode::Yolo {
rustfix: ui_test::RustfixMode::Everything,
}))
.into();
config.comment_defaults.base().diagnostic_code_prefix = Some(Spanned::dummy("clippy::".into())).into();
config.filter(&format!("tests/{test_dir}"), "$$DIR");
config.with_args(&args);
let current_exe_path = env::current_exe().unwrap();
let deps_path = current_exe_path.parent().unwrap();
let profile_path = deps_path.parent().unwrap();
Expand Down Expand Up @@ -179,9 +181,7 @@ fn run_internal_tests() {
return;
}
let (mut config, args) = base_config("ui-internal");
if let OutputConflictHandling::Error(err) = &mut config.output_conflict_handling {
*err = "cargo uitest --features internal -- -- --bless".into();
}
config.bless_command = Some("cargo uitest --features internal -- -- --bless".into());

ui_test::run_tests_generic(
vec![config],
Expand All @@ -196,8 +196,10 @@ fn run_ui_toml() {
let (mut config, args) = base_config("ui-toml");

config
.stderr_filters
.push((Match::from(env::current_dir().unwrap().as_path()), b"$DIR"));
.comment_defaults
.base()
.normalize_stderr
.push((Match::from(env::current_dir().unwrap().as_path()), b"$DIR".into()));

ui_test::run_tests_generic(
vec![config],
Expand All @@ -213,6 +215,8 @@ fn run_ui_toml() {
.unwrap();
}

// Allow `Default::default` as `OptWithSpan` is not nameable
#[allow(clippy::default_trait_access)]
fn run_ui_cargo() {
if IS_RUSTC_TEST_SUITE {
return;
Expand All @@ -234,11 +238,13 @@ fn run_ui_cargo() {
} else {
"cargo-clippy"
});
config.edition = None;
config.comment_defaults.base().edition = Default::default();

config
.stderr_filters
.push((Match::from(env::current_dir().unwrap().as_path()), b"$DIR"));
.comment_defaults
.base()
.normalize_stderr
.push((Match::from(env::current_dir().unwrap().as_path()), b"$DIR".into()));

let ignored_32bit = |path: &Path| {
// FIXME: for some reason the modules are linted in a different order for this test
Expand All @@ -248,7 +254,8 @@ fn run_ui_cargo() {
ui_test::run_tests_generic(
vec![config],
|path, config| {
path.ends_with("Cargo.toml") && ui_test::default_any_file_filter(path, config) && !ignored_32bit(path)
path.ends_with("Cargo.toml")
.then(|| ui_test::default_any_file_filter(path, config) && !ignored_32bit(path))
},
|_config, _path, _file_contents| {},
status_emitter::Text::from(args.format),
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-cargo/multiple_config_files/warn/Cargo.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
warning: using config file `$DIR/$DIR/.clippy.toml`, `$DIR/$DIR/clippy.toml` will be ignored
warning: using config file `$DIR/$DIR/multiple_config_files/warn/.clippy.toml`, `$DIR/$DIR/multiple_config_files/warn/clippy.toml` will be ignored

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:40:5
--> $DIR/absolute_paths/absolute_paths.rs:40:5
|
LL | std::f32::MAX;
| ^^^^^^^^^^^^^
Expand All @@ -8,19 +8,19 @@ LL | std::f32::MAX;
= help: to override `-D warnings` add `#[allow(clippy::absolute_paths)]`

error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:41:5
--> $DIR/absolute_paths/absolute_paths.rs:41:5
|
LL | core::f32::MAX;
| ^^^^^^^^^^^^^^

error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:42:5
--> $DIR/absolute_paths/absolute_paths.rs:42:5
|
LL | ::core::f32::MAX;
| ^^^^^^^^^^^^^^^^

error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:58:5
--> $DIR/absolute_paths/absolute_paths.rs:58:5
|
LL | ::std::f32::MAX;
| ^^^^^^^^^^^^^^^
Expand Down
22 changes: 11 additions & 11 deletions tests/ui-toml/absolute_paths/absolute_paths.disallow_crates.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:40:5
--> $DIR/absolute_paths/absolute_paths.rs:40:5
|
LL | std::f32::MAX;
| ^^^^^^^^^^^^^
Expand All @@ -8,61 +8,61 @@ LL | std::f32::MAX;
= help: to override `-D warnings` add `#[allow(clippy::absolute_paths)]`

error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:41:5
--> $DIR/absolute_paths/absolute_paths.rs:41:5
|
LL | core::f32::MAX;
| ^^^^^^^^^^^^^^

error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:42:5
--> $DIR/absolute_paths/absolute_paths.rs:42:5
|
LL | ::core::f32::MAX;
| ^^^^^^^^^^^^^^^^

error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:43:5
--> $DIR/absolute_paths/absolute_paths.rs:43:5
|
LL | crate::a::b::c::C;
| ^^^^^^^^^^^^^^^^^

error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:44:5
--> $DIR/absolute_paths/absolute_paths.rs:44:5
|
LL | crate::a::b::c::d::e::f::F;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:45:5
--> $DIR/absolute_paths/absolute_paths.rs:45:5
|
LL | crate::a::A;
| ^^^^^^^^^^^

error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:46:5
--> $DIR/absolute_paths/absolute_paths.rs:46:5
|
LL | crate::a::b::B;
| ^^^^^^^^^^^^^^

error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:47:5
--> $DIR/absolute_paths/absolute_paths.rs:47:5
|
LL | crate::a::b::c::C::ZERO;
| ^^^^^^^^^^^^^^^^^

error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:48:5
--> $DIR/absolute_paths/absolute_paths.rs:48:5
|
LL | helper::b::c::d::e::f();
| ^^^^^^^^^^^^^^^^^^^^^

error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:49:5
--> $DIR/absolute_paths/absolute_paths.rs:49:5
|
LL | ::helper::b::c::d::e::f();
| ^^^^^^^^^^^^^^^^^^^^^^^

error: consider bringing this path into scope with the `use` keyword
--> $DIR/absolute_paths.rs:58:5
--> $DIR/absolute_paths/absolute_paths.rs:58:5
|
LL | ::std::f32::MAX;
| ^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: variables can be used directly in the `format!` string
--> $DIR/uninlined_format_args.rs:9:5
--> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:9:5
|
LL | println!("val='{}'", local_i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -13,7 +13,7 @@ LL + println!("val='{local_i32}'");
|

error: variables can be used directly in the `format!` string
--> $DIR/uninlined_format_args.rs:10:5
--> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:10:5
|
LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -25,7 +25,7 @@ LL + println!("Hello {} is {local_f64:.local_i32$}", "x");
|

error: literal with an empty format string
--> $DIR/uninlined_format_args.rs:10:35
--> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:10:35
|
LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64);
| ^^^
Expand All @@ -39,7 +39,7 @@ LL + println!("Hello x is {:.*}", local_i32, local_f64);
|

error: variables can be used directly in the `format!` string
--> $DIR/uninlined_format_args.rs:11:5
--> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:11:5
|
LL | println!("Hello {} is {:.*}", local_i32, 5, local_f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -51,7 +51,7 @@ LL + println!("Hello {local_i32} is {local_f64:.*}", 5);
|

error: variables can be used directly in the `format!` string
--> $DIR/uninlined_format_args.rs:12:5
--> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:12:5
|
LL | println!("Hello {} is {2:.*}", local_i32, 5, local_f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -63,7 +63,7 @@ LL + println!("Hello {local_i32} is {local_f64:.*}", 5);
|

error: variables can be used directly in the `format!` string
--> $DIR/uninlined_format_args.rs:13:5
--> $DIR/allow_mixed_uninlined_format_args/uninlined_format_args.rs:13:5
|
LL | println!("{}, {}", local_i32, local_opt.unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: arithmetic operation that can potentially result in unexpected side-effects
--> $DIR/arithmetic_side_effects_allowed.rs:69:13
--> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:69:13
|
LL | let _ = Baz + Baz;
| ^^^^^^^^^
Expand All @@ -8,49 +8,49 @@ LL | let _ = Baz + Baz;
= help: to override `-D warnings` add `#[allow(clippy::arithmetic_side_effects)]`

error: arithmetic operation that can potentially result in unexpected side-effects
--> $DIR/arithmetic_side_effects_allowed.rs:80:13
--> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:80:13
|
LL | let _ = 1i32 + Baz;
| ^^^^^^^^^^

error: arithmetic operation that can potentially result in unexpected side-effects
--> $DIR/arithmetic_side_effects_allowed.rs:83:13
--> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:83:13
|
LL | let _ = 1i64 + Foo;
| ^^^^^^^^^^

error: arithmetic operation that can potentially result in unexpected side-effects
--> $DIR/arithmetic_side_effects_allowed.rs:87:13
--> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:87:13
|
LL | let _ = 1i64 + Baz;
| ^^^^^^^^^^

error: arithmetic operation that can potentially result in unexpected side-effects
--> $DIR/arithmetic_side_effects_allowed.rs:98:13
--> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:98:13
|
LL | let _ = Baz + 1i32;
| ^^^^^^^^^^

error: arithmetic operation that can potentially result in unexpected side-effects
--> $DIR/arithmetic_side_effects_allowed.rs:101:13
--> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:101:13
|
LL | let _ = Foo + 1i64;
| ^^^^^^^^^^

error: arithmetic operation that can potentially result in unexpected side-effects
--> $DIR/arithmetic_side_effects_allowed.rs:105:13
--> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:105:13
|
LL | let _ = Baz + 1i64;
| ^^^^^^^^^^

error: arithmetic operation that can potentially result in unexpected side-effects
--> $DIR/arithmetic_side_effects_allowed.rs:114:13
--> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:114:13
|
LL | let _ = -Bar;
| ^^^^

error: arithmetic operation that can potentially result in unexpected side-effects
--> $DIR/arithmetic_side_effects_allowed.rs:116:13
--> $DIR/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs:116:13
|
LL | let _ = -Baz;
| ^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: large array defined as const
--> $DIR/array_size_threshold.rs:4:1
--> $DIR/array_size_threshold/array_size_threshold.rs:4:1
|
LL | const ABOVE: [u8; 11] = [0; 11];
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -10,7 +10,7 @@ LL | const ABOVE: [u8; 11] = [0; 11];
= help: to override `-D warnings` add `#[allow(clippy::large_const_arrays)]`

error: allocating a local array larger than 10 bytes
--> $DIR/array_size_threshold.rs:4:25
--> $DIR/array_size_threshold/array_size_threshold.rs:4:25
|
LL | const ABOVE: [u8; 11] = [0; 11];
| ^^^^^^^
Expand All @@ -20,7 +20,7 @@ LL | const ABOVE: [u8; 11] = [0; 11];
= help: to override `-D warnings` add `#[allow(clippy::large_stack_arrays)]`

error: allocating a local array larger than 10 bytes
--> $DIR/array_size_threshold.rs:8:17
--> $DIR/array_size_threshold/array_size_threshold.rs:8:17
|
LL | let above = [0u8; 11];
| ^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `std::string::String` may not be held across an `await` point per `clippy.toml`
--> $DIR/await_holding_invalid_type.rs:5:9
--> $DIR/await_holding_invalid_type/await_holding_invalid_type.rs:5:9
|
LL | let _x = String::from("hello");
| ^^
Expand All @@ -9,13 +9,13 @@ LL | let _x = String::from("hello");
= help: to override `-D warnings` add `#[allow(clippy::await_holding_invalid_type)]`

error: `std::net::Ipv4Addr` may not be held across an `await` point per `clippy.toml`
--> $DIR/await_holding_invalid_type.rs:10:9
--> $DIR/await_holding_invalid_type/await_holding_invalid_type.rs:10:9
|
LL | let x = Ipv4Addr::new(127, 0, 0, 1);
| ^

error: `std::string::String` may not be held across an `await` point per `clippy.toml`
--> $DIR/await_holding_invalid_type.rs:33:13
--> $DIR/await_holding_invalid_type/await_holding_invalid_type.rs:33:13
|
LL | let _x = String::from("hi!");
| ^^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-toml/bad_toml/conf_bad_toml.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: error reading Clippy's configuration file: expected `.`, `=`
--> $DIR/$DIR/clippy.toml:1:4
--> $DIR/$DIR/bad_toml/clippy.toml:1:4
|
LL | fn this_is_obviously(not: a, toml: file) {
| ^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-toml/bad_toml_type/conf_bad_type.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: error reading Clippy's configuration file: invalid type: integer `42`, expected a sequence
--> $DIR/$DIR/clippy.toml:1:20
--> $DIR/$DIR/bad_toml_type/clippy.toml:1:20
|
LL | disallowed-names = 42
| ^^
Expand Down
Loading