diff options
| author | pierwill <pierwill@users.noreply.github.com> | 2021-10-20 15:14:16 -0500 |
|---|---|---|
| committer | pierwill <pierwill@users.noreply.github.com> | 2021-12-13 10:24:05 -0600 |
| commit | 7d7dfba350f13051fd7a409282fcb36094c2a8e9 (patch) | |
| tree | d07eadd07dfa309c444959bd72b58f0dc4ab8879 /src/tools/compiletest | |
| parent | a737592a3d8f0f5ec76524c880d226f28bef2c84 (diff) | |
| download | rust-7d7dfba350f13051fd7a409282fcb36094c2a8e9.tar.gz rust-7d7dfba350f13051fd7a409282fcb36094c2a8e9.zip | |
Include rustc version in `rustc_span::StableCrateId`
Normalize symbol hashes in compiletest. Remove DefId sorting
Diffstat (limited to 'src/tools/compiletest')
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 3ccd4a1cc59..ae97df583a3 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3501,6 +3501,59 @@ impl<'test> TestCx<'test> { normalized = Regex::new("\\s*//(\\[.*\\])?~.*").unwrap().replace_all(&normalized, "").into_owned(); + // This code normalizes various hashes in both + // v0 and legacy symbol names that are emitted in + // the ui and mir-opt tests. + // + // Some tests still require normalization with headers. + const DEFID_HASH_REGEX: &str = r"\[[0-9a-z]{4}\]"; + const DEFID_HASH_PLACEHOLDER: &str = r"[HASH]"; + const V0_DEMANGLING_HASH_REGEX: &str = r"\[[0-9a-z]+\]"; + const V0_DEMANGLING_HASH_PLACEHOLDER: &str = r"[HASH]"; + const V0_CRATE_HASH_PREFIX_REGEX: &str = r"_R.*?Cs[0-9a-zA-Z]+_"; + const V0_CRATE_HASH_REGEX: &str = r"Cs[0-9a-zA-Z]+_"; + const V0_CRATE_HASH_PLACEHOLDER: &str = r"CsCRATE_HASH_"; + const LEGACY_SYMBOL_HASH_REGEX: &str = r"h[\w]{16}E?\)"; + const LEGACY_SYMBOL_HASH_PLACEHOLDER: &str = r"h<SYMBOL_HASH>)"; + let test_name = self + .output_testname_unique() + .into_os_string() + .into_string() + .unwrap() + .split('.') + .next() + .unwrap() + .replace("-", "_"); + // Normalize `DefId` hashes + let defid_regex = format!("{}{}", test_name, DEFID_HASH_REGEX); + let defid_placeholder = format!("{}{}", test_name, DEFID_HASH_PLACEHOLDER); + normalized = Regex::new(&defid_regex) + .unwrap() + .replace_all(&normalized, defid_placeholder) + .into_owned(); + // Normalize v0 demangling hashes + let demangling_regex = format!("{}{}", test_name, V0_DEMANGLING_HASH_REGEX); + let demangling_placeholder = format!("{}{}", test_name, V0_DEMANGLING_HASH_PLACEHOLDER); + normalized = Regex::new(&demangling_regex) + .unwrap() + .replace_all(&normalized, demangling_placeholder) + .into_owned(); + // Normalize v0 crate hashes (see RFC 2603) + let symbol_mangle_prefix_re = Regex::new(V0_CRATE_HASH_PREFIX_REGEX).unwrap(); + if symbol_mangle_prefix_re.is_match(&normalized) { + // Normalize crate hash + normalized = Regex::new(V0_CRATE_HASH_REGEX) + .unwrap() + .replace_all(&normalized, V0_CRATE_HASH_PLACEHOLDER) + .into_owned(); + } + // Normalize legacy mangled symbols + normalized = Regex::new(LEGACY_SYMBOL_HASH_REGEX) + .unwrap() + .replace_all(&normalized, LEGACY_SYMBOL_HASH_PLACEHOLDER) + .into_owned(); + + // Custom normalization rules for rule in custom_rules { let re = Regex::new(&rule.0).expect("bad regex in custom normalization rule"); normalized = re.replace_all(&normalized, &rule.1[..]).into_owned(); |
