diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2024-12-29 10:00:18 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-29 10:00:18 +1100 |
| commit | a8a10110e03efb8e438aa043515432693b4b4ab7 (patch) | |
| tree | 514a278998dfb40f57678b6dc5215e40a71bf906 | |
| parent | 8742e0556dee3c64f7144de2fb2e88936418865a (diff) | |
| parent | 2f8824a477f8b4ec51a3365c2d68f525032b8241 (diff) | |
| download | rust-a8a10110e03efb8e438aa043515432693b4b4ab7.tar.gz rust-a8a10110e03efb8e438aa043515432693b4b4ab7.zip | |
Rollup merge of #134849 - Zalathar:debuginfo-prefixes, r=lqd,clubby789,jieyouxu
compiletest: Slightly simplify the handling of debugger directive prefixes The `cdbg-` prefix is not used by any tests in `tests/debuginfo`, and perhaps there never were any tests that used it. Getting rid of it also lets us get rid of the code for parsing multiple prefixes at the same time, since every debugger now has exactly one prefix.
| -rw-r--r-- | src/tools/compiletest/src/runtest/debugger.rs | 25 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest/debuginfo.rs | 12 |
2 files changed, 11 insertions, 26 deletions
diff --git a/src/tools/compiletest/src/runtest/debugger.rs b/src/tools/compiletest/src/runtest/debugger.rs index c15422fb6f6..d9e5c3fa0d8 100644 --- a/src/tools/compiletest/src/runtest/debugger.rs +++ b/src/tools/compiletest/src/runtest/debugger.rs @@ -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)); } } diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs index c621c22ac99..b236b067569 100644 --- a/src/tools/compiletest/src/runtest/debuginfo.rs +++ b/src/tools/compiletest/src/runtest/debuginfo.rs @@ -59,14 +59,8 @@ impl TestCx<'_> { return; } - let prefixes = { - static PREFIXES: &[&str] = &["cdb", "cdbg"]; - // No "native rust support" variation for CDB yet. - PREFIXES - }; - // Parse debugger commands etc from test files - let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, prefixes) + 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 @@ -137,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"); @@ -403,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: |
