Update test.rs

This commit is contained in:
Chris Denton 2024-06-29 07:57:58 +00:00
parent fa12064d6d
commit a6ef91e414
No known key found for this signature in database
GPG key ID: 713472F2F45627DE

View file

@ -7,7 +7,6 @@
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 @@ fn run(self, builder: &Builder<'_>) {
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 {