Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .vscode/cspell.dictionaries/workspace.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ libc
libstdbuf
musl
tmpd
uchild
ucmd
ucommand
utmpx
Expand All @@ -333,6 +334,7 @@ uucore_procs
uudoc
uumain
uutil
uutests
uutils

# * function names
Expand Down
63 changes: 57 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ uucore = { version = "0.0.30", package = "uucore", path = "src/uucore" }
uucore_procs = { version = "0.0.30", package = "uucore_procs", path = "src/uucore_procs" }
uu_ls = { version = "0.0.30", path = "src/uu/ls" }
uu_base32 = { version = "0.0.30", path = "src/uu/base32" }
uutests = { version = "0.0.30", package = "uutests", path = "tests/uutests/" }

[dependencies]
clap = { workspace = true }
Expand Down Expand Up @@ -505,6 +506,7 @@ sha1 = { workspace = true, features = ["std"] }
tempfile = { workspace = true }
time = { workspace = true, features = ["local-offset"] }
unindent = "0.2.3"
uutests = { workspace = true }
uucore = { workspace = true, features = [
"mode",
"entries",
Expand All @@ -515,6 +517,7 @@ uucore = { workspace = true, features = [
walkdir = { workspace = true }
hex-literal = "1.0.0"
rstest = { workspace = true }
ctor = "0.4.1"

[target.'cfg(any(target_os = "linux", target_os = "android"))'.dev-dependencies]
procfs = { version = "0.17", default-features = false }
Expand Down
4 changes: 3 additions & 1 deletion tests/by-util/test_arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use crate::common::util::TestScenario;
use uutests::new_ucmd;
use uutests::util::TestScenario;
use uutests::util_name;

#[test]
fn test_arch() {
Expand Down
4 changes: 3 additions & 1 deletion tests/by-util/test_base32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
// file that was distributed with this source code.
//

use crate::common::util::TestScenario;
use uutests::new_ucmd;
use uutests::util::TestScenario;
use uutests::util_name;

#[test]
fn test_encode() {
Expand Down
4 changes: 3 additions & 1 deletion tests/by-util/test_base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use crate::common::util::TestScenario;
use uutests::new_ucmd;
use uutests::util::TestScenario;
use uutests::util_name;

#[test]
fn test_encode() {
Expand Down
4 changes: 3 additions & 1 deletion tests/by-util/test_basename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
// file that was distributed with this source code.
// spell-checker:ignore (words) reallylongexecutable nbaz

use crate::common::util::TestScenario;
#[cfg(any(unix, target_os = "redox"))]
use std::ffi::OsStr;
use uutests::new_ucmd;
use uutests::util::TestScenario;
use uutests::util_name;

#[test]
fn test_help() {
Expand Down
4 changes: 3 additions & 1 deletion tests/by-util/test_basenc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

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

use crate::common::util::TestScenario;
use uutests::new_ucmd;
use uutests::util::TestScenario;
use uutests::util_name;

#[test]
fn test_z85_not_padded_decode() {
Expand Down
49 changes: 44 additions & 5 deletions tests/by-util/test_cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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");
}
5 changes: 4 additions & 1 deletion tests/by-util/test_chcon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use std::ffi::CString;
use std::path::Path;
use std::{io, iter, str};

use crate::common::util::*;
use uutests::at_and_ucmd;
use uutests::new_ucmd;
use uutests::util::TestScenario;
use uutests::util_name;

#[test]
fn version() {
Expand Down
5 changes: 4 additions & 1 deletion tests/by-util/test_chgrp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
// file that was distributed with this source code.
// spell-checker:ignore (words) nosuchgroup groupname

use crate::common::util::TestScenario;
use uucore::process::getegid;
use uutests::at_and_ucmd;
use uutests::new_ucmd;
use uutests::util::TestScenario;
use uutests::util_name;

#[test]
fn test_invalid_option() {
Expand Down
6 changes: 5 additions & 1 deletion tests/by-util/test_chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

use crate::common::util::{AtPath, TestScenario, UCommand};
use std::fs::{OpenOptions, Permissions, metadata, set_permissions};
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
use uutests::at_and_ucmd;
use uutests::util::{AtPath, TestScenario, UCommand};

use uutests::new_ucmd;
use uutests::util_name;

static TEST_FILE: &str = "file";
static REFERENCE_FILE: &str = "reference";
Expand Down
5 changes: 3 additions & 2 deletions tests/by-util/test_chown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
// file that was distributed with this source code.
// spell-checker:ignore (words) agroupthatdoesntexist auserthatdoesntexist cuuser groupname notexisting passgrp

use crate::common::util::{CmdResult, TestScenario, is_ci, run_ucmd_as_root};
#[cfg(any(target_os = "linux", target_os = "android"))]
use uucore::process::geteuid;

use uutests::new_ucmd;
use uutests::util::{CmdResult, TestScenario, is_ci, run_ucmd_as_root};
use uutests::util_name;
// Apparently some CI environments have configuration issues, e.g. with 'whoami' and 'id'.
// If we are running inside the CI and "needle" is in "stderr" skipping this test is
// considered okay. If we are not inside the CI this calls assert!(result.success).
Expand Down
7 changes: 5 additions & 2 deletions tests/by-util/test_chroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
// file that was distributed with this source code.
// spell-checker:ignore (words) araba newroot userspec chdir pwd's isroot

use uutests::at_and_ucmd;
use uutests::new_ucmd;
#[cfg(not(target_os = "android"))]
use crate::common::util::is_ci;
use crate::common::util::{TestScenario, run_ucmd_as_root};
use uutests::util::is_ci;
use uutests::util::{TestScenario, run_ucmd_as_root};
use uutests::util_name;

#[test]
fn test_invalid_arg() {
Expand Down
7 changes: 5 additions & 2 deletions tests/by-util/test_cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
// file that was distributed with this source code.
// spell-checker:ignore (words) asdf algo algos asha mgmt xffname hexa GFYEQ HYQK Yqxb dont

use crate::common::util::TestScenario;
use uutests::at_and_ucmd;
use uutests::new_ucmd;
use uutests::util::TestScenario;
use uutests::util_name;

const ALGOS: [&str; 11] = [
"sysv", "bsd", "crc", "md5", "sha1", "sha224", "sha256", "sha384", "sha512", "blake2b", "sm3",
Expand Down Expand Up @@ -1681,7 +1684,7 @@ fn test_check_incorrectly_formatted_checksum_keeps_processing_hex() {
/// This module reimplements the cksum-base64.pl GNU test.
mod gnu_cksum_base64 {
use super::*;
use crate::common::util::log_info;
use uutests::util::log_info;

const PAIRS: [(&str, &str); 12] = [
("sysv", "0 0 f"),
Expand Down
Loading
Loading