about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Denton <chris@chrisdenton.dev>2024-06-29 07:57:58 +0000
committerChris Denton <chris@chrisdenton.dev>2024-06-29 07:57:58 +0000
commita6ef91e41425ba315cb11ee20a99f3fdc714c6cf (patch)
tree7e310aeda9535dbcd85789a359f436ac8ab29576
parentfa12064d6de52baeb3ca4f5fdc26828facb6c11c (diff)
downloadrust-a6ef91e41425ba315cb11ee20a99f3fdc714c6cf.tar.gz
rust-a6ef91e41425ba315cb11ee20a99f3fdc714c6cf.zip
Update test.rs
-rw-r--r--src/bootstrap/src/core/build_steps/test.rs28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs
index 55010f09049..7ac39227d3f 100644
--- a/src/bootstrap/src/core/build_steps/test.rs
+++ b/src/bootstrap/src/core/build_steps/test.rs
@@ -7,7 +7,6 @@ use std::env;
 use std::ffi::OsStr;
 use std::ffi::OsString;
 use std::fs;
-use std::io::ErrorKind;
 use std::iter;
 use std::path::{Path, PathBuf};
 use std::process::{Command, Stdio};
@@ -1817,26 +1816,25 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
             cmd.arg("--gdb").arg(gdb);
         }
 
-        let run = |cmd: &mut Command| {
-            cmd.output().map(|output| {
-                String::from_utf8_lossy(&output.stdout)
-                    .lines()
-                    .next()
-                    .unwrap_or_else(|| panic!("{:?} failed {:?}", cmd, output))
-                    .to_string()
-            })
-        };
-
         let lldb_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb"));
         let lldb_version = Command::new(&lldb_exe)
             .arg("--version")
             .output()
-            .and_then(|output| {
-                if output.status.success() { Ok(output) } else { Err(ErrorKind::Other.into()) }
+            .map(|output| {
+                (String::from_utf8_lossy(&output.stdout).to_string(), output.status.success())
             })
-            .map(|output| String::from_utf8_lossy(&output.stdout).to_string())
-            .ok();
+            .ok()
+            .and_then(|(output, success)| if success { Some(output) } else { None });
         if let Some(ref vers) = lldb_version {
+            let run = |cmd: &mut Command| {
+                cmd.output().map(|output| {
+                    String::from_utf8_lossy(&output.stdout)
+                        .lines()
+                        .next()
+                        .unwrap_or_else(|| panic!("{:?} failed {:?}", cmd, output))
+                        .to_string()
+                })
+            };
             cmd.arg("--lldb-version").arg(vers);
             let lldb_python_dir = run(Command::new(&lldb_exe).arg("-P")).ok();
             if let Some(ref dir) = lldb_python_dir {