Skip to content

Commit 17f737d

Browse files
committed
compiletest: Support revisions in debuginfo (read: debugger) tests
1 parent 5a0439f commit 17f737d

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

src/tools/compiletest/src/runtest/debugger.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ pub(super) struct DebuggerCommands {
1616
check_lines: Vec<(usize, String)>,
1717
/// Source file name
1818
file: Utf8PathBuf,
19+
/// The revision being tested, if any
20+
revision: Option<String>,
1921
}
2022

2123
impl DebuggerCommands {
22-
pub fn parse_from(file: &Utf8Path, debugger_prefix: &str) -> Result<Self, String> {
24+
pub fn parse_from(
25+
file: &Utf8Path,
26+
debugger_prefix: &str,
27+
test_revision: Option<&str>,
28+
) -> Result<Self, String> {
2329
let command_directive = format!("{debugger_prefix}-command");
2430
let check_directive = format!("{debugger_prefix}-check");
2531

@@ -44,6 +50,10 @@ impl DebuggerCommands {
4450
continue;
4551
};
4652

53+
if !directive.applies_to_test_revision(test_revision) {
54+
continue;
55+
}
56+
4757
if directive.name == command_directive
4858
&& let Some(command) = directive.value_after_colon()
4959
{
@@ -56,7 +66,13 @@ impl DebuggerCommands {
5666
}
5767
}
5868

59-
Ok(Self { commands, breakpoint_lines, check_lines, file: file.to_path_buf() })
69+
Ok(Self {
70+
commands,
71+
breakpoint_lines,
72+
check_lines,
73+
file: file.to_path_buf(),
74+
revision: test_revision.map(str::to_owned),
75+
})
6076
}
6177

6278
/// Given debugger output and lines to check, ensure that every line is
@@ -88,9 +104,11 @@ impl DebuggerCommands {
88104
Ok(())
89105
} else {
90106
let fname = self.file.file_name().unwrap();
107+
let revision_suffix =
108+
self.revision.as_ref().map_or(String::new(), |r| format!("#{}", r));
91109
let mut msg = format!(
92-
"check directive(s) from `{}` not found in debugger output. errors:",
93-
self.file
110+
"check directive(s) from `{}{}` not found in debugger output. errors:",
111+
self.file, revision_suffix
94112
);
95113

96114
for (src_lineno, err_line) in missing {

src/tools/compiletest/src/runtest/debuginfo.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl TestCx<'_> {
4646
}
4747

4848
// Parse debugger commands etc from test files
49-
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, "cdb")
49+
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, "cdb", self.revision)
5050
.unwrap_or_else(|e| self.fatal(&e));
5151

5252
// https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-commands
@@ -105,7 +105,7 @@ impl TestCx<'_> {
105105
}
106106

107107
fn run_debuginfo_gdb_test(&self) {
108-
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, "gdb")
108+
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, "gdb", self.revision)
109109
.unwrap_or_else(|e| self.fatal(&e));
110110
let mut cmds = dbg_cmds.commands.join("\n");
111111

@@ -366,7 +366,7 @@ impl TestCx<'_> {
366366
}
367367

368368
// Parse debugger commands etc from test files
369-
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, "lldb")
369+
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, "lldb", self.revision)
370370
.unwrap_or_else(|e| self.fatal(&e));
371371

372372
// Write debugger script:

0 commit comments

Comments
 (0)