Skip to content

Update ui_test to 0.22 #12289

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

Closed
wants to merge 1 commit into from
Closed
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.0"
tester = "0.9"
regex = "1.5"
toml = "0.7.3"
Expand Down
41 changes: 25 additions & 16 deletions tests/compile-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#![warn(rust_2018_idioms, unused_lifetimes)]
#![allow(unused_extern_crates)]

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

use std::collections::BTreeMap;
Expand Down Expand Up @@ -112,20 +113,22 @@ 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,
out_dir: target_dir.join("ui_test"),
output_conflict_handling: OutputConflictHandling::Error,
bless_command: Some("cargo uibless".into()),
..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();
}
let comment_base = config.comment_defaults.base();
comment_base.mode = Spanned::dummy(Mode::Yolo {
rustfix: ui_test::RustfixMode::Everything,
})
.into();
comment_base.diagnostic_code_prefix = Spanned::dummy(String::from("clippy::")).into();
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 +182,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 +197,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()), Vec::from(b"$DIR")));

ui_test::run_tests_generic(
vec![config],
Expand Down Expand Up @@ -234,11 +237,13 @@ fn run_ui_cargo() {
} else {
"cargo-clippy"
});
config.edition = None;
config.comment_defaults.base().edition = None.into();

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()), Vec::from(b"$DIR")));

let ignored_32bit = |path: &Path| {
// FIXME: for some reason the modules are linted in a different order for this test
Expand All @@ -248,7 +253,11 @@ 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)
if path.ends_with("Cargo.toml") {
Some(ui_test::default_any_file_filter(path, config) && !ignored_32bit(path))
} else {
None
}
},
|_config, _path, _file_contents| {},
status_emitter::Text::from(args.format),
Expand Down