move exit status handling to nix module
This commit is contained in:
parent
0cef8f4e0d
commit
cc89c1a88d
|
@ -1,8 +1,7 @@
|
|||
use crate::asynccmd::{AsyncCmd, SpawnedAsyncCmd};
|
||||
use crate::message::buildresult::BuildStatus;
|
||||
use crate::ofborg::partition_result;
|
||||
|
||||
use tempfile::tempfile;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::ffi::OsStr;
|
||||
|
@ -12,6 +11,8 @@ use std::io::{BufRead, BufReader, Seek, SeekFrom};
|
|||
use std::path::Path;
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
use tempfile::tempfile;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum File {
|
||||
DefaultNixpkgs,
|
||||
|
@ -358,6 +359,25 @@ pub fn is_user_setting_warning(line: &str) -> bool {
|
|||
&& line.ends_with("because it is a restricted setting and you are not a trusted user")
|
||||
}
|
||||
|
||||
pub fn wait_for_build_status(spawned: SpawnedAsyncCmd) -> BuildStatus {
|
||||
match spawned.wait() {
|
||||
Ok(s) => match s.code() {
|
||||
Some(0) => BuildStatus::Success,
|
||||
Some(100) => BuildStatus::Failure, // nix permanent failure
|
||||
Some(101) => BuildStatus::TimedOut, // nix build timedout
|
||||
Some(i) => BuildStatus::UnexpectedError {
|
||||
err: format!("command failed with exit code {}", i),
|
||||
},
|
||||
None => BuildStatus::UnexpectedError {
|
||||
err: "unexpected build failure".into(),
|
||||
},
|
||||
},
|
||||
e => BuildStatus::UnexpectedError {
|
||||
err: format!("failed on interior command {:?}", e),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
fn nix() -> Nix {
|
||||
|
|
|
@ -361,23 +361,7 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
|
|||
actions.log_line(&line);
|
||||
}
|
||||
|
||||
// TODO: this belongs in the nix module.
|
||||
let status = match spawned.wait() {
|
||||
Ok(s) => match s.code() {
|
||||
Some(0) => BuildStatus::Success,
|
||||
Some(100) => BuildStatus::Failure, // nix permanent failure
|
||||
Some(101) => BuildStatus::TimedOut, // nix build timedout
|
||||
Some(i) => BuildStatus::UnexpectedError {
|
||||
err: format!("command failed with exit code {}", i),
|
||||
},
|
||||
None => BuildStatus::UnexpectedError {
|
||||
err: "unexpected build failure".into(),
|
||||
},
|
||||
},
|
||||
e => BuildStatus::UnexpectedError {
|
||||
err: format!("failed on interior command {:?}", e),
|
||||
},
|
||||
};
|
||||
let status = nix::wait_for_build_status(spawned);
|
||||
|
||||
info!("ok built ({:?}), building", status);
|
||||
info!("Lines:");
|
||||
|
|
Loading…
Reference in a new issue