Simplify DebuggerCommands::parse_from
to only take one prefix
This commit is contained in:
parent
a625ddd1ed
commit
2f8824a477
2 changed files with 11 additions and 20 deletions
|
@ -19,15 +19,9 @@ pub(super) struct DebuggerCommands {
|
|||
}
|
||||
|
||||
impl DebuggerCommands {
|
||||
pub fn parse_from(
|
||||
file: &Path,
|
||||
config: &Config,
|
||||
debugger_prefixes: &[&str],
|
||||
) -> Result<Self, String> {
|
||||
let directives = debugger_prefixes
|
||||
.iter()
|
||||
.map(|prefix| (format!("{prefix}-command"), format!("{prefix}-check")))
|
||||
.collect::<Vec<_>>();
|
||||
pub fn parse_from(file: &Path, config: &Config, debugger_prefix: &str) -> Result<Self, String> {
|
||||
let command_directive = format!("{debugger_prefix}-command");
|
||||
let check_directive = format!("{debugger_prefix}-check");
|
||||
|
||||
let mut breakpoint_lines = vec![];
|
||||
let mut commands = vec![];
|
||||
|
@ -48,14 +42,11 @@ impl DebuggerCommands {
|
|||
continue;
|
||||
};
|
||||
|
||||
for &(ref command_directive, ref check_directive) in &directives {
|
||||
config
|
||||
.parse_name_value_directive(&line, command_directive)
|
||||
.map(|cmd| commands.push(cmd));
|
||||
|
||||
config
|
||||
.parse_name_value_directive(&line, check_directive)
|
||||
.map(|cmd| check_lines.push((line_no, cmd)));
|
||||
if let Some(command) = config.parse_name_value_directive(&line, &command_directive) {
|
||||
commands.push(command);
|
||||
}
|
||||
if let Some(pattern) = config.parse_name_value_directive(&line, &check_directive) {
|
||||
check_lines.push((line_no, pattern));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ impl TestCx<'_> {
|
|||
}
|
||||
|
||||
// Parse debugger commands etc from test files
|
||||
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["cdb"])
|
||||
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "cdb")
|
||||
.unwrap_or_else(|e| self.fatal(&e));
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-commands
|
||||
|
@ -131,7 +131,7 @@ impl TestCx<'_> {
|
|||
}
|
||||
|
||||
fn run_debuginfo_gdb_test_no_opt(&self) {
|
||||
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["gdb"])
|
||||
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "gdb")
|
||||
.unwrap_or_else(|e| self.fatal(&e));
|
||||
let mut cmds = dbg_cmds.commands.join("\n");
|
||||
|
||||
|
@ -397,7 +397,7 @@ impl TestCx<'_> {
|
|||
}
|
||||
|
||||
// Parse debugger commands etc from test files
|
||||
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["lldb"])
|
||||
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "lldb")
|
||||
.unwrap_or_else(|e| self.fatal(&e));
|
||||
|
||||
// Write debugger script:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue