diff --git a/src/cargo.rs b/src/cargo.rs index 5360017d..1cf59e67 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -16,7 +16,7 @@ use crate::options::{Options, TestTool}; use crate::outcome::{Phase, PhaseResult}; use crate::output::ScenarioOutput; use crate::package::PackageSelection; -use crate::process::{Process, ProcessStatus}; +use crate::process::{Exit, Process}; use crate::Result; /// Run cargo build, check, or test. @@ -56,7 +56,7 @@ pub fn run_cargo( )?; check_interrupted()?; debug!(?process_status, elapsed = ?start.elapsed()); - if let ProcessStatus::Failure(code) = process_status { + if let Exit::Failure(code) = process_status { // 100 "one or more tests failed" from ; // I'm not addind a dependency to just get one integer. if argv[1] == "nextest" && code != 100 { diff --git a/src/outcome.rs b/src/outcome.rs index 72413032..0ca5cab3 100644 --- a/src/outcome.rs +++ b/src/outcome.rs @@ -14,7 +14,7 @@ use serde::Serializer; use tracing::warn; use crate::console::plural; -use crate::process::ProcessStatus; +use crate::process::Exit; use crate::*; /// What phase of running a scenario. @@ -193,7 +193,7 @@ impl ScenarioOutcome { self.phase_results.last().unwrap().phase } - pub fn last_phase_result(&self) -> ProcessStatus { + pub fn last_phase_result(&self) -> Exit { self.phase_results.last().unwrap().process_status } @@ -284,7 +284,7 @@ pub struct PhaseResult { /// How long did it take? pub duration: Duration, /// Did it succeed? - pub process_status: ProcessStatus, + pub process_status: Exit, /// What command was run, as an argv list. pub argv: Vec, } @@ -324,7 +324,7 @@ pub enum SummaryOutcome { mod test { use std::time::Duration; - use crate::process::ProcessStatus; + use crate::process::Exit; use super::{Phase, PhaseResult, Scenario, ScenarioOutcome}; @@ -339,13 +339,13 @@ mod test { PhaseResult { phase: Phase::Build, duration: Duration::from_secs(2), - process_status: ProcessStatus::Success, + process_status: Exit::Success, argv: vec!["cargo".into(), "build".into()], }, PhaseResult { phase: Phase::Test, duration: Duration::from_secs(3), - process_status: ProcessStatus::Success, + process_status: Exit::Success, argv: vec!["cargo".into(), "test".into()], }, ], @@ -355,7 +355,7 @@ mod test { Some(&PhaseResult { phase: Phase::Build, duration: Duration::from_secs(2), - process_status: ProcessStatus::Success, + process_status: Exit::Success, argv: vec!["cargo".into(), "build".into()], }) ); diff --git a/src/process.rs b/src/process.rs index c6a38b54..0582edd8 100644 --- a/src/process.rs +++ b/src/process.rs @@ -52,7 +52,7 @@ impl Process { jobserver: &Option, scenario_output: &mut ScenarioOutput, console: &Console, - ) -> Result { + ) -> Result { let mut child = Process::start(argv, env, cwd, timeout, jobserver, scenario_output)?; let process_status = loop { if let Some(exit_status) = child.poll()? { @@ -102,11 +102,11 @@ impl Process { /// Check if the child process has finished; if so, return its status. #[mutants::skip] // It's hard to avoid timeouts if this never works... - pub fn poll(&mut self) -> Result> { + pub fn poll(&mut self) -> Result> { if self.timeout.is_some_and(|t| self.start.elapsed() > t) { debug!("timeout, terminating child process...",); self.terminate()?; - Ok(Some(ProcessStatus::Timeout)) + Ok(Some(Exit::Timeout)) } else if let Err(e) = check_interrupted() { debug!("interrupted, terminating child process..."); self.terminate()?; @@ -139,7 +139,7 @@ impl Process { /// The result of running a single child process. #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize)] -pub enum ProcessStatus { +pub enum Exit { /// Exited with status 0. Success, /// Exited with status non-0. @@ -153,17 +153,17 @@ pub enum ProcessStatus { Other, } -impl ProcessStatus { +impl Exit { pub fn is_success(&self) -> bool { - *self == ProcessStatus::Success + *self == Exit::Success } pub fn is_timeout(&self) -> bool { - *self == ProcessStatus::Timeout + *self == Exit::Timeout } pub fn is_failure(&self) -> bool { - matches!(self, ProcessStatus::Failure(_)) + matches!(self, Exit::Failure(_)) } } diff --git a/src/process/unix.rs b/src/process/unix.rs index 89d00124..998af0c0 100644 --- a/src/process/unix.rs +++ b/src/process/unix.rs @@ -9,7 +9,7 @@ use tracing::warn; use crate::Result; -use super::ProcessStatus; +use super::Exit; #[allow(unknown_lints, clippy::needless_pass_by_ref_mut)] // To match Windows #[mutants::skip] // hard to exercise the ESRCH edge case @@ -37,16 +37,16 @@ pub(super) fn configure_command(command: &mut Command) { command.process_group(0); } -pub(super) fn interpret_exit(status: ExitStatus) -> ProcessStatus { +pub(super) fn interpret_exit(status: ExitStatus) -> Exit { if let Some(code) = status.code() { if code == 0 { - ProcessStatus::Success + Exit::Success } else { - ProcessStatus::Failure(code as u32) + Exit::Failure(code as u32) } } else if let Some(signal) = status.signal() { - return ProcessStatus::Signalled(signal as u8); + return Exit::Signalled(signal as u8); } else { - ProcessStatus::Other + Exit::Other } } diff --git a/src/process/windows.rs b/src/process/windows.rs index 284fc151..00b800bf 100644 --- a/src/process/windows.rs +++ b/src/process/windows.rs @@ -4,7 +4,7 @@ use anyhow::Context; use crate::Result; -use super::ProcessStatus; +use super::Exit; #[mutants::skip] // hard to exercise the ESRCH edge case pub(super) fn terminate_child(child: &mut Child) -> Result<()> { @@ -12,16 +12,16 @@ pub(super) fn terminate_child(child: &mut Child) -> Result<()> { } #[mutants::skip] -pub(super) fn configure_command(command: &mut Command) {} +pub(super) fn configure_command(_command: &mut Command) {} -pub(super) fn interpret_exit(status: ExitStatus) -> ProcessStatus { +pub(super) fn interpret_exit(status: ExitStatus) -> Exit { if let Some(code) = status.code() { if code == 0 { - ProcessStatus::Success + Exit::Success } else { - ProcessStatus::Failure(code as u32) + Exit::Failure(code as u32) } } else { - ProcessStatus::Other + Exit::Other } }