mirror of
https://github.com/marcoallegretti/karapace.git
synced 2026-03-27 05:53:10 +00:00
perf(runtime): avoid spawning external true in mock backend
This commit is contained in:
parent
1bc69c00dc
commit
c576321479
1 changed files with 9 additions and 8 deletions
|
|
@ -107,14 +107,15 @@ impl RuntimeBackend for MockBackend {
|
||||||
command: &[String],
|
command: &[String],
|
||||||
) -> Result<std::process::Output, RuntimeError> {
|
) -> Result<std::process::Output, RuntimeError> {
|
||||||
let stdout = format!("mock-exec: {}\n", command.join(" "));
|
let stdout = format!("mock-exec: {}\n", command.join(" "));
|
||||||
// Create a real success ExitStatus portably
|
|
||||||
let success_status = std::process::Command::new("true")
|
#[cfg(unix)]
|
||||||
.status()
|
let success_status = {
|
||||||
.unwrap_or_else(|_| {
|
use std::os::unix::process::ExitStatusExt;
|
||||||
std::process::Command::new("/bin/true")
|
std::process::ExitStatus::from_raw(0)
|
||||||
.status()
|
};
|
||||||
.expect("cannot execute /bin/true")
|
|
||||||
});
|
#[cfg(not(unix))]
|
||||||
|
let success_status = std::process::Command::new("true").status()?;
|
||||||
Ok(std::process::Output {
|
Ok(std::process::Output {
|
||||||
status: success_status,
|
status: success_status,
|
||||||
stdout: stdout.into_bytes(),
|
stdout: stdout.into_bytes(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue