mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
uutests: adjust the tests to use them
This commit is contained in:
parent
ccfcda531e
commit
a0179ea239
102 changed files with 1018 additions and 157 deletions
|
@ -4,16 +4,18 @@
|
|||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore NOFILE nonewline cmdline
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
#[cfg(not(windows))]
|
||||
use crate::common::util::vec_of_size;
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use rlimit::Resource;
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(unix)]
|
||||
use std::fs::File;
|
||||
use std::fs::OpenOptions;
|
||||
#[cfg(not(windows))]
|
||||
use std::process::Stdio;
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
#[cfg(not(windows))]
|
||||
use uutests::util::vec_of_size;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_output_simple() {
|
||||
|
@ -668,3 +670,40 @@ fn test_appending_same_input_output() {
|
|||
.no_stdout()
|
||||
.stderr_contains("input file is output file");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn test_uchild_when_no_capture_reading_from_infinite_source() {
|
||||
use regex::Regex;
|
||||
|
||||
let ts = TestScenario::new("cat");
|
||||
|
||||
let expected_stdout = b"\0".repeat(12345);
|
||||
let mut child = ts
|
||||
.ucmd()
|
||||
.set_stdin(Stdio::from(File::open("/dev/zero").unwrap()))
|
||||
.set_stdout(Stdio::piped())
|
||||
.run_no_wait();
|
||||
|
||||
child
|
||||
.make_assertion()
|
||||
.with_exact_output(12345, 0)
|
||||
.stdout_only_bytes(expected_stdout);
|
||||
|
||||
child
|
||||
.kill()
|
||||
.make_assertion()
|
||||
.with_current_output()
|
||||
.stdout_matches(&Regex::new("[\0].*").unwrap())
|
||||
.no_stderr();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_child_when_pipe_in() {
|
||||
let ts = TestScenario::new("cat");
|
||||
let mut child = ts.ucmd().set_stdin(Stdio::piped()).run_no_wait();
|
||||
child.pipe_in("content");
|
||||
child.wait().unwrap().stdout_only("content").success();
|
||||
|
||||
ts.ucmd().pipe_in("content").run().stdout_is("content");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue