1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::Error;
use std::io::ErrorKind;
use std::path::Path;
use std::process::Command;
pub fn run_dotnet_command_if_installed<P: AsRef<Path>>(path: P, command: &str) -> Result<String, Error> {
let child = match Command::new("dotnet").arg(command).current_dir(path).spawn() {
Ok(x) => x,
Err(x @ std::io::Error { .. }) if x.kind() == ErrorKind::NotFound => {
return Ok("dotnet not found, skipped".to_string());
}
Err(x) => return Err(Error::IO(x)),
};
let output = child.wait_with_output()?;
if output.status.success() {
Ok(output.status.to_string())
} else {
Err(Error::TestFailed)
}
}