From fa12064d6de52baeb3ca4f5fdc26828facb6c11c Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Sat, 29 Jun 2024 07:27:25 +0000 Subject: [PATCH 1/2] Don't get output if `lldb --version` errors --- src/bootstrap/src/core/build_steps/test.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 1ef5af7cc2daf..55010f09049eb 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -7,6 +7,7 @@ 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}; @@ -1830,6 +1831,9 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the 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()) .ok(); if let Some(ref vers) = lldb_version { From a6ef91e41425ba315cb11ee20a99f3fdc714c6cf Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Sat, 29 Jun 2024 07:57:58 +0000 Subject: [PATCH 2/2] Update test.rs --- src/bootstrap/src/core/build_steps/test.rs | 28 ++++++++++------------ 1 file 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 55010f09049eb..7ac39227d3f17 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 {