about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo.net>2017-01-16 18:22:38 -0500
committerMichael Woerister <michaelwoerister@posteo.net>2017-01-16 18:22:38 -0500
commit30ba990fce18dc3dde9e6d05d4bbbb2a56b34aba (patch)
treebf3b410ddb9de3446e54b05e51d96b3e523c86aa /src
parentf4375987633d08e9f0d6c13468c7df90c3ae546d (diff)
downloadrust-30ba990fce18dc3dde9e6d05d4bbbb2a56b34aba.tar.gz
rust-30ba990fce18dc3dde9e6d05d4bbbb2a56b34aba.zip
ignore-gdb-version: Address review comments.
Diffstat (limited to 'src')
-rw-r--r--src/tools/compiletest/src/header.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index eb8624fe71f..ac1ac1c2f6c 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -80,17 +80,22 @@ impl EarlyProps {
 
             if let Some(actual_version) = config.gdb_version {
                 if line.contains("min-gdb-version") {
-                    let min_version = extract_gdb_version_range(line);
+                    let (start_ver, end_ver) = extract_gdb_version_range(line);
 
-                    if min_version.0 != min_version.1 {
+                    if start_ver != end_ver {
                         panic!("Expected single GDB version")
                     }
                     // Ignore if actual version is smaller the minimum required
                     // version
-                    actual_version < min_version.0
+                    actual_version < start_ver
                 } 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
+                    let (min_version, max_version) = extract_gdb_version_range(line);
+
+                    if max_version < min_version {
+                        panic!("Malformed GDB version range: max < min")
+                    }
+
+                    actual_version >= min_version && actual_version <= max_version
                 } else {
                     false
                 }
@@ -99,6 +104,11 @@ impl EarlyProps {
             }
         }
 
+        // Takes a directive of the form "ignore-gdb-version <version1> [- <version2>]",
+        // returns the numeric representation of <version1> and <version2> as
+        // tuple: (<version1> as u32, <version2> as u32)
+        // If the <version2> part is omitted, the second component of the tuple
+        // is the same as <version1>.
         fn extract_gdb_version_range(line: &str) -> (u32, u32) {
             const ERROR_MESSAGE: &'static str = "Malformed GDB version directive";
 
@@ -109,7 +119,6 @@ impl EarlyProps {
                                        .collect::<Vec<&str>>();
 
             match range_components.len() {
-                0 => panic!(ERROR_MESSAGE),
                 1 => {
                     let v = extract_gdb_version(range_components[0]).unwrap();
                     (v, v)