Skip to content

Commit 4516dac

Browse files
committed
compiletest: Support revisions in debuginfo (read: debugger) tests
1 parent f186dad commit 4516dac

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

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

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

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

@@ -41,6 +47,10 @@ impl DebuggerCommands {
4147
continue;
4248
};
4349

50+
if !directive.applies_to_test_revision(test_revision) {
51+
continue;
52+
}
53+
4454
if directive.name == command_directive
4555
&& let Some(command) = directive.value_after_colon()
4656
{
@@ -53,7 +63,13 @@ impl DebuggerCommands {
5363
}
5464
}
5565

56-
Ok(Self { commands, breakpoint_lines, check_lines, file: file.to_path_buf() })
66+
Ok(Self {
67+
commands,
68+
breakpoint_lines,
69+
check_lines,
70+
file: file.to_path_buf(),
71+
revision: test_revision.map(str::to_owned),
72+
})
5773
}
5874

5975
/// Given debugger output and lines to check, ensure that every line is
@@ -85,9 +101,11 @@ impl DebuggerCommands {
85101
Ok(())
86102
} else {
87103
let fname = self.file.file_name().unwrap();
104+
let revision_suffix =
105+
self.revision.as_ref().map_or(String::new(), |r| format!("#{}", r));
88106
let mut msg = format!(
89-
"check directive(s) from `{}` not found in debugger output. errors:",
90-
self.file
107+
"check directive(s) from `{}{}` not found in debugger output. errors:",
108+
self.file, revision_suffix
91109
);
92110

93111
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)