Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Bump ui_test crate
  • Loading branch information
oli-obk committed Sep 22, 2023
commit 9f4e7c69456d56d1ec5ae18a82b816135e0dcdf4
38 changes: 29 additions & 9 deletions src/tools/miri/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ dependencies = [
"memchr",
]

[[package]]
name = "annotate-snippets"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3b9d411ecbaf79885c6df4d75fff75858d5995ff25385657a28af47e82f9c36"
dependencies = [
"unicode-width",
"yansi-term",
]

[[package]]
name = "ansi_term"
version = "0.12.1"
Expand Down Expand Up @@ -216,12 +226,6 @@ dependencies = [
"windows-sys 0.45.0",
]

[[package]]
name = "distance"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d9d8664cf849d7d0f3114a3a387d2f5e4303176d746d5a951aaddc66dfe9240"

[[package]]
name = "encode_unicode"
version = "0.3.6"
Expand Down Expand Up @@ -372,6 +376,12 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"

[[package]]
name = "levenshtein"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760"

[[package]]
name = "libc"
version = "0.2.148"
Expand Down Expand Up @@ -937,10 +947,11 @@ dependencies = [

[[package]]
name = "ui_test"
version = "0.14.2"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d15b71b50d95aeb687f68289543b9cabdbec7afc277176ce9dfcf192c7035d"
checksum = "accffe020b57a6dd50014d457b5842c5a2ca73cd84f07d86d0a19c460a6509ae"
dependencies = [
"annotate-snippets",
"anyhow",
"bstr",
"cargo-platform",
Expand All @@ -949,9 +960,9 @@ dependencies = [
"colored",
"comma",
"crossbeam-channel",
"distance",
"indicatif",
"lazy_static",
"levenshtein",
"prettydiff",
"regex",
"rustc_version",
Expand Down Expand Up @@ -1147,3 +1158,12 @@ name = "windows_x86_64_msvc"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"

[[package]]
name = "yansi-term"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1"
dependencies = [
"winapi",
]
2 changes: 1 addition & 1 deletion src/tools/miri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ libloading = "0.7"

[dev-dependencies]
colored = "2"
ui_test = "0.14.1"
ui_test = "0.21.1"
rustc_version = "0.4"
# Features chosen to match those required by env_logger, to avoid rebuilds
regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] }
Expand Down
56 changes: 29 additions & 27 deletions src/tools/miri/tests/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::num::NonZeroUsize;
use std::path::{Path, PathBuf};
use std::{env, process::Command};
use ui_test::{color_eyre::Result, Config, Match, Mode, OutputConflictHandling};
use ui_test::{status_emitter, CommandBuilder};
use ui_test::{status_emitter, CommandBuilder, Format, RustfixMode};

fn miri_path() -> PathBuf {
PathBuf::from(option_env!("MIRI").unwrap_or(env!("CARGO_BIN_EXE_miri")))
Expand Down Expand Up @@ -79,25 +79,17 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
program.args.push(flag);
}

let bless = env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0");
let skip_ui_checks = env::var_os("MIRI_SKIP_UI_CHECKS").is_some();

let output_conflict_handling = match (bless, skip_ui_checks) {
(false, false) => OutputConflictHandling::Error("./miri test --bless".into()),
(true, false) => OutputConflictHandling::Bless,
(false, true) => OutputConflictHandling::Ignore,
(true, true) => panic!("cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time"),
};

let mut config = Config {
target: Some(target.to_owned()),
stderr_filters: STDERR.clone(),
stdout_filters: STDOUT.clone(),
mode,
program,
output_conflict_handling,
out_dir: PathBuf::from(std::env::var_os("CARGO_TARGET_DIR").unwrap()).join("ui"),
edition: Some("2021".into()),
threads: std::env::var("MIRI_TEST_THREADS")
.ok()
.map(|threads| NonZeroUsize::new(threads.parse().unwrap()).unwrap()),
..Config::rustc(path)
};

Expand All @@ -121,25 +113,31 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
}

fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> Result<()> {
let config = test_config(target, path, mode, with_dependencies);
let mut config = test_config(target, path, mode, with_dependencies);

// Handle command-line arguments.
let args = ui_test::Args::test();
let quiet = args.quiet;
let args = ui_test::Args::test()?;
let default_bless = env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0");
config.with_args(&args, default_bless);
if let OutputConflictHandling::Error(msg) = &mut config.output_conflict_handling {
*msg = "./miri test --bless".into();
}
if env::var_os("MIRI_SKIP_UI_CHECKS").is_some() {
assert!(!default_bless, "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time");
config.output_conflict_handling = OutputConflictHandling::Ignore;
}
eprintln!(" Compiler: {}", config.program.display());
ui_test::run_tests_generic(
vec![config],
std::env::var("MIRI_TEST_THREADS").map_or_else(
|_| std::thread::available_parallelism().unwrap(),
|threads| NonZeroUsize::new(threads.parse().unwrap()).unwrap(),
),
args,
// The files we're actually interested in (all `.rs` files).
ui_test::default_file_filter,
// This could be used to overwrite the `Config` on a per-test basis.
|_, _| {},
|_, _, _| {},
(
if quiet { status_emitter::Text::quiet() } else { status_emitter::Text::verbose() },
match args.format {
Format::Terse => status_emitter::Text::quiet(),
Format::Pretty => status_emitter::Text::verbose(),
},
status_emitter::Gha::</* GHA Actions groups*/ false> {
name: format!("{mode:?} {path} ({target})"),
},
Expand Down Expand Up @@ -244,21 +242,21 @@ fn main() -> Result<()> {
ui(Mode::Pass, "tests/pass-dep", &target, WithDependencies)?;
ui(Mode::Panic, "tests/panic", &target, WithDependencies)?;
ui(
Mode::Fail { require_patterns: true, rustfix: false },
Mode::Fail { require_patterns: true, rustfix: RustfixMode::Disabled },
"tests/fail",
&target,
WithoutDependencies,
)?;
ui(
Mode::Fail { require_patterns: true, rustfix: false },
Mode::Fail { require_patterns: true, rustfix: RustfixMode::Disabled },
"tests/fail-dep",
&target,
WithDependencies,
)?;
if cfg!(target_os = "linux") {
ui(Mode::Pass, "tests/extern-so/pass", &target, WithoutDependencies)?;
ui(
Mode::Fail { require_patterns: true, rustfix: false },
Mode::Fail { require_patterns: true, rustfix: RustfixMode::Disabled },
"tests/extern-so/fail",
&target,
WithoutDependencies,
Expand All @@ -270,8 +268,12 @@ fn main() -> Result<()> {

fn run_dep_mode(target: String, mut args: impl Iterator<Item = OsString>) -> Result<()> {
let path = args.next().expect("./miri run-dep must be followed by a file name");
let mut config =
test_config(&target, "", Mode::Yolo { rustfix: false }, /* with dependencies */ true);
let mut config = test_config(
&target,
"",
Mode::Yolo { rustfix: RustfixMode::Disabled },
/* with dependencies */ true,
);
config.program.args.clear(); // We want to give the user full control over flags
let dep_args = config.build_dependencies()?;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$DIR/backtrace-api-v0.rs:24:14 (func_d)
$DIR/backtrace-api-v0.rs:20:5 (func_c)
$DIR/backtrace-api-v0.rs:9:5 (func_b)
$DIR/backtrace-api-v0.rs:9:5 (func_b::<u8>)
$DIR/backtrace-api-v0.rs:5:5 (func_a)
$DIR/backtrace-api-v0.rs:29:18 (main)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$DIR/backtrace-api-v1.rs:27:9 (func_d)
$DIR/backtrace-api-v1.rs:20:5 (func_c)
$DIR/backtrace-api-v1.rs:9:5 (func_b)
$DIR/backtrace-api-v1.rs:9:5 (func_b::<u8>)
$DIR/backtrace-api-v1.rs:5:5 (func_a)
$DIR/backtrace-api-v1.rs:34:18 (main)