mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Merge pull request #2650 from blyxxyz/tty-flaky-test
tty: Make test_stdout_fail() less flaky
This commit is contained in:
commit
92a1f1422e
3 changed files with 19 additions and 28 deletions
|
@ -11,6 +11,7 @@ use super::format_field::FormatField;
|
|||
// output for a number, organized together
|
||||
// to allow for easy generalization of output manipulation
|
||||
// (e.g. max number of digits after decimal)
|
||||
#[derive(Default)]
|
||||
pub struct FormatPrimitive {
|
||||
pub prefix: Option<String>,
|
||||
pub pre_decimal: Option<String>,
|
||||
|
@ -18,17 +19,6 @@ pub struct FormatPrimitive {
|
|||
pub suffix: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for FormatPrimitive {
|
||||
fn default() -> FormatPrimitive {
|
||||
FormatPrimitive {
|
||||
prefix: None,
|
||||
pre_decimal: None,
|
||||
post_decimal: None,
|
||||
suffix: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub enum Base {
|
||||
Ten = 10,
|
||||
|
|
|
@ -800,7 +800,7 @@ impl Default for KeyPosition {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug, Default)]
|
||||
struct FieldSelector {
|
||||
from: KeyPosition,
|
||||
to: Option<KeyPosition>,
|
||||
|
@ -812,18 +812,6 @@ struct FieldSelector {
|
|||
needs_selection: bool,
|
||||
}
|
||||
|
||||
impl Default for FieldSelector {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
from: Default::default(),
|
||||
to: None,
|
||||
settings: Default::default(),
|
||||
needs_tokens: false,
|
||||
needs_selection: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FieldSelector {
|
||||
/// Splits this position into the actual position and the attached options.
|
||||
fn split_key_options(position: &str) -> (&str, &str) {
|
||||
|
|
|
@ -66,10 +66,23 @@ fn test_wrong_argument() {
|
|||
|
||||
#[test]
|
||||
// FixME: freebsd panic
|
||||
#[cfg(not(any(windows, target_os = "freebsd")))]
|
||||
#[cfg(all(unix, not(target_os = "freebsd")))]
|
||||
fn test_stdout_fail() {
|
||||
let mut child = new_ucmd!().run_no_wait();
|
||||
drop(child.stdout.take());
|
||||
let status = child.wait().unwrap();
|
||||
use std::process::{Command, Stdio};
|
||||
let ts = TestScenario::new(util_name!());
|
||||
// Sleep inside a shell to ensure the process doesn't finish before we've
|
||||
// closed its stdout
|
||||
let mut proc = Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(format!(
|
||||
"sleep 0.2; exec {} {}",
|
||||
ts.bin_path.to_str().unwrap(),
|
||||
ts.util_name
|
||||
))
|
||||
.stdout(Stdio::piped())
|
||||
.spawn()
|
||||
.unwrap();
|
||||
drop(proc.stdout.take());
|
||||
let status = proc.wait().unwrap();
|
||||
assert_eq!(status.code(), Some(3));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue