Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ impl Config {
line.starts_with("no-") && self.parse_name_directive(&line[3..], directive)
}

pub fn parse_name_value_directive(
fn parse_name_value_directive(
&self,
line: &str,
directive: &str,
Expand Down
27 changes: 15 additions & 12 deletions src/tools/compiletest/src/runtest/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::io::{BufRead, BufReader};

use camino::{Utf8Path, Utf8PathBuf};

use crate::common::Config;
use crate::runtest::ProcRes;

/// Representation of information to invoke a debugger and check its output
Expand All @@ -20,11 +19,7 @@ pub(super) struct DebuggerCommands {
}

impl DebuggerCommands {
pub fn parse_from(
file: &Utf8Path,
config: &Config,
debugger_prefix: &str,
) -> Result<Self, String> {
pub fn parse_from(file: &Utf8Path, debugger_prefix: &str) -> Result<Self, String> {
let command_directive = format!("{debugger_prefix}-command");
let check_directive = format!("{debugger_prefix}-check");

Expand All @@ -47,14 +42,10 @@ impl DebuggerCommands {
continue;
};

if let Some(command) =
config.parse_name_value_directive(&line, &command_directive, file, line_no)
{
if let Some(command) = parse_name_value(&line, &command_directive) {
commands.push(command);
}
if let Some(pattern) =
config.parse_name_value_directive(&line, &check_directive, file, line_no)
{
if let Some(pattern) = parse_name_value(&line, &check_directive) {
check_lines.push((line_no, pattern));
}
}
Expand Down Expand Up @@ -114,6 +105,18 @@ impl DebuggerCommands {
}
}

/// Split off from the main `parse_name_value_directive`, so that improvements
/// to directive handling aren't held back by debuginfo test commands.
Comment on lines +108 to +109
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

fn parse_name_value(line: &str, name: &str) -> Option<String> {
if let Some(after_name) = line.strip_prefix(name)
&& let Some(value) = after_name.strip_prefix(':')
{
Some(value.to_owned())
} else {
None
}
}

/// Check that the pattern in `check_line` applies to `line`. Returns `true` if they do match.
fn check_single_line(line: &str, check_line: &str) -> bool {
// Allow check lines to leave parts unspecified (e.g., uninitialized
Expand Down
6 changes: 3 additions & 3 deletions src/tools/compiletest/src/runtest/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,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, "cdb")
.unwrap_or_else(|e| self.fatal(&e));

// https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-commands
Expand Down Expand Up @@ -130,7 +130,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, "gdb")
.unwrap_or_else(|e| self.fatal(&e));
let mut cmds = dbg_cmds.commands.join("\n");

Expand Down Expand Up @@ -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, "lldb")
.unwrap_or_else(|e| self.fatal(&e));

// Write debugger script:
Expand Down