Fix inverted was_killed logic (#1779)
Also improve the error messages and code structure.
This commit is contained in:
parent
b0bc4a79c9
commit
d4915c18e7
|
|
@ -490,30 +490,36 @@ impl<T> TestOutput<T> {
|
||||||
/// reason.
|
/// reason.
|
||||||
pub fn assert_was_killed(&self) -> Result<()> {
|
pub fn assert_was_killed(&self) -> Result<()> {
|
||||||
if self.was_killed() {
|
if self.was_killed() {
|
||||||
Err(eyre!("command was killed")).context_from(self)?
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(eyre!(
|
||||||
|
"command exited without a kill, but the test expected kill exit"
|
||||||
|
))
|
||||||
|
.context_from(self)?
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns Ok if the program was not killed, Err(Report) if exit was by
|
/// Returns Ok if the program was not killed, Err(Report) if exit was by
|
||||||
/// another reason.
|
/// another reason.
|
||||||
pub fn assert_was_not_killed(&self) -> Result<()> {
|
pub fn assert_was_not_killed(&self) -> Result<()> {
|
||||||
if !self.was_killed() {
|
if self.was_killed() {
|
||||||
Err(eyre!("command wasn't killed")).context_from(self)?
|
Err(eyre!(
|
||||||
|
"command was killed, but the test expected an exit without a kill"
|
||||||
|
))
|
||||||
|
.context_from(self)?
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
fn was_killed(&self) -> bool {
|
fn was_killed(&self) -> bool {
|
||||||
self.output.status.code() != Some(1)
|
self.output.status.code() == Some(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn was_killed(&self) -> bool {
|
fn was_killed(&self) -> bool {
|
||||||
self.output.status.signal() != Some(9)
|
self.output.status.signal() == Some(9)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue