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::asynccmd::{AsyncCmd, SpawnedAsyncCmd};
|
||||||
|
use crate::message::buildresult::BuildStatus;
|
||||||
use crate::ofborg::partition_result;
|
use crate::ofborg::partition_result;
|
||||||
|
|
||||||
use tempfile::tempfile;
|
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
@ -12,6 +11,8 @@ use std::io::{BufRead, BufReader, Seek, SeekFrom};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
|
use tempfile::tempfile;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub enum File {
|
pub enum File {
|
||||||
DefaultNixpkgs,
|
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")
|
&& 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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
fn nix() -> Nix {
|
fn nix() -> Nix {
|
||||||
|
|
|
@ -361,23 +361,7 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
|
||||||
actions.log_line(&line);
|
actions.log_line(&line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this belongs in the nix module.
|
let status = nix::wait_for_build_status(spawned);
|
||||||
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),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
info!("ok built ({:?}), building", status);
|
info!("ok built ({:?}), building", status);
|
||||||
info!("Lines:");
|
info!("Lines:");
|
||||||
|
|
Loading…
Reference in a new issue