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::env;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::ffi::OsString; use std::ffi::OsString;
use std::fs; use std::fs;
use std::io::ErrorKind;
use std::iter; use std::iter;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::{Command, Stdio}; 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); 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_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb"));
let lldb_version = Command::new(&lldb_exe) let lldb_version = Command::new(&lldb_exe)
.arg("--version") .arg("--version")
.output() .output()
.and_then(|output| { .map(|output| {
if output.status.success() { Ok(output) } else { Err(ErrorKind::Other.into()) } (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 { 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); cmd.arg("--lldb-version").arg(vers);
let lldb_python_dir = run(Command::new(&lldb_exe).arg("-P")).ok(); let lldb_python_dir = run(Command::new(&lldb_exe).arg("-P")).ok();
if let Some(ref dir) = lldb_python_dir { if let Some(ref dir) = lldb_python_dir {