compiletest: allow using revisions with debuginfo tests
This commit is contained in:
parent
9a7b7d5e50
commit
45382e64cf
@ -648,8 +648,6 @@ fn run_debuginfo_test(&self) {
|
||||
}
|
||||
|
||||
fn run_debuginfo_cdb_test(&self) {
|
||||
assert!(self.revision.is_none(), "revisions not relevant here");
|
||||
|
||||
let config = Config {
|
||||
target_rustcflags: self.cleanup_debug_info_options(&self.config.target_rustcflags),
|
||||
host_rustcflags: self.cleanup_debug_info_options(&self.config.host_rustcflags),
|
||||
@ -695,7 +693,12 @@ fn run_debuginfo_cdb_test_no_opt(&self) {
|
||||
|
||||
// Parse debugger commands etc from test files
|
||||
let DebuggerCommands { commands, check_lines, breakpoint_lines, .. } =
|
||||
match DebuggerCommands::parse_from(&self.testpaths.file, self.config, prefixes) {
|
||||
match DebuggerCommands::parse_from(
|
||||
&self.testpaths.file,
|
||||
self.config,
|
||||
prefixes,
|
||||
self.revision,
|
||||
) {
|
||||
Ok(cmds) => cmds,
|
||||
Err(e) => self.fatal(&e),
|
||||
};
|
||||
@ -756,8 +759,6 @@ fn run_debuginfo_cdb_test_no_opt(&self) {
|
||||
}
|
||||
|
||||
fn run_debuginfo_gdb_test(&self) {
|
||||
assert!(self.revision.is_none(), "revisions not relevant here");
|
||||
|
||||
let config = Config {
|
||||
target_rustcflags: self.cleanup_debug_info_options(&self.config.target_rustcflags),
|
||||
host_rustcflags: self.cleanup_debug_info_options(&self.config.host_rustcflags),
|
||||
@ -783,7 +784,12 @@ fn run_debuginfo_gdb_test_no_opt(&self) {
|
||||
};
|
||||
|
||||
let DebuggerCommands { commands, check_lines, breakpoint_lines } =
|
||||
match DebuggerCommands::parse_from(&self.testpaths.file, self.config, prefixes) {
|
||||
match DebuggerCommands::parse_from(
|
||||
&self.testpaths.file,
|
||||
self.config,
|
||||
prefixes,
|
||||
self.revision,
|
||||
) {
|
||||
Ok(cmds) => cmds,
|
||||
Err(e) => self.fatal(&e),
|
||||
};
|
||||
@ -1005,8 +1011,6 @@ fn run_debuginfo_gdb_test_no_opt(&self) {
|
||||
}
|
||||
|
||||
fn run_debuginfo_lldb_test(&self) {
|
||||
assert!(self.revision.is_none(), "revisions not relevant here");
|
||||
|
||||
if self.config.lldb_python_dir.is_none() {
|
||||
self.fatal("Can't run LLDB test because LLDB's python path is not set.");
|
||||
}
|
||||
@ -1059,7 +1063,12 @@ fn run_debuginfo_lldb_test_no_opt(&self) {
|
||||
|
||||
// Parse debugger commands etc from test files
|
||||
let DebuggerCommands { commands, check_lines, breakpoint_lines, .. } =
|
||||
match DebuggerCommands::parse_from(&self.testpaths.file, self.config, prefixes) {
|
||||
match DebuggerCommands::parse_from(
|
||||
&self.testpaths.file,
|
||||
self.config,
|
||||
prefixes,
|
||||
self.revision,
|
||||
) {
|
||||
Ok(cmds) => cmds,
|
||||
Err(e) => self.fatal(&e),
|
||||
};
|
||||
|
@ -16,6 +16,7 @@ pub(super) fn parse_from(
|
||||
file: &Path,
|
||||
config: &Config,
|
||||
debugger_prefixes: &[&str],
|
||||
rev: Option<&str>,
|
||||
) -> Result<Self, String> {
|
||||
let directives = debugger_prefixes
|
||||
.iter()
|
||||
@ -25,13 +26,38 @@ pub(super) fn parse_from(
|
||||
let mut breakpoint_lines = vec![];
|
||||
let mut commands = vec![];
|
||||
let mut check_lines = vec![];
|
||||
let mut counter = 1;
|
||||
let mut counter = 0;
|
||||
let reader = BufReader::new(File::open(file).unwrap());
|
||||
for line in reader.lines() {
|
||||
counter += 1;
|
||||
match line {
|
||||
Ok(line) => {
|
||||
let line =
|
||||
if line.starts_with("//") { line[2..].trim_start() } else { line.as_str() };
|
||||
let (line, lnrev) = if line.starts_with("//") {
|
||||
let line = line[2..].trim_start();
|
||||
if line.starts_with('[') {
|
||||
if let Some(close_brace) = line.find(']') {
|
||||
let open_brace = line.find('[').unwrap();
|
||||
let lnrev = &line[open_brace + 1..close_brace];
|
||||
let line = line[(close_brace + 1)..].trim_start();
|
||||
(line, Some(lnrev))
|
||||
} else {
|
||||
panic!(
|
||||
"malformed condition direction: expected `//[foo]`, found `{}`",
|
||||
line
|
||||
)
|
||||
}
|
||||
} else {
|
||||
(line, None)
|
||||
}
|
||||
} else {
|
||||
(line.as_str(), None)
|
||||
};
|
||||
|
||||
// Skip any revision specific directive that doesn't match the current
|
||||
// revision being tested
|
||||
if lnrev.is_some() && lnrev != rev {
|
||||
continue;
|
||||
}
|
||||
|
||||
if line.contains("#break") {
|
||||
breakpoint_lines.push(counter);
|
||||
@ -49,7 +75,6 @@ pub(super) fn parse_from(
|
||||
}
|
||||
Err(e) => return Err(format!("Error while parsing debugger commands: {}", e)),
|
||||
}
|
||||
counter += 1;
|
||||
}
|
||||
|
||||
Ok(Self { commands, check_lines, breakpoint_lines })
|
||||
|
Loading…
Reference in New Issue
Block a user