diff options
| author | bors <bors@rust-lang.org> | 2022-07-20 19:37:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-07-20 19:37:17 +0000 |
| commit | d68e7ebc38cb42b8b237392b28045edeec761503 (patch) | |
| tree | e8109432f17346411b536b520111848a173e8cf1 /src/tools | |
| parent | a7468c60f8dbf5feb23ad840b174d7e57113a846 (diff) | |
| parent | a5a681100cb14af73926f309821903175b4fc2a2 (diff) | |
| download | rust-d68e7ebc38cb42b8b237392b28045edeec761503.tar.gz rust-d68e7ebc38cb42b8b237392b28045edeec761503.zip | |
Auto merge of #99520 - matthiaskrgr:rollup-05uuv5s, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #99212 (introduce `implied_by` in `#[unstable]` attribute) - #99352 (Use `typeck_results` to avoid duplicate `ast_ty_to_ty` call) - #99355 (better error for bad depth parameter on macro metavar expr) - #99480 (Diagnostic width span is not added when '0$' is used as width in format strings) - #99488 (compiletest: Allow using revisions with debuginfo tests.) - #99489 (rustdoc UI fixes) - #99508 (Avoid `Symbol` to `String` conversions) - #99510 (adapt assembly/static-relocation-model test for LLVM change) - #99516 (Use new tracking issue for proc_macro::tracked_*.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/compiletest/src/header.rs | 36 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 27 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest/debugger.rs | 15 |
3 files changed, 54 insertions, 24 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 17f2b77dab0..02f4d29a2f0 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -535,6 +535,29 @@ impl TestProps { } } +pub fn line_directive<'line>( + comment: &str, + ln: &'line str, +) -> Option<(Option<&'line str>, &'line str)> { + if ln.starts_with(comment) { + let ln = ln[comment.len()..].trim_start(); + if ln.starts_with('[') { + // A comment like `//[foo]` is specific to revision `foo` + if let Some(close_brace) = ln.find(']') { + let lncfg = &ln[1..close_brace]; + + Some((Some(lncfg), ln[(close_brace + 1)..].trim_start())) + } else { + panic!("malformed condition directive: expected `{}[foo]`, found `{}`", comment, ln) + } + } else { + Some((None, ln)) + } + } else { + None + } +} + fn iter_header<R: Read>(testfile: &Path, rdr: R, it: &mut dyn FnMut(Option<&str>, &str)) { if testfile.is_dir() { return; @@ -557,17 +580,8 @@ fn iter_header<R: Read>(testfile: &Path, rdr: R, it: &mut dyn FnMut(Option<&str> let ln = ln.trim(); if ln.starts_with("fn") || ln.starts_with("mod") { return; - } else if ln.starts_with(comment) && ln[comment.len()..].trim_start().starts_with('[') { - // A comment like `//[foo]` is specific to revision `foo` - if let Some(close_brace) = ln.find(']') { - let open_brace = ln.find('[').unwrap(); - let lncfg = &ln[open_brace + 1..close_brace]; - it(Some(lncfg), ln[(close_brace + 1)..].trim_start()); - } else { - panic!("malformed condition directive: expected `{}[foo]`, found `{}`", comment, ln) - } - } else if ln.starts_with(comment) { - it(None, ln[comment.len()..].trim_start()); + } else if let Some((lncfg, ln)) = line_directive(comment, ln) { + it(lncfg, ln); } } } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 5517b5a12c3..26730fcec4c 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -648,8 +648,6 @@ impl<'test> TestCx<'test> { } 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 @@ impl<'test> TestCx<'test> { // 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 @@ impl<'test> TestCx<'test> { } 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 @@ impl<'test> TestCx<'test> { }; 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 @@ impl<'test> TestCx<'test> { } 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 @@ impl<'test> TestCx<'test> { // 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), }; diff --git a/src/tools/compiletest/src/runtest/debugger.rs b/src/tools/compiletest/src/runtest/debugger.rs index cbd5e4c431f..379ff0bab40 100644 --- a/src/tools/compiletest/src/runtest/debugger.rs +++ b/src/tools/compiletest/src/runtest/debugger.rs @@ -1,4 +1,5 @@ use crate::common::Config; +use crate::header::line_directive; use crate::runtest::ProcRes; use std::fs::File; @@ -16,6 +17,7 @@ impl DebuggerCommands { file: &Path, config: &Config, debugger_prefixes: &[&str], + rev: Option<&str>, ) -> Result<Self, String> { let directives = debugger_prefixes .iter() @@ -25,13 +27,19 @@ impl DebuggerCommands { 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 (lnrev, line) = line_directive("//", &line).unwrap_or((None, &line)); + + // 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 +57,6 @@ impl DebuggerCommands { } Err(e) => return Err(format!("Error while parsing debugger commands: {}", e)), } - counter += 1; } Ok(Self { commands, check_lines, breakpoint_lines }) |
