Skip to content

Commit feeeba2

Browse files
committed
Auto merge of #2521 - oli-obk:bump_ui_test, r=RalfJung
Bump UI test dependency This gives us the new diff renderer as well as the ability to run tests without parallelism if we'd want to.
2 parents da45adc + 240f92a commit feeeba2

File tree

3 files changed

+50
-94
lines changed

3 files changed

+50
-94
lines changed

Cargo.lock

+5-45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ libc = "0.2"
4040

4141
[dev-dependencies]
4242
colored = "2"
43-
ui_test = "0.1"
43+
ui_test = "0.3.1"
4444
# Features chosen to match those required by env_logger, to avoid rebuilds
4545
regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] }
4646
lazy_static = "1.4.0"

tests/compiletest.rs

+44-48
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use colored::*;
22
use regex::Regex;
33
use std::path::{Path, PathBuf};
4-
use std::{env, ffi::OsString, process::Command};
5-
use ui_test::{color_eyre::Result, Config, DependencyBuilder, Mode, OutputConflictHandling};
4+
use std::{env, process::Command};
5+
use ui_test::{color_eyre::Result, Config, Mode, OutputConflictHandling};
66

77
fn miri_path() -> PathBuf {
88
PathBuf::from(option_env!("MIRI").unwrap_or(env!("CARGO_BIN_EXE_miri")))
@@ -43,30 +43,40 @@ fn run_tests(
4343
target: Option<String>,
4444
with_dependencies: bool,
4545
) -> Result<()> {
46+
let mut config = Config {
47+
target,
48+
stderr_filters: STDERR.clone(),
49+
stdout_filters: STDOUT.clone(),
50+
root_dir: PathBuf::from(path),
51+
mode,
52+
program: miri_path(),
53+
quiet: false,
54+
..Config::default()
55+
};
56+
4657
let in_rustc_test_suite = option_env!("RUSTC_STAGE").is_some();
4758

4859
// Add some flags we always want.
49-
let mut flags: Vec<OsString> = Vec::new();
50-
flags.push("--edition".into());
51-
flags.push("2018".into());
60+
config.args.push("--edition".into());
61+
config.args.push("2018".into());
5262
if in_rustc_test_suite {
5363
// Less aggressive warnings to make the rustc toolstate management less painful.
5464
// (We often get warnings when e.g. a feature gets stabilized or some lint gets added/improved.)
55-
flags.push("-Astable-features".into());
56-
flags.push("-Aunused".into());
65+
config.args.push("-Astable-features".into());
66+
config.args.push("-Aunused".into());
5767
} else {
58-
flags.push("-Dwarnings".into());
59-
flags.push("-Dunused".into());
68+
config.args.push("-Dwarnings".into());
69+
config.args.push("-Dunused".into());
6070
}
6171
if let Ok(extra_flags) = env::var("MIRIFLAGS") {
6272
for flag in extra_flags.split_whitespace() {
63-
flags.push(flag.into());
73+
config.args.push(flag.into());
6474
}
6575
}
66-
flags.push("-Zui-testing".into());
67-
if let Some(target) = &target {
68-
flags.push("--target".into());
69-
flags.push(target.into());
76+
config.args.push("-Zui-testing".into());
77+
if let Some(target) = &config.target {
78+
config.args.push("--target".into());
79+
config.args.push(target.into());
7080
}
7181

7282
// If we're on linux, and we're testing the extern-so functionality,
@@ -76,57 +86,43 @@ fn run_tests(
7686
let so_file_path = build_so_for_c_ffi_tests();
7787
let mut flag = std::ffi::OsString::from("-Zmiri-extern-so-file=");
7888
flag.push(so_file_path.into_os_string());
79-
flags.push(flag);
89+
config.args.push(flag);
8090
}
8191

8292
let skip_ui_checks = env::var_os("MIRI_SKIP_UI_CHECKS").is_some();
8393

84-
let output_conflict_handling = match (env::var_os("MIRI_BLESS").is_some(), skip_ui_checks) {
94+
config.output_conflict_handling = match (env::var_os("MIRI_BLESS").is_some(), skip_ui_checks) {
8595
(false, false) => OutputConflictHandling::Error,
8696
(true, false) => OutputConflictHandling::Bless,
8797
(false, true) => OutputConflictHandling::Ignore,
8898
(true, true) => panic!("cannot use MIRI_BLESS and MIRI_SKIP_UI_CHECKS at the same time"),
8999
};
90100

91-
// Pass on all unknown arguments as filters.
92-
let mut quiet = false;
93-
let path_filter = std::env::args().skip(1).filter(|arg| {
101+
// Handle command-line arguments.
102+
config.path_filter.extend(std::env::args().skip(1).filter(|arg| {
94103
match &**arg {
95104
"--quiet" => {
96-
quiet = true;
105+
config.quiet = true;
97106
false
98107
}
99108
_ => true,
100109
}
101-
});
110+
}));
102111

103112
let use_std = env::var_os("MIRI_NO_STD").is_none();
104113

105-
let config = Config {
106-
args: flags,
107-
target,
108-
stderr_filters: STDERR.clone(),
109-
stdout_filters: STDOUT.clone(),
110-
root_dir: PathBuf::from(path),
111-
mode,
112-
path_filter: path_filter.collect(),
113-
program: miri_path(),
114-
output_conflict_handling,
115-
dependencies_crate_manifest_path: (with_dependencies && use_std)
116-
.then(|| Path::new("test_dependencies").join("Cargo.toml")),
117-
dependency_builder: Some(DependencyBuilder {
118-
program: std::env::var_os("CARGO").unwrap().into(),
119-
args: vec![
120-
"run".into(),
121-
"--manifest-path".into(),
122-
"cargo-miri/Cargo.toml".into(),
123-
"--".into(),
124-
"miri".into(),
125-
],
126-
envs: vec![],
127-
}),
128-
quiet,
129-
};
114+
if with_dependencies && use_std {
115+
config.dependencies_crate_manifest_path =
116+
Some(Path::new("test_dependencies").join("Cargo.toml"));
117+
config.dependency_builder.args = vec![
118+
"run".into(),
119+
"--manifest-path".into(),
120+
"cargo-miri/Cargo.toml".into(),
121+
"--".into(),
122+
"miri".into(),
123+
"run".into(), // There is no `cargo miri build` so we just use `cargo miri run`.
124+
];
125+
}
130126
ui_test::run_tests(config)
131127
}
132128

@@ -214,10 +210,10 @@ fn main() -> Result<()> {
214210
ui(Mode::Pass, "tests/pass", WithoutDependencies)?;
215211
ui(Mode::Pass, "tests/pass-dep", WithDependencies)?;
216212
ui(Mode::Panic, "tests/panic", WithDependencies)?;
217-
ui(Mode::Fail, "tests/fail", WithDependencies)?;
213+
ui(Mode::Fail { require_patterns: true }, "tests/fail", WithDependencies)?;
218214
if cfg!(target_os = "linux") {
219215
ui(Mode::Pass, "tests/extern-so/pass", WithoutDependencies)?;
220-
ui(Mode::Fail, "tests/extern-so/fail", WithDependencies)?;
216+
ui(Mode::Fail { require_patterns: true }, "tests/extern-so/fail", WithDependencies)?;
221217
}
222218

223219
Ok(())

0 commit comments

Comments
 (0)