Skip to content

Commit 62e11ad

Browse files
compiletest: Allow for ignoring tests if certain GDB version is detected.
1 parent 7ef1a69 commit 62e11ad

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

src/tools/compiletest/src/header.rs

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,24 @@ impl EarlyProps {
7373
return false;
7474
}
7575

76-
if parse_name_directive(line, "ignore-gdb") {
76+
if !line.contains("ignore-gdb-version") &&
77+
parse_name_directive(line, "ignore-gdb") {
7778
return true;
7879
}
7980

8081
if let Some(actual_version) = config.gdb_version {
8182
if line.contains("min-gdb-version") {
82-
let min_version = line.trim()
83-
.split(' ')
84-
.last()
85-
.expect("Malformed GDB version directive");
83+
let min_version = extract_gdb_version_range(line);
84+
85+
if min_version.0 != min_version.1 {
86+
panic!("Expected single GDB version")
87+
}
8688
// Ignore if actual version is smaller the minimum required
8789
// version
88-
actual_version < extract_gdb_version(min_version).unwrap()
90+
actual_version < min_version.0
91+
} else if line.contains("ignore-gdb-version") {
92+
let version_range = extract_gdb_version_range(line);
93+
actual_version >= version_range.0 && actual_version <= version_range.1
8994
} else {
9095
false
9196
}
@@ -94,6 +99,30 @@ impl EarlyProps {
9499
}
95100
}
96101

102+
fn extract_gdb_version_range(line: &str) -> (u32, u32) {
103+
const ERROR_MESSAGE: &'static str = "Malformed GDB version directive";
104+
105+
let range_components = line.split(' ')
106+
.flat_map(|word| word.split('-'))
107+
.filter(|word| word.len() > 0)
108+
.skip_while(|word| extract_gdb_version(word).is_none())
109+
.collect::<Vec<&str>>();
110+
111+
match range_components.len() {
112+
0 => panic!(ERROR_MESSAGE),
113+
1 => {
114+
let v = extract_gdb_version(range_components[0]).unwrap();
115+
(v, v)
116+
}
117+
2 => {
118+
let v_min = extract_gdb_version(range_components[0]).unwrap();
119+
let v_max = extract_gdb_version(range_components[1]).expect(ERROR_MESSAGE);
120+
(v_min, v_max)
121+
}
122+
_ => panic!(ERROR_MESSAGE),
123+
}
124+
}
125+
97126
fn ignore_lldb(config: &Config, line: &str) -> bool {
98127
if config.mode != common::DebugInfoLldb {
99128
return false;

src/tools/compiletest/src/main.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,6 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
587587
return Some(((major * 1000) + minor) * 1000 + patch);
588588
}
589589

590-
println!("Could not extract GDB version from line '{}'", full_version_line);
591590
None
592591
}
593592

@@ -624,8 +623,6 @@ fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
624623
}).collect::<String>();
625624
if !vers.is_empty() { return Some(vers) }
626625
}
627-
println!("Could not extract LLDB version from line '{}'",
628-
full_version_line);
629626
}
630627
}
631628
None

0 commit comments

Comments
 (0)