Skip to content

Commit

Permalink
Auto merge of rust-lang#2521 - oli-obk:bump_ui_test, r=RalfJung
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Aug 31, 2022
2 parents da45adc + 240f92a commit feeeba2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 94 deletions.
50 changes: 5 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ libc = "0.2"

[dev-dependencies]
colored = "2"
ui_test = "0.1"
ui_test = "0.3.1"
# Features chosen to match those required by env_logger, to avoid rebuilds
regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] }
lazy_static = "1.4.0"
Expand Down
92 changes: 44 additions & 48 deletions tests/compiletest.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use colored::*;
use regex::Regex;
use std::path::{Path, PathBuf};
use std::{env, ffi::OsString, process::Command};
use ui_test::{color_eyre::Result, Config, DependencyBuilder, Mode, OutputConflictHandling};
use std::{env, process::Command};
use ui_test::{color_eyre::Result, Config, Mode, OutputConflictHandling};

fn miri_path() -> PathBuf {
PathBuf::from(option_env!("MIRI").unwrap_or(env!("CARGO_BIN_EXE_miri")))
Expand Down Expand Up @@ -43,30 +43,40 @@ fn run_tests(
target: Option<String>,
with_dependencies: bool,
) -> Result<()> {
let mut config = Config {
target,
stderr_filters: STDERR.clone(),
stdout_filters: STDOUT.clone(),
root_dir: PathBuf::from(path),
mode,
program: miri_path(),
quiet: false,
..Config::default()
};

let in_rustc_test_suite = option_env!("RUSTC_STAGE").is_some();

// Add some flags we always want.
let mut flags: Vec<OsString> = Vec::new();
flags.push("--edition".into());
flags.push("2018".into());
config.args.push("--edition".into());
config.args.push("2018".into());
if in_rustc_test_suite {
// Less aggressive warnings to make the rustc toolstate management less painful.
// (We often get warnings when e.g. a feature gets stabilized or some lint gets added/improved.)
flags.push("-Astable-features".into());
flags.push("-Aunused".into());
config.args.push("-Astable-features".into());
config.args.push("-Aunused".into());
} else {
flags.push("-Dwarnings".into());
flags.push("-Dunused".into());
config.args.push("-Dwarnings".into());
config.args.push("-Dunused".into());
}
if let Ok(extra_flags) = env::var("MIRIFLAGS") {
for flag in extra_flags.split_whitespace() {
flags.push(flag.into());
config.args.push(flag.into());
}
}
flags.push("-Zui-testing".into());
if let Some(target) = &target {
flags.push("--target".into());
flags.push(target.into());
config.args.push("-Zui-testing".into());
if let Some(target) = &config.target {
config.args.push("--target".into());
config.args.push(target.into());
}

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

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

let output_conflict_handling = match (env::var_os("MIRI_BLESS").is_some(), skip_ui_checks) {
config.output_conflict_handling = match (env::var_os("MIRI_BLESS").is_some(), skip_ui_checks) {
(false, false) => OutputConflictHandling::Error,
(true, false) => OutputConflictHandling::Bless,
(false, true) => OutputConflictHandling::Ignore,
(true, true) => panic!("cannot use MIRI_BLESS and MIRI_SKIP_UI_CHECKS at the same time"),
};

// Pass on all unknown arguments as filters.
let mut quiet = false;
let path_filter = std::env::args().skip(1).filter(|arg| {
// Handle command-line arguments.
config.path_filter.extend(std::env::args().skip(1).filter(|arg| {
match &**arg {
"--quiet" => {
quiet = true;
config.quiet = true;
false
}
_ => true,
}
});
}));

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

let config = Config {
args: flags,
target,
stderr_filters: STDERR.clone(),
stdout_filters: STDOUT.clone(),
root_dir: PathBuf::from(path),
mode,
path_filter: path_filter.collect(),
program: miri_path(),
output_conflict_handling,
dependencies_crate_manifest_path: (with_dependencies && use_std)
.then(|| Path::new("test_dependencies").join("Cargo.toml")),
dependency_builder: Some(DependencyBuilder {
program: std::env::var_os("CARGO").unwrap().into(),
args: vec![
"run".into(),
"--manifest-path".into(),
"cargo-miri/Cargo.toml".into(),
"--".into(),
"miri".into(),
],
envs: vec![],
}),
quiet,
};
if with_dependencies && use_std {
config.dependencies_crate_manifest_path =
Some(Path::new("test_dependencies").join("Cargo.toml"));
config.dependency_builder.args = vec![
"run".into(),
"--manifest-path".into(),
"cargo-miri/Cargo.toml".into(),
"--".into(),
"miri".into(),
"run".into(), // There is no `cargo miri build` so we just use `cargo miri run`.
];
}
ui_test::run_tests(config)
}

Expand Down Expand Up @@ -214,10 +210,10 @@ fn main() -> Result<()> {
ui(Mode::Pass, "tests/pass", WithoutDependencies)?;
ui(Mode::Pass, "tests/pass-dep", WithDependencies)?;
ui(Mode::Panic, "tests/panic", WithDependencies)?;
ui(Mode::Fail, "tests/fail", WithDependencies)?;
ui(Mode::Fail { require_patterns: true }, "tests/fail", WithDependencies)?;
if cfg!(target_os = "linux") {
ui(Mode::Pass, "tests/extern-so/pass", WithoutDependencies)?;
ui(Mode::Fail, "tests/extern-so/fail", WithDependencies)?;
ui(Mode::Fail { require_patterns: true }, "tests/extern-so/fail", WithDependencies)?;
}

Ok(())
Expand Down

0 comments on commit feeeba2

Please sign in to comment.