mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37: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
|
// output for a number, organized together
|
||||||
// to allow for easy generalization of output manipulation
|
// to allow for easy generalization of output manipulation
|
||||||
// (e.g. max number of digits after decimal)
|
// (e.g. max number of digits after decimal)
|
||||||
|
#[derive(Default)]
|
||||||
pub struct FormatPrimitive {
|
pub struct FormatPrimitive {
|
||||||
pub prefix: Option<String>,
|
pub prefix: Option<String>,
|
||||||
pub pre_decimal: Option<String>,
|
pub pre_decimal: Option<String>,
|
||||||
|
@ -18,17 +19,6 @@ pub struct FormatPrimitive {
|
||||||
pub suffix: Option<String>,
|
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)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub enum Base {
|
pub enum Base {
|
||||||
Ten = 10,
|
Ten = 10,
|
||||||
|
|
|
@ -800,7 +800,7 @@ impl Default for KeyPosition {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Debug, Default)]
|
||||||
struct FieldSelector {
|
struct FieldSelector {
|
||||||
from: KeyPosition,
|
from: KeyPosition,
|
||||||
to: Option<KeyPosition>,
|
to: Option<KeyPosition>,
|
||||||
|
@ -812,18 +812,6 @@ struct FieldSelector {
|
||||||
needs_selection: bool,
|
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 {
|
impl FieldSelector {
|
||||||
/// Splits this position into the actual position and the attached options.
|
/// Splits this position into the actual position and the attached options.
|
||||||
fn split_key_options(position: &str) -> (&str, &str) {
|
fn split_key_options(position: &str) -> (&str, &str) {
|
||||||
|
|
|
@ -66,10 +66,23 @@ fn test_wrong_argument() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
// FixME: freebsd panic
|
// FixME: freebsd panic
|
||||||
#[cfg(not(any(windows, target_os = "freebsd")))]
|
#[cfg(all(unix, not(target_os = "freebsd")))]
|
||||||
fn test_stdout_fail() {
|
fn test_stdout_fail() {
|
||||||
let mut child = new_ucmd!().run_no_wait();
|
use std::process::{Command, Stdio};
|
||||||
drop(child.stdout.take());
|
let ts = TestScenario::new(util_name!());
|
||||||
let status = child.wait().unwrap();
|
// 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));
|
assert_eq!(status.code(), Some(3));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue