about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo.net>2017-01-09 18:09:11 -0500
committerMichael Woerister <michaelwoerister@posteo.net>2017-01-13 13:23:53 -0500
commit62e11ad8bb28707837f07987f9ed5ae02789078c (patch)
tree8227ef8f6cb3e672e31581cfa27a2f575dd6ebae /src
parent7ef1a69d2e05d86e0893763d2c86677e9c5f3d99 (diff)
downloadrust-62e11ad8bb28707837f07987f9ed5ae02789078c.tar.gz
rust-62e11ad8bb28707837f07987f9ed5ae02789078c.zip
compiletest: Allow for ignoring tests if certain GDB version is detected.
Diffstat (limited to 'src')
-rw-r--r--src/tools/compiletest/src/header.rs41
-rw-r--r--src/tools/compiletest/src/main.rs3
2 files changed, 35 insertions, 9 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index e57c9949b1c..eb8624fe71f 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -73,19 +73,24 @@ impl EarlyProps {
                 return false;
             }
 
-            if parse_name_directive(line, "ignore-gdb") {
+            if !line.contains("ignore-gdb-version") &&
+               parse_name_directive(line, "ignore-gdb") {
                 return true;
             }
 
             if let Some(actual_version) = config.gdb_version {
                 if line.contains("min-gdb-version") {
-                    let min_version = line.trim()
-                        .split(' ')
-                        .last()
-                        .expect("Malformed GDB version directive");
+                    let min_version = extract_gdb_version_range(line);
+
+                    if min_version.0 != min_version.1 {
+                        panic!("Expected single GDB version")
+                    }
                     // Ignore if actual version is smaller the minimum required
                     // version
-                    actual_version < extract_gdb_version(min_version).unwrap()
+                    actual_version < min_version.0
+                } else if line.contains("ignore-gdb-version") {
+                    let version_range = extract_gdb_version_range(line);
+                    actual_version >= version_range.0 && actual_version <= version_range.1
                 } else {
                     false
                 }
@@ -94,6 +99,30 @@ impl EarlyProps {
             }
         }
 
+        fn extract_gdb_version_range(line: &str) -> (u32, u32) {
+            const ERROR_MESSAGE: &'static str = "Malformed GDB version directive";
+
+            let range_components = line.split(' ')
+                                       .flat_map(|word| word.split('-'))
+                                       .filter(|word| word.len() > 0)
+                                       .skip_while(|word| extract_gdb_version(word).is_none())
+                                       .collect::<Vec<&str>>();
+
+            match range_components.len() {
+                0 => panic!(ERROR_MESSAGE),
+                1 => {
+                    let v = extract_gdb_version(range_components[0]).unwrap();
+                    (v, v)
+                }
+                2 => {
+                    let v_min = extract_gdb_version(range_components[0]).unwrap();
+                    let v_max = extract_gdb_version(range_components[1]).expect(ERROR_MESSAGE);
+                    (v_min, v_max)
+                }
+                _ => panic!(ERROR_MESSAGE),
+            }
+        }
+
         fn ignore_lldb(config: &Config, line: &str) -> bool {
             if config.mode != common::DebugInfoLldb {
                 return false;
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index f6c8393ac21..8c9982d1d4e 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -587,7 +587,6 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
         return Some(((major * 1000) + minor) * 1000 + patch);
     }
 
-    println!("Could not extract GDB version from line '{}'", full_version_line);
     None
 }
 
@@ -624,8 +623,6 @@ fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
                 }).collect::<String>();
                 if !vers.is_empty() { return Some(vers) }
             }
-            println!("Could not extract LLDB version from line '{}'",
-                     full_version_line);
         }
     }
     None