-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Normalize alloc-id in tests. #116767
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
Normalize alloc-id in tests. #116767
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -697,6 +697,7 @@ dependencies = [ | |
"getopts", | ||
"glob", | ||
"home", | ||
"indexmap 2.0.0", | ||
"lazycell", | ||
"libc", | ||
"miow", | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4258,6 +4258,37 @@ impl<'test> TestCx<'test> { | |||||||||||||||
V0_BACK_REF_RE.replace_all(&normalized, V0_BACK_REF_PLACEHOLDER).into_owned(); | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
// AllocId are numbered globally in a compilation session. This can lead to changes | ||||||||||||||||
// depending on the exact compilation flags and host architecture. Meanwhile, we want | ||||||||||||||||
// to keep them numbered, to see if the same id appears multiple times. | ||||||||||||||||
Comment on lines
+4262
to
+4263
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
{ | ||||||||||||||||
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. | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There could be 0 And same for the leading |
||||||||||||||||
// Complete with filler `─` to preserve the pretty-print. | ||||||||||||||||
if let Some(tail) = caps.get(3) { | ||||||||||||||||
ret.push_str(tail.as_str()); | ||||||||||||||||
let orig_len = caps.get(0).unwrap().as_str().len(); | ||||||||||||||||
let ret_len = ret.len(); | ||||||||||||||||
for _ in orig_len..ret_len { | ||||||||||||||||
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"); | ||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,6 @@ fn main() -> () { | |
} | ||
} | ||
|
||
alloc1 (size: 3, align: 1) { | ||
ALLOC0 (size: 3, align: 1) { | ||
66 6f 6f │ foo | ||
} |
Uh oh!
There was an error while loading. Please reload this page.