Skip to content

Commit 1a763a4

Browse files
committed
uutests: adjust the tests to use them
1 parent 6948135 commit 1a763a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1018
-157
lines changed

tests/by-util/test_arch.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
//
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
5-
use crate::common::util::TestScenario;
5+
use uutests::new_ucmd;
6+
use uutests::util::TestScenario;
7+
use uutests::util_name;
68

79
#[test]
810
fn test_arch() {

tests/by-util/test_base32.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
// file that was distributed with this source code.
55
//
66

7-
use crate::common::util::TestScenario;
7+
use uutests::new_ucmd;
8+
use uutests::util::TestScenario;
9+
use uutests::util_name;
810

911
#[test]
1012
fn test_encode() {

tests/by-util/test_base64.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
//
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
5-
use crate::common::util::TestScenario;
5+
use uutests::new_ucmd;
6+
use uutests::util::TestScenario;
7+
use uutests::util_name;
68

79
#[test]
810
fn test_encode() {

tests/by-util/test_basename.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
// file that was distributed with this source code.
55
// spell-checker:ignore (words) reallylongexecutable nbaz
66

7-
use crate::common::util::TestScenario;
87
#[cfg(any(unix, target_os = "redox"))]
98
use std::ffi::OsStr;
9+
use uutests::new_ucmd;
10+
use uutests::util::TestScenario;
11+
use uutests::util_name;
1012

1113
#[test]
1214
fn test_help() {

tests/by-util/test_basenc.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
// spell-checker: ignore (encodings) lsbf msbf
77

8-
use crate::common::util::TestScenario;
8+
use uutests::new_ucmd;
9+
use uutests::util::TestScenario;
10+
use uutests::util_name;
911

1012
#[test]
1113
fn test_z85_not_padded_decode() {

tests/by-util/test_cat.rs

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
// file that was distributed with this source code.
55
// spell-checker:ignore NOFILE nonewline cmdline
66

7-
use crate::common::util::TestScenario;
8-
#[cfg(not(windows))]
9-
use crate::common::util::vec_of_size;
107
#[cfg(any(target_os = "linux", target_os = "android"))]
118
use rlimit::Resource;
12-
#[cfg(target_os = "linux")]
9+
#[cfg(unix)]
1310
use std::fs::File;
1411
use std::fs::OpenOptions;
15-
#[cfg(not(windows))]
1612
use std::process::Stdio;
13+
use uutests::at_and_ucmd;
14+
use uutests::new_ucmd;
15+
use uutests::util::TestScenario;
16+
#[cfg(not(windows))]
17+
use uutests::util::vec_of_size;
18+
use uutests::util_name;
1719

1820
#[test]
1921
fn test_output_simple() {
@@ -668,3 +670,40 @@ fn test_appending_same_input_output() {
668670
.no_stdout()
669671
.stderr_contains("input file is output file");
670672
}
673+
674+
#[cfg(unix)]
675+
#[test]
676+
fn test_uchild_when_no_capture_reading_from_infinite_source() {
677+
use regex::Regex;
678+
679+
let ts = TestScenario::new("cat");
680+
681+
let expected_stdout = b"\0".repeat(12345);
682+
let mut child = ts
683+
.ucmd()
684+
.set_stdin(Stdio::from(File::open("/dev/zero").unwrap()))
685+
.set_stdout(Stdio::piped())
686+
.run_no_wait();
687+
688+
child
689+
.make_assertion()
690+
.with_exact_output(12345, 0)
691+
.stdout_only_bytes(expected_stdout);
692+
693+
child
694+
.kill()
695+
.make_assertion()
696+
.with_current_output()
697+
.stdout_matches(&Regex::new("[\0].*").unwrap())
698+
.no_stderr();
699+
}
700+
701+
#[test]
702+
fn test_child_when_pipe_in() {
703+
let ts = TestScenario::new("cat");
704+
let mut child = ts.ucmd().set_stdin(Stdio::piped()).run_no_wait();
705+
child.pipe_in("content");
706+
child.wait().unwrap().stdout_only("content").success();
707+
708+
ts.ucmd().pipe_in("content").run().stdout_is("content");
709+
}

tests/by-util/test_chcon.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ use std::ffi::CString;
1010
use std::path::Path;
1111
use std::{io, iter, str};
1212

13-
use crate::common::util::*;
13+
use uutests::at_and_ucmd;
14+
use uutests::new_ucmd;
15+
use uutests::util::TestScenario;
16+
use uutests::util_name;
1417

1518
#[test]
1619
fn version() {

tests/by-util/test_chgrp.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
// file that was distributed with this source code.
55
// spell-checker:ignore (words) nosuchgroup groupname
66

7-
use crate::common::util::TestScenario;
87
use uucore::process::getegid;
8+
use uutests::at_and_ucmd;
9+
use uutests::new_ucmd;
10+
use uutests::util::TestScenario;
11+
use uutests::util_name;
912

1013
#[test]
1114
fn test_invalid_option() {

tests/by-util/test_chmod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55

6-
use crate::common::util::{AtPath, TestScenario, UCommand};
76
use std::fs::{OpenOptions, Permissions, metadata, set_permissions};
87
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
8+
use uutests::at_and_ucmd;
9+
use uutests::util::{AtPath, TestScenario, UCommand};
10+
11+
use uutests::new_ucmd;
12+
use uutests::util_name;
913

1014
static TEST_FILE: &str = "file";
1115
static REFERENCE_FILE: &str = "reference";

tests/by-util/test_chown.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
// file that was distributed with this source code.
55
// spell-checker:ignore (words) agroupthatdoesntexist auserthatdoesntexist cuuser groupname notexisting passgrp
66

7-
use crate::common::util::{CmdResult, TestScenario, is_ci, run_ucmd_as_root};
87
#[cfg(any(target_os = "linux", target_os = "android"))]
98
use uucore::process::geteuid;
10-
9+
use uutests::new_ucmd;
10+
use uutests::util::{CmdResult, TestScenario, is_ci, run_ucmd_as_root};
11+
use uutests::util_name;
1112
// Apparently some CI environments have configuration issues, e.g. with 'whoami' and 'id'.
1213
// If we are running inside the CI and "needle" is in "stderr" skipping this test is
1314
// considered okay. If we are not inside the CI this calls assert!(result.success).

0 commit comments

Comments
 (0)