Skip to content

compiletest: up deps #108306

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 2 commits into from
Feb 22, 2023
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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -891,11 +891,11 @@ dependencies = [
"diff",
"getopts",
"glob",
"lazy_static",
"lazycell",
"libc",
"miow 0.3.7",
"miow 0.5.0",
"miropt-test-tools",
"once_cell",
"regex",
"rustfix",
"serde",
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ regex = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rustfix = "0.6.0"
lazy_static = "1.0"
once_cell = "1.16.0"
walkdir = "2"
glob = "0.3.0"
lazycell = "1.3.0"
Expand All @@ -25,5 +25,5 @@ lazycell = "1.3.0"
libc = "0.2"

[target.'cfg(windows)'.dependencies]
miow = "0.3"
miow = "0.5"
winapi = { version = "0.3", features = ["winerror"] }
8 changes: 3 additions & 5 deletions src/tools/compiletest/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::io::BufReader;
use std::path::Path;
use std::str::FromStr;

use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use regex::Regex;
use tracing::*;

Expand Down Expand Up @@ -117,10 +117,8 @@ fn parse_expected(
// //~^^^^^
// //[cfg1]~
// //[cfg1,cfg2]~^^
lazy_static! {
static ref RE: Regex =
Regex::new(r"//(?:\[(?P<cfgs>[\w,]+)])?~(?P<adjust>\||\^*)").unwrap();
}
static RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"//(?:\[(?P<cfgs>[\w,]+)])?~(?P<adjust>\||\^*)").unwrap());

let captures = RE.captures(line)?;

Expand Down
71 changes: 33 additions & 38 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use std::process::{Child, Command, ExitStatus, Output, Stdio};
use std::str;

use glob::glob;
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use tracing::*;

use crate::extract_gdb_version;
Expand All @@ -52,9 +52,8 @@ fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
use winapi::um::errhandlingapi::SetErrorMode;
use winapi::um::winbase::SEM_NOGPFAULTERRORBOX;

lazy_static! {
static ref LOCK: Mutex<()> = Mutex::new(());
}
static LOCK: Mutex<()> = Mutex::new(());

// Error mode is a global variable, so lock it so only one thread will change it
let _lock = LOCK.lock().unwrap();

Expand Down Expand Up @@ -2848,11 +2847,10 @@ impl<'test> TestCx<'test> {
// the form <crate-name1>.<crate-disambiguator1>-in-<crate-name2>.<crate-disambiguator2>,
// remove all crate-disambiguators.
fn remove_crate_disambiguator_from_cgu(cgu: &str) -> String {
lazy_static! {
static ref RE: Regex =
Regex::new(r"^[^\.]+(?P<d1>\.[[:alnum:]]+)(-in-[^\.]+(?P<d2>\.[[:alnum:]]+))?")
.unwrap();
}
static RE: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"^[^\.]+(?P<d1>\.[[:alnum:]]+)(-in-[^\.]+(?P<d2>\.[[:alnum:]]+))?")
.unwrap()
});

let captures =
RE.captures(cgu).unwrap_or_else(|| panic!("invalid cgu name encountered: {}", cgu));
Expand Down Expand Up @@ -3170,12 +3168,12 @@ impl<'test> TestCx<'test> {
// 'uploaded "$TEST_BUILD_DIR/<test_executable>, waiting for result"'
// is printed to stdout by the client and then captured in the ProcRes,
// so it needs to be removed when comparing the run-pass test execution output
lazy_static! {
static ref REMOTE_TEST_RE: Regex = Regex::new(
static REMOTE_TEST_RE: Lazy<Regex> = Lazy::new(|| {
Regex::new(
"^uploaded \"\\$TEST_BUILD_DIR(/[[:alnum:]_\\-.]+)+\", waiting for result\n"
)
.unwrap();
}
.unwrap()
});
REMOTE_TEST_RE
.replace(
&self.normalize_output(&proc_res.stdout, &self.props.normalize_stdout),
Expand Down Expand Up @@ -3620,10 +3618,8 @@ impl<'test> TestCx<'test> {
// with placeholders as we do not want tests needing updated when compiler source code
// changes.
// eg. $SRC_DIR/libcore/mem.rs:323:14 becomes $SRC_DIR/libcore/mem.rs:LL:COL
lazy_static! {
static ref SRC_DIR_RE: Regex =
Regex::new("SRC_DIR(.+):\\d+:\\d+(: \\d+:\\d+)?").unwrap();
}
static SRC_DIR_RE: Lazy<Regex> =
Lazy::new(|| Regex::new("SRC_DIR(.+):\\d+:\\d+(: \\d+:\\d+)?").unwrap());

normalized = SRC_DIR_RE.replace_all(&normalized, "SRC_DIR$1:LL:COL").into_owned();

Expand All @@ -3634,19 +3630,17 @@ impl<'test> TestCx<'test> {
// since they duplicate actual errors and make the output hard to read.
// This mirrors the regex in src/tools/tidy/src/style.rs, please update
// both if either are changed.
lazy_static! {
static ref ANNOTATION_RE: Regex = Regex::new("\\s*//(\\[.*\\])?~.*").unwrap();
}
static ANNOTATION_RE: Lazy<Regex> =
Lazy::new(|| Regex::new("\\s*//(\\[.*\\])?~.*").unwrap());

normalized = ANNOTATION_RE.replace_all(&normalized, "").into_owned();

// This code normalizes various hashes in v0 symbol mangling that is
// emitted in the ui and mir-opt tests.
lazy_static! {
static ref V0_CRATE_HASH_PREFIX_RE: Regex =
Regex::new(r"_R.*?Cs[0-9a-zA-Z]+_").unwrap();
static ref V0_CRATE_HASH_RE: Regex = Regex::new(r"Cs[0-9a-zA-Z]+_").unwrap();
}
static V0_CRATE_HASH_PREFIX_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"_R.*?Cs[0-9a-zA-Z]+_").unwrap());
static V0_CRATE_HASH_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"Cs[0-9a-zA-Z]+_").unwrap());

const V0_CRATE_HASH_PLACEHOLDER: &str = r"CsCRATE_HASH_";
if V0_CRATE_HASH_PREFIX_RE.is_match(&normalized) {
Expand All @@ -3655,10 +3649,9 @@ impl<'test> TestCx<'test> {
V0_CRATE_HASH_RE.replace_all(&normalized, V0_CRATE_HASH_PLACEHOLDER).into_owned();
}

lazy_static! {
static ref V0_BACK_REF_PREFIX_RE: Regex = Regex::new(r"\(_R.*?B[0-9a-zA-Z]_").unwrap();
static ref V0_BACK_REF_RE: Regex = Regex::new(r"B[0-9a-zA-Z]_").unwrap();
}
static V0_BACK_REF_PREFIX_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"\(_R.*?B[0-9a-zA-Z]_").unwrap());
static V0_BACK_REF_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"B[0-9a-zA-Z]_").unwrap());

const V0_BACK_REF_PLACEHOLDER: &str = r"B<REF>_";
if V0_BACK_REF_PREFIX_RE.is_match(&normalized) {
Expand All @@ -3681,21 +3674,23 @@ impl<'test> TestCx<'test> {
/// Replaces backslashes in paths with forward slashes, and replaces CRLF line endings
/// with LF.
fn normalize_platform_differences(output: &str) -> String {
lazy_static! {
/// Used to find Windows paths.
///
/// It's not possible to detect paths in the error messages generally, but this is a
/// decent enough heuristic.
static ref PATH_BACKSLASH_RE: Regex = Regex::new(r#"(?x)
/// Used to find Windows paths.
///
/// It's not possible to detect paths in the error messages generally, but this is a
/// decent enough heuristic.
static PATH_BACKSLASH_RE: Lazy<Regex> = Lazy::new(|| {
Regex::new(
r#"(?x)
(?:
# Match paths that don't include spaces.
(?:\\[\pL\pN\.\-_']+)+\.\pL+
|
# If the path starts with a well-known root, then allow spaces.
\$(?:DIR|SRC_DIR|TEST_BUILD_DIR|BUILD_DIR|LIB_DIR)(?:\\[\pL\pN\.\-_' ]+)+
)"#
).unwrap();
}
)"#,
)
.unwrap()
});

let output = output.replace(r"\\", r"\");

Expand Down