about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-02-23 23:54:24 +0000
committervarkor <github@varkor.com>2018-02-23 23:54:24 +0000
commit70db41cdf74589c957cb930cdd58ebf6bafee5af (patch)
tree109e10e637baf9a24f2dce18fd61dc7b8dd98fb7
parent063deba92e44809125a433ca6e6c1ad0993313bf (diff)
downloadrust-70db41cdf74589c957cb930cdd58ebf6bafee5af.tar.gz
rust-70db41cdf74589c957cb930cdd58ebf6bafee5af.zip
Handle gdb command failure gracefully in compiletest
Previously, if the gdb command was available, but threw an error, compiletest would panic.  This is obviously not good. Now, gdb is treated as missing if calling `gdb --version` does not output anything on stdout.
-rw-r--r--src/tools/compiletest/src/main.rs17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index e3d453a991d..304143eaa0b 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -736,17 +736,12 @@ fn analyze_gdb(gdb: Option<String>) -> (Option<String>, Option<u32>, bool) {
         Some(ref s) => s,
     };
 
-    let version_line = Command::new(gdb)
-        .arg("--version")
-        .output()
-        .map(|output| {
-            String::from_utf8_lossy(&output.stdout)
-                .lines()
-                .next()
-                .unwrap()
-                .to_string()
-        })
-        .ok();
+    let mut version_line = None;
+    if let Ok(output) = Command::new(gdb).arg("--version").output() {
+        if let Some(first_line) = String::from_utf8_lossy(&output.stdout).lines().next() {
+            version_line = Some(first_line.to_string());
+        }
+    }
 
     let version = match version_line {
         Some(line) => extract_gdb_version(&line),