diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-10-15 17:00:11 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-10-16 16:29:35 +0000 |
| commit | 02424e4bc57344dc7436644f897b5500a1973242 (patch) | |
| tree | fbb9f0f8f6f8ce86254b9e75a44b49da00ca09a5 /src | |
| parent | e7bdc5f9f869219e8d20060b42a09ea10a837851 (diff) | |
| download | rust-02424e4bc57344dc7436644f897b5500a1973242.tar.gz rust-02424e4bc57344dc7436644f897b5500a1973242.zip | |
Normalize alloc-id in tests.
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/compiletest/Cargo.toml | 1 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index bb1fa6e9237..31c6353e675 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -11,6 +11,7 @@ colored = "2" diff = "0.1.10" unified-diff = "0.2.1" getopts = "0.2" +indexmap = "2.0.0" miropt-test-tools = { path = "../miropt-test-tools" } build_helper = { path = "../build_helper" } tracing = "0.1" diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 7b42d8e9b58..3982b789328 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -4258,6 +4258,34 @@ impl<'test> TestCx<'test> { V0_BACK_REF_RE.replace_all(&normalized, V0_BACK_REF_PLACEHOLDER).into_owned(); } + // Normalize AllocId counter + { + use std::fmt::Write; + + let re = Regex::new(r"(╾a|─a|\balloc)([0-9]+)\b(─|\+0x[0-9]+─)?").unwrap(); + let mut seen_allocs = indexmap::IndexSet::new(); + normalized = re + .replace_all(&normalized, |caps: &Captures<'_>| { + // Use uppercase to distinguish with the non-normalized version. + let mut ret = caps.get(1).unwrap().as_str().to_uppercase(); + // Renumber the captured index. + let index = caps.get(2).unwrap().as_str().to_string(); + let (index, _) = seen_allocs.insert_full(index); + write!(&mut ret, "{index}").unwrap(); + // If we have a tail finishing with `─`, this means pretty-printing. + // Complete with filler `─` to preserve the pretty-print. + if let Some(tail) = caps.get(3) { + ret.push_str(tail.as_str()); + let diff = caps.get(0).unwrap().as_str().len() - ret.len(); + for _ in 0..diff { + ret.push('─'); + } + } + ret + }) + .into_owned(); + } + // Custom normalization rules for rule in custom_rules { let re = Regex::new(&rule.0).expect("bad regex in custom normalization rule"); |
