mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #7598 from sylvestre/uutests2
Move our tests infra into a dedicated crate
This commit is contained in:
commit
61b7f4b54b
113 changed files with 1337 additions and 935 deletions
|
@ -325,6 +325,7 @@ libc
|
||||||
libstdbuf
|
libstdbuf
|
||||||
musl
|
musl
|
||||||
tmpd
|
tmpd
|
||||||
|
uchild
|
||||||
ucmd
|
ucmd
|
||||||
ucommand
|
ucommand
|
||||||
utmpx
|
utmpx
|
||||||
|
@ -333,6 +334,7 @@ uucore_procs
|
||||||
uudoc
|
uudoc
|
||||||
uumain
|
uumain
|
||||||
uutil
|
uutil
|
||||||
|
uutests
|
||||||
uutils
|
uutils
|
||||||
|
|
||||||
# * function names
|
# * function names
|
||||||
|
|
63
Cargo.lock
generated
63
Cargo.lock
generated
|
@ -448,6 +448,7 @@ dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"clap_complete",
|
"clap_complete",
|
||||||
"clap_mangen",
|
"clap_mangen",
|
||||||
|
"ctor",
|
||||||
"filetime",
|
"filetime",
|
||||||
"glob",
|
"glob",
|
||||||
"hex-literal",
|
"hex-literal",
|
||||||
|
@ -574,6 +575,7 @@ dependencies = [
|
||||||
"uu_yes",
|
"uu_yes",
|
||||||
"uucore",
|
"uucore",
|
||||||
"uuhelp_parser",
|
"uuhelp_parser",
|
||||||
|
"uutests",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
"xattr",
|
"xattr",
|
||||||
"zip",
|
"zip",
|
||||||
|
@ -724,6 +726,22 @@ dependencies = [
|
||||||
"typenum",
|
"typenum",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ctor"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "07e9666f4a9a948d4f1dff0c08a4512b0f7c86414b23960104c243c10d79f4c3"
|
||||||
|
dependencies = [
|
||||||
|
"ctor-proc-macro",
|
||||||
|
"dtor",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ctor-proc-macro"
|
||||||
|
version = "0.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4f211af61d8efdd104f96e57adf5e426ba1bc3ed7a4ead616e15e5881fd79c4d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ctrlc"
|
name = "ctrlc"
|
||||||
version = "3.4.5"
|
version = "3.4.5"
|
||||||
|
@ -817,6 +835,21 @@ dependencies = [
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dtor"
|
||||||
|
version = "0.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "222ef136a1c687d4aa0395c175f2c4586e379924c352fd02f7870cf7de783c23"
|
||||||
|
dependencies = [
|
||||||
|
"dtor-proc-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dtor-proc-macro"
|
||||||
|
version = "0.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7454e41ff9012c00d53cf7f475c5e3afa3b91b7c90568495495e8d9bf47a1055"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dunce"
|
name = "dunce"
|
||||||
version = "1.0.5"
|
version = "1.0.5"
|
||||||
|
@ -848,7 +881,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1259,7 +1292,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
|
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"windows-targets 0.48.5",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1989,7 +2022,7 @@ dependencies = [
|
||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys 0.4.15",
|
"linux-raw-sys 0.4.15",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2002,7 +2035,7 @@ dependencies = [
|
||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys 0.9.3",
|
"linux-raw-sys 0.9.3",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2246,7 +2279,7 @@ dependencies = [
|
||||||
"getrandom 0.3.1",
|
"getrandom 0.3.1",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix 1.0.1",
|
"rustix 1.0.1",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3531,6 +3564,24 @@ version = "1.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e0f540e3240398cce6128b64ba83fdbdd86129c16a3aa1a3a252efd66eb3d587"
|
checksum = "e0f540e3240398cce6128b64ba83fdbdd86129c16a3aa1a3a252efd66eb3d587"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uutests"
|
||||||
|
version = "0.0.30"
|
||||||
|
dependencies = [
|
||||||
|
"ctor",
|
||||||
|
"glob",
|
||||||
|
"libc",
|
||||||
|
"nix",
|
||||||
|
"pretty_assertions",
|
||||||
|
"rand 0.9.0",
|
||||||
|
"regex",
|
||||||
|
"rlimit",
|
||||||
|
"tempfile",
|
||||||
|
"time",
|
||||||
|
"uucore",
|
||||||
|
"xattr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uutils_term_grid"
|
name = "uutils_term_grid"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
|
@ -3670,7 +3721,7 @@ version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -365,6 +365,7 @@ uucore = { version = "0.0.30", package = "uucore", path = "src/uucore" }
|
||||||
uucore_procs = { version = "0.0.30", package = "uucore_procs", path = "src/uucore_procs" }
|
uucore_procs = { version = "0.0.30", package = "uucore_procs", path = "src/uucore_procs" }
|
||||||
uu_ls = { version = "0.0.30", path = "src/uu/ls" }
|
uu_ls = { version = "0.0.30", path = "src/uu/ls" }
|
||||||
uu_base32 = { version = "0.0.30", path = "src/uu/base32" }
|
uu_base32 = { version = "0.0.30", path = "src/uu/base32" }
|
||||||
|
uutests = { version = "0.0.30", package = "uutests", path = "tests/uutests/" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { workspace = true }
|
clap = { workspace = true }
|
||||||
|
@ -504,6 +505,7 @@ sha1 = { workspace = true, features = ["std"] }
|
||||||
tempfile = { workspace = true }
|
tempfile = { workspace = true }
|
||||||
time = { workspace = true, features = ["local-offset"] }
|
time = { workspace = true, features = ["local-offset"] }
|
||||||
unindent = "0.2.3"
|
unindent = "0.2.3"
|
||||||
|
uutests = { workspace = true }
|
||||||
uucore = { workspace = true, features = [
|
uucore = { workspace = true, features = [
|
||||||
"mode",
|
"mode",
|
||||||
"entries",
|
"entries",
|
||||||
|
@ -514,6 +516,7 @@ uucore = { workspace = true, features = [
|
||||||
walkdir = { workspace = true }
|
walkdir = { workspace = true }
|
||||||
hex-literal = "1.0.0"
|
hex-literal = "1.0.0"
|
||||||
rstest = { workspace = true }
|
rstest = { workspace = true }
|
||||||
|
ctor = "0.4.1"
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dev-dependencies]
|
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dev-dependencies]
|
||||||
procfs = { version = "0.17", default-features = false }
|
procfs = { version = "0.17", default-features = false }
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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]
|
#[test]
|
||||||
fn test_arch() {
|
fn test_arch() {
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
// file that was distributed with this source code.
|
// 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]
|
#[test]
|
||||||
fn test_encode() {
|
fn test_encode() {
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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]
|
#[test]
|
||||||
fn test_encode() {
|
fn test_encode() {
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (words) reallylongexecutable nbaz
|
// spell-checker:ignore (words) reallylongexecutable nbaz
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
#[cfg(any(unix, target_os = "redox"))]
|
#[cfg(any(unix, target_os = "redox"))]
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_help() {
|
fn test_help() {
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
// spell-checker: ignore (encodings) lsbf msbf
|
// spell-checker: ignore (encodings) lsbf msbf
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_z85_not_padded_decode() {
|
fn test_z85_not_padded_decode() {
|
||||||
|
|
|
@ -4,16 +4,18 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore NOFILE nonewline cmdline
|
// 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"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
use rlimit::Resource;
|
use rlimit::Resource;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(unix)]
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
#[cfg(not(windows))]
|
|
||||||
use std::process::Stdio;
|
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]
|
#[test]
|
||||||
fn test_output_simple() {
|
fn test_output_simple() {
|
||||||
|
@ -668,3 +670,40 @@ fn test_appending_same_input_output() {
|
||||||
.no_stdout()
|
.no_stdout()
|
||||||
.stderr_contains("input file is output file");
|
.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");
|
||||||
|
}
|
||||||
|
|
|
@ -10,7 +10,10 @@ use std::ffi::CString;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::{io, iter, str};
|
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]
|
#[test]
|
||||||
fn version() {
|
fn version() {
|
||||||
|
|
|
@ -4,8 +4,11 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (words) nosuchgroup groupname
|
// spell-checker:ignore (words) nosuchgroup groupname
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use uucore::process::getegid;
|
use uucore::process::getegid;
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_option() {
|
fn test_invalid_option() {
|
||||||
|
|
|
@ -3,9 +3,13 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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::fs::{OpenOptions, Permissions, metadata, set_permissions};
|
||||||
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
|
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 TEST_FILE: &str = "file";
|
||||||
static REFERENCE_FILE: &str = "reference";
|
static REFERENCE_FILE: &str = "reference";
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (words) agroupthatdoesntexist auserthatdoesntexist cuuser groupname notexisting passgrp
|
// 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"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
use uucore::process::geteuid;
|
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'.
|
// 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
|
// 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).
|
// considered okay. If we are not inside the CI this calls assert!(result.success).
|
||||||
|
|
|
@ -4,9 +4,12 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (words) araba newroot userspec chdir pwd's isroot
|
// 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"))]
|
#[cfg(not(target_os = "android"))]
|
||||||
use crate::common::util::is_ci;
|
use uutests::util::is_ci;
|
||||||
use crate::common::util::{TestScenario, run_ucmd_as_root};
|
use uutests::util::{TestScenario, run_ucmd_as_root};
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (words) asdf algo algos asha mgmt xffname hexa GFYEQ HYQK Yqxb dont
|
// 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] = [
|
const ALGOS: [&str; 11] = [
|
||||||
"sysv", "bsd", "crc", "md5", "sha1", "sha224", "sha256", "sha384", "sha512", "blake2b", "sm3",
|
"sysv", "bsd", "crc", "md5", "sha1", "sha224", "sha256", "sha384", "sha512", "blake2b", "sm3",
|
||||||
|
@ -1681,7 +1684,7 @@ fn test_check_incorrectly_formatted_checksum_keeps_processing_hex() {
|
||||||
/// This module reimplements the cksum-base64.pl GNU test.
|
/// This module reimplements the cksum-base64.pl GNU test.
|
||||||
mod gnu_cksum_base64 {
|
mod gnu_cksum_base64 {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::common::util::log_info;
|
use uutests::util::log_info;
|
||||||
|
|
||||||
const PAIRS: [(&str, &str); 12] = [
|
const PAIRS: [(&str, &str); 12] = [
|
||||||
("sysv", "0 0 f"),
|
("sysv", "0 0 f"),
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (words) defaultcheck nocheck helpb helpz nwordb nwordwordz wordtotal
|
// spell-checker:ignore (words) defaultcheck nocheck helpb helpz nwordb nwordwordz wordtotal
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -4,7 +4,12 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs neve ROOTDIR USERDIR procfs outfile uufs xattrs
|
// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs neve ROOTDIR USERDIR procfs outfile uufs xattrs
|
||||||
// spell-checker:ignore bdfl hlsl IRWXO IRWXG getfattr
|
// spell-checker:ignore bdfl hlsl IRWXO IRWXG getfattr
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::path_concat;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
use std::fs::set_permissions;
|
use std::fs::set_permissions;
|
||||||
|
|
||||||
|
@ -34,7 +39,7 @@ use std::time::Duration;
|
||||||
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
#[cfg(feature = "truncate")]
|
#[cfg(feature = "truncate")]
|
||||||
use crate::common::util::PATH;
|
use uutests::util::PATH;
|
||||||
|
|
||||||
static TEST_EXISTING_FILE: &str = "existing_file.txt";
|
static TEST_EXISTING_FILE: &str = "existing_file.txt";
|
||||||
static TEST_HELLO_WORLD_SOURCE: &str = "hello_world.txt";
|
static TEST_HELLO_WORLD_SOURCE: &str = "hello_world.txt";
|
||||||
|
@ -60,7 +65,7 @@ static TEST_NONEXISTENT_FILE: &str = "nonexistent_file.txt";
|
||||||
unix,
|
unix,
|
||||||
not(any(target_os = "android", target_os = "macos", target_os = "openbsd"))
|
not(any(target_os = "android", target_os = "macos", target_os = "openbsd"))
|
||||||
))]
|
))]
|
||||||
use crate::common::util::compare_xattrs;
|
use uutests::util::compare_xattrs;
|
||||||
|
|
||||||
/// Assert that mode, ownership, and permissions of two metadata objects match.
|
/// Assert that mode, ownership, and permissions of two metadata objects match.
|
||||||
#[cfg(all(not(windows), not(target_os = "freebsd")))]
|
#[cfg(all(not(windows), not(target_os = "freebsd")))]
|
||||||
|
@ -2372,7 +2377,7 @@ fn test_cp_target_file_dev_null() {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
|
#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
|
||||||
fn test_cp_one_file_system() {
|
fn test_cp_one_file_system() {
|
||||||
use crate::common::util::AtPath;
|
use uutests::util::AtPath;
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
let mut scene = TestScenario::new(util_name!());
|
let mut scene = TestScenario::new(util_name!());
|
||||||
|
@ -4669,7 +4674,8 @@ fn test_cp_no_dereference_attributes_only_with_symlink() {
|
||||||
/// contains the test for cp when the source and destination points to the same file
|
/// contains the test for cp when the source and destination points to the same file
|
||||||
mod same_file {
|
mod same_file {
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
const FILE_NAME: &str = "foo";
|
const FILE_NAME: &str = "foo";
|
||||||
const SYMLINK_NAME: &str = "symlink";
|
const SYMLINK_NAME: &str = "symlink";
|
||||||
|
@ -5594,8 +5600,9 @@ mod same_file {
|
||||||
#[cfg(all(unix, not(target_os = "android")))]
|
#[cfg(all(unix, not(target_os = "android")))]
|
||||||
mod link_deref {
|
mod link_deref {
|
||||||
|
|
||||||
use crate::common::util::{AtPath, TestScenario};
|
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
|
use uutests::util::{AtPath, TestScenario};
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
const FILE: &str = "file";
|
const FILE: &str = "file";
|
||||||
const FILE_LINK: &str = "file_link";
|
const FILE_LINK: &str = "file_link";
|
||||||
|
@ -6037,8 +6044,8 @@ fn test_cp_no_file() {
|
||||||
not(any(target_os = "android", target_os = "macos", target_os = "openbsd"))
|
not(any(target_os = "android", target_os = "macos", target_os = "openbsd"))
|
||||||
))]
|
))]
|
||||||
fn test_cp_preserve_xattr_readonly_source() {
|
fn test_cp_preserve_xattr_readonly_source() {
|
||||||
use crate::common::util::compare_xattrs;
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
use uutests::util::compare_xattrs;
|
||||||
|
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
|
|
|
@ -2,8 +2,11 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use glob::glob;
|
use glob::glob;
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
/// Returns a string of numbers with the given range, each on a new line.
|
/// Returns a string of numbers with the given range, each on a new line.
|
||||||
/// The upper bound is not included.
|
/// The upper bound is not included.
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
|
|
||||||
// spell-checker:ignore defg
|
// spell-checker:ignore defg
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
static INPUT: &str = "lists.txt";
|
static INPUT: &str = "lists.txt";
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,13 @@ use chrono::{DateTime, Duration, Utc};
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
#[cfg(all(unix, not(target_os = "macos")))]
|
#[cfg(all(unix, not(target_os = "macos")))]
|
||||||
use uucore::process::geteuid;
|
use uucore::process::geteuid;
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -4,11 +4,14 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, availible, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, iseek, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, oseek, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat abcdefghijklm abcdefghi nabcde nabcdefg abcdefg fifoname seekable
|
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, availible, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, iseek, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, oseek, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat abcdefghijklm abcdefghi nabcde nabcdefg abcdefg fifoname seekable
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
#[cfg(all(unix, not(feature = "feat_selinux")))]
|
use uutests::new_ucmd;
|
||||||
use crate::common::util::run_ucmd_as_root_with_stdin_stdout;
|
use uutests::util::TestScenario;
|
||||||
|
#[cfg(unix)]
|
||||||
|
use uutests::util::run_ucmd_as_root_with_stdin_stdout;
|
||||||
#[cfg(all(not(windows), feature = "printf"))]
|
#[cfg(all(not(windows), feature = "printf"))]
|
||||||
use crate::common::util::{TESTS_BINARY, UCommand};
|
use uutests::util::{UCommand, get_tests_binary};
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use uucore::io::OwnedFileDescriptorOrHandle;
|
use uucore::io::OwnedFileDescriptorOrHandle;
|
||||||
|
@ -1505,9 +1508,9 @@ fn test_skip_input_fifo() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_multiple_processes_reading_stdin() {
|
fn test_multiple_processes_reading_stdin() {
|
||||||
// TODO Investigate if this is possible on Windows.
|
// TODO Investigate if this is possible on Windows.
|
||||||
let printf = format!("{TESTS_BINARY} printf 'abcdef\n'");
|
let printf = format!("{} printf 'abcdef\n'", get_tests_binary());
|
||||||
let dd_skip = format!("{TESTS_BINARY} dd bs=1 skip=3 count=0");
|
let dd_skip = format!("{} dd bs=1 skip=3 count=0", get_tests_binary());
|
||||||
let dd = format!("{TESTS_BINARY} dd");
|
let dd = format!("{} dd", get_tests_binary());
|
||||||
UCommand::new()
|
UCommand::new()
|
||||||
.arg(format!("{printf} | ( {dd_skip} && {dd} ) 2> /dev/null"))
|
.arg(format!("{printf} | ( {dd_skip} && {dd} ) 2> /dev/null"))
|
||||||
.succeeds()
|
.succeeds()
|
||||||
|
@ -1609,7 +1612,7 @@ fn test_reading_partial_blocks_from_fifo() {
|
||||||
|
|
||||||
// Start a `dd` process that reads from the fifo (so it will wait
|
// Start a `dd` process that reads from the fifo (so it will wait
|
||||||
// until the writer process starts).
|
// until the writer process starts).
|
||||||
let mut reader_command = Command::new(TESTS_BINARY);
|
let mut reader_command = Command::new(get_tests_binary());
|
||||||
let child = reader_command
|
let child = reader_command
|
||||||
.args(["dd", "ibs=3", "obs=3", &format!("if={fifoname}")])
|
.args(["dd", "ibs=3", "obs=3", &format!("if={fifoname}")])
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
@ -1653,7 +1656,7 @@ fn test_reading_partial_blocks_from_fifo_unbuffered() {
|
||||||
// until the writer process starts).
|
// until the writer process starts).
|
||||||
//
|
//
|
||||||
// `bs=N` takes precedence over `ibs=N` and `obs=N`.
|
// `bs=N` takes precedence over `ibs=N` and `obs=N`.
|
||||||
let mut reader_command = Command::new(TESTS_BINARY);
|
let mut reader_command = Command::new(get_tests_binary());
|
||||||
let child = reader_command
|
let child = reader_command
|
||||||
.args(["dd", "bs=3", "ibs=1", "obs=1", &format!("if={fifoname}")])
|
.args(["dd", "bs=3", "ibs=1", "obs=1", &format!("if={fifoname}")])
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
|
|
@ -12,7 +12,11 @@
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
#[cfg(not(any(target_os = "freebsd", target_os = "windows")))]
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As dir use the same functions than ls, we don't have to retest them here.
|
* As dir use the same functions than ls, we don't have to retest them here.
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore overridable colorterm
|
// spell-checker:ignore overridable colorterm
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
use dircolors::{OutputFmt, StrUtils, guess_syntax};
|
use dircolors::{OutputFmt, StrUtils, guess_syntax};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -7,9 +7,14 @@
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
use crate::common::util::expected_result;
|
use uutests::unwrap_or_return;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
use uutests::util::expected_result;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[cfg(not(target_os = "openbsd"))]
|
#[cfg(not(target_os = "openbsd"))]
|
||||||
const SUB_DIR: &str = "subdir/deeper";
|
const SUB_DIR: &str = "subdir/deeper";
|
||||||
|
|
|
@ -2,9 +2,12 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (words) araba merci
|
// spell-checker:ignore (words) araba merci mright
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util::UCommand;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_default() {
|
fn test_default() {
|
||||||
|
@ -492,6 +495,64 @@ fn slash_eight_off_by_one() {
|
||||||
.stdout_only(r"\8");
|
.stdout_only(r"\8");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_normalized_newlines_stdout_is() {
|
||||||
|
let res = new_ucmd!().args(&["-ne", "A\r\nB\nC"]).run();
|
||||||
|
|
||||||
|
res.normalized_newlines_stdout_is("A\r\nB\nC");
|
||||||
|
res.normalized_newlines_stdout_is("A\nB\nC");
|
||||||
|
res.normalized_newlines_stdout_is("A\nB\r\nC");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_normalized_newlines_stdout_is_fail() {
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["-ne", "A\r\nB\nC"])
|
||||||
|
.run()
|
||||||
|
.stdout_is("A\r\nB\nC");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cmd_result_stdout_check_and_stdout_str_check() {
|
||||||
|
let result = new_ucmd!().arg("Hello world").run();
|
||||||
|
|
||||||
|
result.stdout_str_check(|stdout| stdout.ends_with("world\n"));
|
||||||
|
result.stdout_check(|stdout| stdout.get(0..2).unwrap().eq(b"He"));
|
||||||
|
result.no_stderr();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cmd_result_stderr_check_and_stderr_str_check() {
|
||||||
|
let ts = TestScenario::new("echo");
|
||||||
|
|
||||||
|
let result = UCommand::new()
|
||||||
|
.arg(format!(
|
||||||
|
"{} {} Hello world >&2",
|
||||||
|
ts.bin_path.display(),
|
||||||
|
ts.util_name
|
||||||
|
))
|
||||||
|
.run();
|
||||||
|
|
||||||
|
result.stderr_str_check(|stderr| stderr.ends_with("world\n"));
|
||||||
|
result.stderr_check(|stdout| stdout.get(0..2).unwrap().eq(b"He"));
|
||||||
|
result.no_stdout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cmd_result_stdout_str_check_when_false_then_panics() {
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["-e", "\\f"])
|
||||||
|
.succeeds()
|
||||||
|
.stdout_only("\x0C\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_cmd_result_signal_when_normal_exit_then_no_signal() {
|
||||||
|
let result = TestScenario::new("echo").ucmd().run();
|
||||||
|
assert!(result.signal().is_none());
|
||||||
|
}
|
||||||
|
|
||||||
mod posixly_correct {
|
mod posixly_correct {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -543,3 +604,56 @@ mod posixly_correct {
|
||||||
.stdout_only("foo");
|
.stdout_only("foo");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_child_when_run_with_a_non_blocking_util() {
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("hello world")
|
||||||
|
.run()
|
||||||
|
.success()
|
||||||
|
.stdout_only("hello world\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test basically that most of the methods of UChild are working
|
||||||
|
#[test]
|
||||||
|
fn test_uchild_when_run_no_wait_with_a_non_blocking_util() {
|
||||||
|
let mut child = new_ucmd!().arg("hello world").run_no_wait();
|
||||||
|
|
||||||
|
// check `child.is_alive()` and `child.delay()` is working
|
||||||
|
let mut trials = 10;
|
||||||
|
while child.is_alive() {
|
||||||
|
assert!(
|
||||||
|
trials > 0,
|
||||||
|
"Assertion failed: child process is still alive."
|
||||||
|
);
|
||||||
|
|
||||||
|
child.delay(500);
|
||||||
|
trials -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert!(!child.is_alive());
|
||||||
|
|
||||||
|
// check `child.is_not_alive()` is working
|
||||||
|
assert!(child.is_not_alive());
|
||||||
|
|
||||||
|
// check the current output is correct
|
||||||
|
std::assert_eq!(child.stdout(), "hello world\n");
|
||||||
|
assert!(child.stderr().is_empty());
|
||||||
|
|
||||||
|
// check the current output of echo is empty. We already called `child.stdout()` and `echo`
|
||||||
|
// exited so there's no additional output after the first call of `child.stdout()`
|
||||||
|
assert!(child.stdout().is_empty());
|
||||||
|
assert!(child.stderr().is_empty());
|
||||||
|
|
||||||
|
// check that we're still able to access all output of the child process, even after exit
|
||||||
|
// and call to `child.stdout()`
|
||||||
|
std::assert_eq!(child.stdout_all(), "hello world\n");
|
||||||
|
assert!(child.stderr_all().is_empty());
|
||||||
|
|
||||||
|
// we should be able to call kill without panics, even if the process already exited
|
||||||
|
child.make_assertion().is_not_alive();
|
||||||
|
child.kill();
|
||||||
|
|
||||||
|
// we should be able to call wait without panics and apply some assertions
|
||||||
|
child.wait().unwrap().code_is(0).no_stdout().no_stderr();
|
||||||
|
}
|
||||||
|
|
|
@ -2,12 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (words) bamf chdir rlimit prlimit COMSPEC cout cerr FFFD
|
// spell-checker:ignore (words) bamf chdir rlimit prlimit COMSPEC cout cerr FFFD winsize xpixel ypixel
|
||||||
#![allow(clippy::missing_errors_doc)]
|
#![allow(clippy::missing_errors_doc)]
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
#[cfg(unix)]
|
|
||||||
use crate::common::util::UChild;
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use nix::sys::signal::Signal;
|
use nix::sys::signal::Signal;
|
||||||
#[cfg(feature = "echo")]
|
#[cfg(feature = "echo")]
|
||||||
|
@ -17,6 +14,13 @@ use std::path::Path;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
#[cfg(unix)]
|
||||||
|
use uutests::util::TerminalSimulation;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
#[cfg(unix)]
|
||||||
|
use uutests::util::UChild;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
struct Target {
|
struct Target {
|
||||||
|
@ -520,7 +524,7 @@ fn test_split_string_into_args_debug_output_whitespace_handling() {
|
||||||
fn test_gnu_e20() {
|
fn test_gnu_e20() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
|
|
||||||
let env_bin = String::from(crate::common::util::TESTS_BINARY) + " " + util_name!();
|
let env_bin = String::from(uutests::util::get_tests_binary()) + " " + util_name!();
|
||||||
|
|
||||||
let (input, output) = (
|
let (input, output) = (
|
||||||
[
|
[
|
||||||
|
@ -1516,3 +1520,205 @@ mod test_raw_string_parser {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_simulation_of_terminal_false() {
|
||||||
|
let scene = TestScenario::new("util");
|
||||||
|
|
||||||
|
let out = scene.ccmd("env").arg("sh").arg("is_a_tty.sh").succeeds();
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stdout()),
|
||||||
|
"stdin is not a tty\nstdout is not a tty\nstderr is not a tty\n"
|
||||||
|
);
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stderr()),
|
||||||
|
"This is an error message.\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_simulation_of_terminal_true() {
|
||||||
|
let scene = TestScenario::new("util");
|
||||||
|
|
||||||
|
let out = scene
|
||||||
|
.ccmd("env")
|
||||||
|
.arg("sh")
|
||||||
|
.arg("is_a_tty.sh")
|
||||||
|
.terminal_simulation(true)
|
||||||
|
.succeeds();
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stdout()),
|
||||||
|
"stdin is a tty\r\nterminal size: 30 80\r\nstdout is a tty\r\nstderr is a tty\r\n"
|
||||||
|
);
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stderr()),
|
||||||
|
"This is an error message.\r\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_simulation_of_terminal_for_stdin_only() {
|
||||||
|
let scene = TestScenario::new("util");
|
||||||
|
|
||||||
|
let out = scene
|
||||||
|
.ccmd("env")
|
||||||
|
.arg("sh")
|
||||||
|
.arg("is_a_tty.sh")
|
||||||
|
.terminal_sim_stdio(TerminalSimulation {
|
||||||
|
stdin: true,
|
||||||
|
stdout: false,
|
||||||
|
stderr: false,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.succeeds();
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stdout()),
|
||||||
|
"stdin is a tty\nterminal size: 30 80\nstdout is not a tty\nstderr is not a tty\n"
|
||||||
|
);
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stderr()),
|
||||||
|
"This is an error message.\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_simulation_of_terminal_for_stdout_only() {
|
||||||
|
let scene = TestScenario::new("util");
|
||||||
|
|
||||||
|
let out = scene
|
||||||
|
.ccmd("env")
|
||||||
|
.arg("sh")
|
||||||
|
.arg("is_a_tty.sh")
|
||||||
|
.terminal_sim_stdio(TerminalSimulation {
|
||||||
|
stdin: false,
|
||||||
|
stdout: true,
|
||||||
|
stderr: false,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.succeeds();
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stdout()),
|
||||||
|
"stdin is not a tty\r\nstdout is a tty\r\nstderr is not a tty\r\n"
|
||||||
|
);
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stderr()),
|
||||||
|
"This is an error message.\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_simulation_of_terminal_for_stderr_only() {
|
||||||
|
let scene = TestScenario::new("util");
|
||||||
|
|
||||||
|
let out = scene
|
||||||
|
.ccmd("env")
|
||||||
|
.arg("sh")
|
||||||
|
.arg("is_a_tty.sh")
|
||||||
|
.terminal_sim_stdio(TerminalSimulation {
|
||||||
|
stdin: false,
|
||||||
|
stdout: false,
|
||||||
|
stderr: true,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.succeeds();
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stdout()),
|
||||||
|
"stdin is not a tty\nstdout is not a tty\nstderr is a tty\n"
|
||||||
|
);
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stderr()),
|
||||||
|
"This is an error message.\r\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_simulation_of_terminal_size_information() {
|
||||||
|
let scene = TestScenario::new("util");
|
||||||
|
|
||||||
|
let out = scene
|
||||||
|
.ccmd("env")
|
||||||
|
.arg("sh")
|
||||||
|
.arg("is_a_tty.sh")
|
||||||
|
.terminal_sim_stdio(TerminalSimulation {
|
||||||
|
size: Some(libc::winsize {
|
||||||
|
ws_col: 40,
|
||||||
|
ws_row: 10,
|
||||||
|
ws_xpixel: 40 * 8,
|
||||||
|
ws_ypixel: 10 * 10,
|
||||||
|
}),
|
||||||
|
stdout: true,
|
||||||
|
stdin: true,
|
||||||
|
stderr: true,
|
||||||
|
})
|
||||||
|
.succeeds();
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stdout()),
|
||||||
|
"stdin is a tty\r\nterminal size: 10 40\r\nstdout is a tty\r\nstderr is a tty\r\n"
|
||||||
|
);
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stderr()),
|
||||||
|
"This is an error message.\r\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_simulation_of_terminal_pty_sends_eot_automatically() {
|
||||||
|
let scene = TestScenario::new("util");
|
||||||
|
|
||||||
|
let mut cmd = scene.ccmd("env");
|
||||||
|
cmd.timeout(std::time::Duration::from_secs(10));
|
||||||
|
cmd.args(&["cat", "-"]);
|
||||||
|
cmd.terminal_simulation(true);
|
||||||
|
let child = cmd.run_no_wait();
|
||||||
|
let out = child.wait().unwrap(); // cat would block if there is no eot
|
||||||
|
|
||||||
|
std::assert_eq!(String::from_utf8_lossy(out.stderr()), "");
|
||||||
|
std::assert_eq!(String::from_utf8_lossy(out.stdout()), "\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_simulation_of_terminal_pty_pipes_into_data_and_sends_eot_automatically() {
|
||||||
|
let scene = TestScenario::new("util");
|
||||||
|
|
||||||
|
let message = "Hello stdin forwarding!";
|
||||||
|
|
||||||
|
let mut cmd = scene.ccmd("env");
|
||||||
|
cmd.args(&["cat", "-"]);
|
||||||
|
cmd.terminal_simulation(true);
|
||||||
|
cmd.pipe_in(message);
|
||||||
|
let child = cmd.run_no_wait();
|
||||||
|
let out = child.wait().unwrap();
|
||||||
|
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stdout()),
|
||||||
|
format!("{message}\r\n")
|
||||||
|
);
|
||||||
|
std::assert_eq!(String::from_utf8_lossy(out.stderr()), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_simulation_of_terminal_pty_write_in_data_and_sends_eot_automatically() {
|
||||||
|
let scene = TestScenario::new("util");
|
||||||
|
|
||||||
|
let mut cmd = scene.ccmd("env");
|
||||||
|
cmd.args(&["cat", "-"]);
|
||||||
|
cmd.terminal_simulation(true);
|
||||||
|
let mut child = cmd.run_no_wait();
|
||||||
|
child.write_in("Hello stdin forwarding via write_in!");
|
||||||
|
let out = child.wait().unwrap();
|
||||||
|
|
||||||
|
std::assert_eq!(
|
||||||
|
String::from_utf8_lossy(out.stdout()),
|
||||||
|
"Hello stdin forwarding via write_in!\r\n"
|
||||||
|
);
|
||||||
|
std::assert_eq!(String::from_utf8_lossy(out.stderr()), "");
|
||||||
|
}
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
// spell-checker:ignore (ToDO) taaaa tbbbb tcccc
|
// spell-checker:ignore (ToDO) taaaa tbbbb tcccc
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
// spell-checker:ignore abbccd abcac acabc andand bigcmp bignum emptysub
|
// spell-checker:ignore abbccd abcac acabc andand bigcmp bignum emptysub
|
||||||
// spell-checker:ignore orempty oror
|
// spell-checker:ignore orempty oror
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_no_arguments() {
|
fn test_no_arguments() {
|
||||||
|
@ -400,7 +402,9 @@ fn test_long_input() {
|
||||||
|
|
||||||
/// Regroup the testcases of the GNU test expr.pl
|
/// Regroup the testcases of the GNU test expr.pl
|
||||||
mod gnu_expr {
|
mod gnu_expr {
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_a() {
|
fn test_a() {
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
clippy::cast_sign_loss
|
clippy::cast_sign_loss
|
||||||
)]
|
)]
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
|
|
||||||
|
@ -44,11 +46,11 @@ fn test_repeated_exponents() {
|
||||||
#[cfg(feature = "sort")]
|
#[cfg(feature = "sort")]
|
||||||
#[cfg(not(target_os = "android"))]
|
#[cfg(not(target_os = "android"))]
|
||||||
fn test_parallel() {
|
fn test_parallel() {
|
||||||
use crate::common::util::AtPath;
|
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
use sha1::{Digest, Sha1};
|
use sha1::{Digest, Sha1};
|
||||||
use std::{fs::OpenOptions, time::Duration};
|
use std::{fs::OpenOptions, time::Duration};
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
|
use uutests::util::AtPath;
|
||||||
// factor should only flush the buffer at line breaks
|
// factor should only flush the buffer at line breaks
|
||||||
let n_integers = 100_000;
|
let n_integers = 100_000;
|
||||||
let mut input_string = String::new();
|
let mut input_string = String::new();
|
||||||
|
|
|
@ -2,13 +2,12 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
#[test]
|
#[test]
|
||||||
fn test_no_args() {
|
fn test_no_args() {
|
||||||
new_ucmd!().fails().no_output();
|
new_ucmd!().fails().no_output();
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
|
|
||||||
//spell-checker: ignore coreutil
|
//spell-checker: ignore coreutil
|
||||||
|
|
||||||
use crate::common::util::{TestScenario, check_coreutil_version, expected_result, whoami};
|
use uutests::new_ucmd;
|
||||||
|
use uutests::unwrap_or_return;
|
||||||
|
use uutests::util::{TestScenario, check_coreutil_version, expected_result, whoami};
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
const VERSION_MIN_MULTIPLE_USERS: &str = "8.31"; // this feature was introduced in GNU's coreutils 8.31
|
const VERSION_MIN_MULTIPLE_USERS: &str = "8.31"; // this feature was introduced in GNU's coreutils 8.31
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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;
|
||||||
// spell-checker:ignore checkfile, nonames, testf, ntestf
|
// spell-checker:ignore checkfile, nonames, testf, ntestf
|
||||||
macro_rules! get_hash(
|
macro_rules! get_hash(
|
||||||
($str:expr) => (
|
($str:expr) => (
|
||||||
|
@ -14,7 +17,7 @@ macro_rules! test_digest {
|
||||||
($($id:ident $t:ident $size:expr)*) => ($(
|
($($id:ident $t:ident $size:expr)*) => ($(
|
||||||
|
|
||||||
mod $id {
|
mod $id {
|
||||||
use crate::common::util::*;
|
use uutests::util::*;
|
||||||
static DIGEST_ARG: &'static str = concat!("--", stringify!($t));
|
static DIGEST_ARG: &'static str = concat!("--", stringify!($t));
|
||||||
static BITS_ARG: &'static str = concat!("--bits=", stringify!($size));
|
static BITS_ARG: &'static str = concat!("--bits=", stringify!($size));
|
||||||
static EXPECTED_FILE: &'static str = concat!(stringify!($id), ".expected");
|
static EXPECTED_FILE: &'static str = concat!(stringify!($id), ".expected");
|
||||||
|
@ -72,6 +75,9 @@ macro_rules! test_digest {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_text_mode() {
|
fn test_text_mode() {
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
// TODO Replace this with hard-coded files that store the
|
// TODO Replace this with hard-coded files that store the
|
||||||
// expected output of text mode on an input file that has
|
// expected output of text mode on an input file that has
|
||||||
// "\r\n" line endings.
|
// "\r\n" line endings.
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
// spell-checker:ignore (words) bogusfile emptyfile abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstu
|
// spell-checker:ignore (words) bogusfile emptyfile abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstu
|
||||||
// spell-checker:ignore (words) seekable
|
// spell-checker:ignore (words) seekable
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
not(target_os = "windows"),
|
not(target_os = "windows"),
|
||||||
not(target_os = "macos"),
|
not(target_os = "macos"),
|
||||||
|
@ -15,7 +14,9 @@ use crate::common::util::TestScenario;
|
||||||
not(target_os = "openbsd")
|
not(target_os = "openbsd")
|
||||||
))]
|
))]
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
static INPUT: &str = "lorem_ipsum.txt";
|
static INPUT: &str = "lorem_ipsum.txt";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_normal() {
|
fn test_normal() {
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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]
|
#[test]
|
||||||
fn test_hostname() {
|
fn test_hostname() {
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) coreutil
|
// spell-checker:ignore (ToDO) coreutil
|
||||||
|
|
||||||
use crate::common::util::{TestScenario, check_coreutil_version, expected_result, is_ci, whoami};
|
use uutests::new_ucmd;
|
||||||
|
use uutests::unwrap_or_return;
|
||||||
|
use uutests::util::{TestScenario, check_coreutil_version, expected_result, is_ci, whoami};
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
const VERSION_MIN_MULTIPLE_USERS: &str = "8.31"; // this feature was introduced in GNU's coreutils 8.31
|
const VERSION_MIN_MULTIPLE_USERS: &str = "8.31"; // this feature was introduced in GNU's coreutils 8.31
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (words) helloworld nodir objdump n'source
|
// spell-checker:ignore (words) helloworld nodir objdump n'source
|
||||||
|
|
||||||
use crate::common::util::{TestScenario, is_ci, run_ucmd_as_root};
|
|
||||||
#[cfg(not(target_os = "openbsd"))]
|
#[cfg(not(target_os = "openbsd"))]
|
||||||
use filetime::FileTime;
|
use filetime::FileTime;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
@ -14,6 +13,10 @@ use std::process::Command;
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use uucore::process::{getegid, geteuid};
|
use uucore::process::{getegid, geteuid};
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::{TestScenario, is_ci, run_ucmd_as_root};
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -4,13 +4,15 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (words) autoformat nocheck
|
// spell-checker:ignore (words) autoformat nocheck
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::{ffi::OsStr, os::unix::ffi::OsStrExt};
|
use std::{ffi::OsStr, os::unix::ffi::OsStrExt};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use std::{ffi::OsString, os::windows::ffi::OsStringExt};
|
use std::{ffi::OsString, os::windows::ffi::OsStringExt};
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
// spell-checker:ignore IAMNOTASIGNAL
|
// spell-checker:ignore IAMNOTASIGNAL
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::os::unix::process::ExitStatusExt;
|
use std::os::unix::process::ExitStatusExt;
|
||||||
use std::process::{Child, Command};
|
use std::process::{Child, Command};
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
// A child process the tests will try to kill.
|
// A child process the tests will try to kill.
|
||||||
struct Target {
|
struct Target {
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -4,8 +4,11 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
#![allow(clippy::similar_names)]
|
#![allow(clippy::similar_names)]
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::{TestScenario, is_ci};
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::{TestScenario, is_ci};
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -10,9 +10,6 @@
|
||||||
clippy::cast_possible_truncation
|
clippy::cast_possible_truncation
|
||||||
)]
|
)]
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
#[cfg(any(unix, feature = "feat_selinux"))]
|
|
||||||
use crate::common::util::expected_result;
|
|
||||||
#[cfg(all(unix, feature = "chmod"))]
|
#[cfg(all(unix, feature = "chmod"))]
|
||||||
use nix::unistd::{close, dup};
|
use nix::unistd::{close, dup};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
@ -29,6 +26,13 @@ use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
#[cfg(unix)]
|
||||||
|
use uutests::unwrap_or_return;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
#[cfg(any(unix, feature = "feat_selinux"))]
|
||||||
|
use uutests::util::expected_result;
|
||||||
|
use uutests::{at_and_ucmd, util_name};
|
||||||
|
|
||||||
const LONG_ARGS: &[&str] = &[
|
const LONG_ARGS: &[&str] = &[
|
||||||
"-l",
|
"-l",
|
||||||
|
@ -2232,6 +2236,7 @@ fn test_ls_recursive_1() {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
mod quoting {
|
mod quoting {
|
||||||
use super::TestScenario;
|
use super::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
/// Create a directory with "dirname", then for each check, assert that the
|
/// Create a directory with "dirname", then for each check, assert that the
|
||||||
/// output is correct.
|
/// output is correct.
|
||||||
|
|
|
@ -7,11 +7,15 @@
|
||||||
|
|
||||||
#![allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
|
#![allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
use libc::mode_t;
|
use libc::mode_t;
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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]
|
#[test]
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (words) gpghome
|
// spell-checker:ignore (words) gpghome
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use std::io::IsTerminal;
|
use std::io::IsTerminal;
|
||||||
|
#[cfg(target_family = "unix")]
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_more_no_arg() {
|
fn test_more_no_arg() {
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
//
|
//
|
||||||
// spell-checker:ignore mydir
|
// spell-checker:ignore mydir
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use filetime::FileTime;
|
use filetime::FileTime;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::{at_and_ucmd, util_name};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mv_invalid_arg() {
|
fn test_mv_invalid_arg() {
|
||||||
|
@ -1670,7 +1672,7 @@ fn test_mv_dir_into_path_slash() {
|
||||||
fn test_acl() {
|
fn test_acl() {
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
use crate::common::util::compare_xattrs;
|
use uutests::util::compare_xattrs;
|
||||||
|
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
|
@ -1766,10 +1768,11 @@ fn test_move_should_not_fallback_to_copy() {
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
mod inter_partition_copying {
|
mod inter_partition_copying {
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use std::fs::{read_to_string, set_permissions, write};
|
use std::fs::{read_to_string, set_permissions, write};
|
||||||
use std::os::unix::fs::{PermissionsExt, symlink};
|
use std::os::unix::fs::{PermissionsExt, symlink};
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
// Ensure that the copying code used in an inter-partition move unlinks the destination symlink.
|
// Ensure that the copying code used in an inter-partition move unlinks the destination symlink.
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1823,6 +1826,7 @@ mod inter_partition_copying {
|
||||||
// that it would output the proper error message.
|
// that it would output the proper error message.
|
||||||
#[test]
|
#[test]
|
||||||
pub(crate) fn test_mv_unlinks_dest_symlink_error_message() {
|
pub(crate) fn test_mv_unlinks_dest_symlink_error_message() {
|
||||||
|
use uutests::util::TestScenario;
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore libc's setpriority
|
// spell-checker:ignore libc's setpriority
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(target_os = "android"))]
|
#[cfg(not(target_os = "android"))]
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
//
|
//
|
||||||
// spell-checker:ignore binvalid finvalid hinvalid iinvalid linvalid nabcabc nabcabcabc ninvalid vinvalid winvalid dabc näää
|
// spell-checker:ignore binvalid finvalid hinvalid iinvalid linvalid nabcabc nabcabcabc ninvalid vinvalid winvalid dabc näää
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -3,9 +3,12 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore winsize Openpty openpty xpixel ypixel ptyprocess
|
// spell-checker:ignore winsize Openpty openpty xpixel ypixel ptyprocess
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
#[cfg(not(target_os = "openbsd"))]
|
#[cfg(not(target_os = "openbsd"))]
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
// General observation: nohup.out will not be created in tests run by cargo test
|
// General observation: nohup.out will not be created in tests run by cargo test
|
||||||
// because stdin/stdout is not attached to a TTY.
|
// because stdin/stdout is not attached to a TTY.
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore incorrectnumber
|
// spell-checker:ignore incorrectnumber
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (paths) gnutest ronna quetta
|
// spell-checker:ignore (paths) gnutest ronna quetta
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -5,8 +5,11 @@
|
||||||
|
|
||||||
// spell-checker:ignore abcdefghijklmnopqrstuvwxyz Anone
|
// spell-checker:ignore abcdefghijklmnopqrstuvwxyz Anone
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use unindent::unindent;
|
use unindent::unindent;
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
// octal dump of 'abcdefghijklmnopqrstuvwxyz\n'
|
// octal dump of 'abcdefghijklmnopqrstuvwxyz\n'
|
||||||
static ALPHA_OUT: &str = "
|
static ALPHA_OUT: &str = "
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
|
|
||||||
// spell-checker:ignore bsdutils toybox
|
// spell-checker:ignore bsdutils toybox
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
struct TestData<'b> {
|
struct TestData<'b> {
|
||||||
name: &'b str,
|
name: &'b str,
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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]
|
#[test]
|
||||||
fn test_no_args() {
|
fn test_no_args() {
|
||||||
|
|
|
@ -3,13 +3,16 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
#[cfg(target_os = "openbsd")]
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
#[cfg(not(target_os = "openbsd"))]
|
|
||||||
use crate::common::util::{TestScenario, expected_result};
|
|
||||||
use pinky::Capitalize;
|
use pinky::Capitalize;
|
||||||
#[cfg(not(target_os = "openbsd"))]
|
#[cfg(not(target_os = "openbsd"))]
|
||||||
use uucore::entries::{Locate, Passwd};
|
use uucore::entries::{Locate, Passwd};
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::unwrap_or_return;
|
||||||
|
#[cfg(target_os = "openbsd")]
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
#[cfg(not(target_os = "openbsd"))]
|
||||||
|
use uutests::util::{TestScenario, expected_result};
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (ToDO) Sdivide
|
// spell-checker:ignore (ToDO) Sdivide
|
||||||
|
|
||||||
use crate::common::util::{TestScenario, UCommand};
|
|
||||||
use chrono::{DateTime, Duration, Utc};
|
use chrono::{DateTime, Duration, Utc};
|
||||||
use std::fs::metadata;
|
use std::fs::metadata;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::{TestScenario, UCommand};
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
const DATE_TIME_FORMAT: &str = "%b %d %H:%M %Y";
|
const DATE_TIME_FORMAT: &str = "%b %d %H:%M %Y";
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::TestScenario;
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_all() {
|
fn test_get_all() {
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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]
|
#[test]
|
||||||
fn basic_literal() {
|
fn basic_literal() {
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore roff
|
// spell-checker:ignore roff
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -6,7 +6,10 @@
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use crate::common::util::{TestScenario, UCommand};
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::{TestScenario, UCommand};
|
||||||
|
//use uutests::at_and_ucmd;
|
||||||
|
use uutests::{at_and_ucmd, util_name};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore regfile
|
// spell-checker:ignore regfile
|
||||||
use crate::common::util::{TestScenario, get_root_path};
|
use uutests::new_ucmd;
|
||||||
|
use uutests::path_concat;
|
||||||
|
use uutests::util::{TestScenario, get_root_path};
|
||||||
|
use uutests::{at_and_ucmd, util_name};
|
||||||
|
|
||||||
static GIBBERISH: &str = "supercalifragilisticexpialidocious";
|
static GIBBERISH: &str = "supercalifragilisticexpialidocious";
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore nusr
|
// spell-checker:ignore nusr
|
||||||
use crate::common::util::{TestScenario, get_root_path};
|
use uutests::new_ucmd;
|
||||||
|
use uutests::path_concat;
|
||||||
|
use uutests::util::{TestScenario, get_root_path};
|
||||||
|
use uutests::{at_and_ucmd, util_name};
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
|
@ -6,7 +6,10 @@
|
||||||
|
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
@ -777,6 +780,64 @@ fn test_non_utf8() {
|
||||||
assert!(!at.file_exists(file));
|
assert!(!at.file_exists(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_uchild_when_run_no_wait_with_a_blocking_command() {
|
||||||
|
let ts = TestScenario::new("rm");
|
||||||
|
let at = &ts.fixtures;
|
||||||
|
|
||||||
|
at.mkdir("a");
|
||||||
|
at.touch("a/empty");
|
||||||
|
|
||||||
|
#[cfg(target_vendor = "apple")]
|
||||||
|
let delay: u64 = 2000;
|
||||||
|
#[cfg(not(target_vendor = "apple"))]
|
||||||
|
let delay: u64 = 1000;
|
||||||
|
|
||||||
|
let yes = if cfg!(windows) { "y\r\n" } else { "y\n" };
|
||||||
|
|
||||||
|
let mut child = ts
|
||||||
|
.ucmd()
|
||||||
|
.set_stdin(Stdio::piped())
|
||||||
|
.stderr_to_stdout()
|
||||||
|
.args(&["-riv", "a"])
|
||||||
|
.run_no_wait();
|
||||||
|
child
|
||||||
|
.make_assertion_with_delay(delay)
|
||||||
|
.is_alive()
|
||||||
|
.with_current_output()
|
||||||
|
.stdout_is("rm: descend into directory 'a'? ");
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
let expected = "rm: descend into directory 'a'? \
|
||||||
|
rm: remove regular empty file 'a\\empty'? ";
|
||||||
|
#[cfg(unix)]
|
||||||
|
let expected = "rm: descend into directory 'a'? \
|
||||||
|
rm: remove regular empty file 'a/empty'? ";
|
||||||
|
child.write_in(yes);
|
||||||
|
child
|
||||||
|
.make_assertion_with_delay(delay)
|
||||||
|
.is_alive()
|
||||||
|
.with_all_output()
|
||||||
|
.stdout_is(expected);
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
let expected = "removed 'a\\empty'\nrm: remove directory 'a'? ";
|
||||||
|
#[cfg(unix)]
|
||||||
|
let expected = "removed 'a/empty'\nrm: remove directory 'a'? ";
|
||||||
|
|
||||||
|
child
|
||||||
|
.write_in(yes)
|
||||||
|
.make_assertion_with_delay(delay)
|
||||||
|
.is_alive()
|
||||||
|
.with_exact_output(44, 0)
|
||||||
|
.stdout_only(expected);
|
||||||
|
|
||||||
|
let expected = "removed directory 'a'\n";
|
||||||
|
|
||||||
|
child.write_in(yes);
|
||||||
|
child.wait().unwrap().stdout_only(expected).success();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_recursive_interactive() {
|
fn test_recursive_interactive() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
const DIR: &str = "dir";
|
const DIR: &str = "dir";
|
||||||
const DIR_FILE: &str = "dir/file";
|
const DIR_FILE: &str = "dir/file";
|
||||||
|
|
|
@ -6,7 +6,9 @@
|
||||||
|
|
||||||
#![cfg(feature = "feat_selinux")]
|
#![cfg(feature = "feat_selinux")]
|
||||||
|
|
||||||
use crate::common::util::*;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
// TODO: Check the implementation of `--compute` somehow.
|
// TODO: Check the implementation of `--compute` somehow.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore lmnop xlmnop
|
// spell-checker:ignore lmnop xlmnop
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
|
|
||||||
// spell-checker:ignore wipesync
|
// spell-checker:ignore wipesync
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) unwritable
|
// spell-checker:ignore (ToDO) unwritable
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -5,10 +5,13 @@
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
// spell-checker:ignore dont SIGBUS SIGSEGV sigsegv sigbus
|
// spell-checker:ignore dont SIGBUS SIGSEGV sigsegv sigbus
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use nix::sys::signal::Signal::{SIGBUS, SIGSEGV};
|
use nix::sys::signal::Signal::{SIGBUS, SIGSEGV};
|
||||||
|
use std::io::ErrorKind;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -272,3 +275,141 @@ fn test_negative_interval() {
|
||||||
.fails()
|
.fails()
|
||||||
.usage_error("invalid time interval '-1': Number was negative");
|
.usage_error("invalid time interval '-1': Number was negative");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
#[should_panic = "Program must be run first or has not finished"]
|
||||||
|
fn test_cmd_result_signal_when_still_running_then_panic() {
|
||||||
|
let mut child = TestScenario::new("sleep").ucmd().arg("60").run_no_wait();
|
||||||
|
|
||||||
|
child
|
||||||
|
.make_assertion()
|
||||||
|
.is_alive()
|
||||||
|
.with_current_output()
|
||||||
|
.signal();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_cmd_result_signal_when_kill_then_signal() {
|
||||||
|
let mut child = TestScenario::new("sleep").ucmd().arg("60").run_no_wait();
|
||||||
|
|
||||||
|
child.kill();
|
||||||
|
child
|
||||||
|
.make_assertion()
|
||||||
|
.is_not_alive()
|
||||||
|
.with_current_output()
|
||||||
|
.signal_is(9)
|
||||||
|
.signal_name_is("SIGKILL")
|
||||||
|
.signal_name_is("KILL")
|
||||||
|
.signal_name_is("9")
|
||||||
|
.signal()
|
||||||
|
.expect("Signal was none");
|
||||||
|
|
||||||
|
let result = child.wait().unwrap();
|
||||||
|
result
|
||||||
|
.signal_is(9)
|
||||||
|
.signal_name_is("SIGKILL")
|
||||||
|
.signal_name_is("KILL")
|
||||||
|
.signal_name_is("9")
|
||||||
|
.signal()
|
||||||
|
.expect("Signal was none");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[rstest]
|
||||||
|
#[case::signal_only_part_of_name("IGKILL")] // spell-checker: disable-line
|
||||||
|
#[case::signal_just_sig("SIG")]
|
||||||
|
#[case::signal_value_too_high("100")]
|
||||||
|
#[case::signal_value_negative("-1")]
|
||||||
|
#[should_panic = "Invalid signal name or value"]
|
||||||
|
fn test_cmd_result_signal_when_invalid_signal_name_then_panic(#[case] signal_name: &str) {
|
||||||
|
let mut child = TestScenario::new("sleep").ucmd().arg("60").run_no_wait();
|
||||||
|
child.kill();
|
||||||
|
let result = child.wait().unwrap();
|
||||||
|
result.signal_name_is(signal_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(unix)]
|
||||||
|
fn test_cmd_result_signal_name_is_accepts_lowercase() {
|
||||||
|
let mut child = TestScenario::new("sleep").ucmd().arg("60").run_no_wait();
|
||||||
|
child.kill();
|
||||||
|
let result = child.wait().unwrap();
|
||||||
|
result.signal_name_is("sigkill");
|
||||||
|
result.signal_name_is("kill");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_uchild_when_wait_and_timeout_is_reached_then_timeout_error() {
|
||||||
|
let ts = TestScenario::new("sleep");
|
||||||
|
let child = ts
|
||||||
|
.ucmd()
|
||||||
|
.timeout(Duration::from_secs(1))
|
||||||
|
.arg("10.0")
|
||||||
|
.run_no_wait();
|
||||||
|
|
||||||
|
match child.wait() {
|
||||||
|
Err(error) if error.kind() == ErrorKind::Other => {
|
||||||
|
std::assert_eq!(error.to_string(), "wait: Timeout of '1s' reached");
|
||||||
|
}
|
||||||
|
Err(error) => panic!("Assertion failed: Expected error with timeout but was: {error}"),
|
||||||
|
Ok(_) => panic!("Assertion failed: Expected timeout of `wait`."),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[rstest]
|
||||||
|
#[timeout(Duration::from_secs(5))]
|
||||||
|
fn test_uchild_when_kill_and_timeout_higher_than_kill_time_then_no_panic() {
|
||||||
|
let ts = TestScenario::new("sleep");
|
||||||
|
let mut child = ts
|
||||||
|
.ucmd()
|
||||||
|
.timeout(Duration::from_secs(60))
|
||||||
|
.arg("20.0")
|
||||||
|
.run_no_wait();
|
||||||
|
|
||||||
|
child.kill().make_assertion().is_not_alive();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_uchild_when_try_kill_and_timeout_is_reached_then_error() {
|
||||||
|
let ts = TestScenario::new("sleep");
|
||||||
|
let mut child = ts.ucmd().timeout(Duration::ZERO).arg("10.0").run_no_wait();
|
||||||
|
|
||||||
|
match child.try_kill() {
|
||||||
|
Err(error) if error.kind() == ErrorKind::Other => {
|
||||||
|
std::assert_eq!(error.to_string(), "kill: Timeout of '0s' reached");
|
||||||
|
}
|
||||||
|
Err(error) => panic!("Assertion failed: Expected error with timeout but was: {error}"),
|
||||||
|
Ok(()) => panic!("Assertion failed: Expected timeout of `try_kill`."),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[should_panic = "kill: Timeout of '0s' reached"]
|
||||||
|
fn test_uchild_when_kill_with_timeout_and_timeout_is_reached_then_panic() {
|
||||||
|
let ts = TestScenario::new("sleep");
|
||||||
|
let mut child = ts.ucmd().timeout(Duration::ZERO).arg("10.0").run_no_wait();
|
||||||
|
|
||||||
|
child.kill();
|
||||||
|
panic!("Assertion failed: Expected timeout of `kill`.");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[should_panic(expected = "wait: Timeout of '1.1s' reached")]
|
||||||
|
fn test_ucommand_when_run_with_timeout_and_timeout_is_reached_then_panic() {
|
||||||
|
let ts = TestScenario::new("sleep");
|
||||||
|
ts.ucmd()
|
||||||
|
.timeout(Duration::from_millis(1100))
|
||||||
|
.arg("10.0")
|
||||||
|
.run();
|
||||||
|
|
||||||
|
panic!("Assertion failed: Expected timeout of `run`.")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[rstest]
|
||||||
|
#[timeout(Duration::from_secs(10))]
|
||||||
|
fn test_ucommand_when_run_with_timeout_higher_then_execution_time_then_no_panic() {
|
||||||
|
let ts = TestScenario::new("sleep");
|
||||||
|
ts.ucmd().timeout(Duration::from_secs(60)).arg("1.0").run();
|
||||||
|
}
|
||||||
|
|
|
@ -8,7 +8,10 @@
|
||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
fn test_helper(file_name: &str, possible_args: &[&str]) {
|
fn test_helper(file_name: &str, possible_args: &[&str]) {
|
||||||
for args in possible_args {
|
for args in possible_args {
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes threebytes asciilowercase ghijkl mnopq rstuv wxyz fivelines twohundredfortyonebytes onehundredlines nbbbb dxen ncccc rlimit NOFILE
|
// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes threebytes asciilowercase ghijkl mnopq rstuv wxyz fivelines twohundredfortyonebytes onehundredlines nbbbb dxen ncccc rlimit NOFILE
|
||||||
|
|
||||||
use crate::common::util::{AtPath, TestScenario};
|
|
||||||
use rand::{Rng, SeedableRng, rng};
|
use rand::{Rng, SeedableRng, rng};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
|
@ -16,6 +15,11 @@ use std::{
|
||||||
fs::{File, read_dir},
|
fs::{File, read_dir},
|
||||||
io::{BufWriter, Read, Write},
|
io::{BufWriter, Read, Write},
|
||||||
};
|
};
|
||||||
|
use uutests::util::{AtPath, TestScenario};
|
||||||
|
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
fn random_chars(n: usize) -> String {
|
fn random_chars(n: usize) -> String {
|
||||||
rng()
|
rng()
|
||||||
|
|
|
@ -3,7 +3,11 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
use crate::common::util::{TestScenario, expected_result};
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::unwrap_or_return;
|
||||||
|
use uutests::util::{TestScenario, expected_result};
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
use uutests::new_ucmd;
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
use crate::common::util::TestScenario;
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn invalid_input() {
|
fn invalid_input() {
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore parenb parmrk ixany iuclc onlcr ofdel icanon noflsh
|
// spell-checker:ignore parenb parmrk ixany iuclc onlcr ofdel icanon noflsh
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -2,9 +2,11 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore axxbxx bxxaxx axxx axxxx xxaxx xxax xxxxa axyz zyax zyxa
|
// spell-checker:ignore axxbxx bxxaxx axxx axxxx xxaxx xxax xxxxa axyz zyax zyxa
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -13,12 +13,6 @@
|
||||||
clippy::cast_possible_truncation
|
clippy::cast_possible_truncation
|
||||||
)]
|
)]
|
||||||
|
|
||||||
use crate::common::random::{AlphanumericNewline, RandomizedString};
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
#[cfg(unix)]
|
|
||||||
use crate::common::util::expected_result;
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
use crate::common::util::is_ci;
|
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rand::distr::Alphanumeric;
|
use rand::distr::Alphanumeric;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
@ -45,6 +39,18 @@ use tail::chunks::BUFFER_SIZE as CHUNK_BUFFER_SIZE;
|
||||||
not(target_os = "openbsd")
|
not(target_os = "openbsd")
|
||||||
))]
|
))]
|
||||||
use tail::text;
|
use tail::text;
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::random::{AlphanumericNewline, RandomizedString};
|
||||||
|
#[cfg(unix)]
|
||||||
|
use uutests::unwrap_or_return;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
#[cfg(unix)]
|
||||||
|
use uutests::util::expected_result;
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
use uutests::util::is_ci;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
const FOOBAR_TXT: &str = "foobar.txt";
|
const FOOBAR_TXT: &str = "foobar.txt";
|
||||||
const FOOBAR_2_TXT: &str = "foobar2.txt";
|
const FOOBAR_2_TXT: &str = "foobar2.txt";
|
||||||
|
@ -4805,3 +4811,39 @@ fn test_following_with_pid() {
|
||||||
|
|
||||||
child.kill();
|
child.kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This error was first detected when running tail so tail is used here but
|
||||||
|
// should fail with any command that takes piped input.
|
||||||
|
// See also https://github.com/uutils/coreutils/issues/3895
|
||||||
|
#[test]
|
||||||
|
#[cfg_attr(not(feature = "expensive_tests"), ignore)]
|
||||||
|
fn test_when_piped_input_then_no_broken_pipe() {
|
||||||
|
let ts = TestScenario::new("tail");
|
||||||
|
for i in 0..10000 {
|
||||||
|
dbg!(i);
|
||||||
|
let test_string = "a\nb\n";
|
||||||
|
ts.ucmd()
|
||||||
|
.args(&["-n", "0"])
|
||||||
|
.pipe_in(test_string)
|
||||||
|
.succeeds()
|
||||||
|
.no_stdout()
|
||||||
|
.no_stderr();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_child_when_run_with_stderr_to_stdout() {
|
||||||
|
let ts = TestScenario::new("tail");
|
||||||
|
let at = &ts.fixtures;
|
||||||
|
|
||||||
|
at.write("data", "file data\n");
|
||||||
|
|
||||||
|
let expected_stdout = "==> data <==\n\
|
||||||
|
file data\n\
|
||||||
|
tail: cannot open 'missing' for reading: No such file or directory\n";
|
||||||
|
ts.ucmd()
|
||||||
|
.args(&["data", "missing"])
|
||||||
|
.stderr_to_stdout()
|
||||||
|
.fails()
|
||||||
|
.stdout_only(expected_stdout);
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
#![allow(clippy::borrow_as_ptr)]
|
#![allow(clippy::borrow_as_ptr)]
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::{at_and_ucmd, new_ucmd, util_name};
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
@ -160,12 +162,15 @@ fn test_tee_no_more_writeable_2() {
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
mod linux_only {
|
mod linux_only {
|
||||||
use crate::common::util::{AtPath, CmdResult, TestScenario, UCommand};
|
use uutests::util::{AtPath, CmdResult, TestScenario, UCommand};
|
||||||
|
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
fn make_broken_pipe() -> File {
|
fn make_broken_pipe() -> File {
|
||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
|
|
||||||
// spell-checker:ignore (words) egid euid pseudofloat
|
// spell-checker:ignore (words) egid euid pseudofloat
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_empty_test_equivalent_to_false() {
|
fn test_empty_test_equivalent_to_false() {
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore dont
|
// spell-checker:ignore dont
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -4,12 +4,15 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore (formats) cymdhm cymdhms mdhm mdhms ymdhm ymdhms datetime mktime
|
// spell-checker:ignore (formats) cymdhm cymdhms mdhm mdhms ymdhm ymdhms datetime mktime
|
||||||
|
|
||||||
use crate::common::util::{AtPath, TestScenario};
|
|
||||||
use filetime::FileTime;
|
use filetime::FileTime;
|
||||||
#[cfg(not(target_os = "freebsd"))]
|
#[cfg(not(target_os = "freebsd"))]
|
||||||
use filetime::set_symlink_file_times;
|
use filetime::set_symlink_file_times;
|
||||||
use std::fs::remove_file;
|
use std::fs::remove_file;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::{AtPath, TestScenario};
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
fn get_file_times(at: &AtPath, path: &str) -> (FileTime, FileTime) {
|
fn get_file_times(at: &AtPath, path: &str) -> (FileTime, FileTime) {
|
||||||
let m = at.metadata(path);
|
let m = at.metadata(path);
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore aabbaa aabbcc aabc abbb abbbcddd abcc abcdefabcdef abcdefghijk abcdefghijklmn abcdefghijklmnop ABCDEFGHIJKLMNOPQRS abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFZZ abcxyz ABCXYZ abcxyzabcxyz ABCXYZABCXYZ acbdef alnum amzamz AMZXAMZ bbbd cclass cefgm cntrl compl dabcdef dncase Gzabcdefg PQRST upcase wxyzz xdigit XXXYYY xycde xyyye xyyz xyzzzzxyzzzz ZABCDEF Zamz Cdefghijkl Cdefghijklmn asdfqqwweerr qwerr asdfqwer qwer aassddffqwer asdfqwer
|
// spell-checker:ignore aabbaa aabbcc aabc abbb abbbcddd abcc abcdefabcdef abcdefghijk abcdefghijklmn abcdefghijklmnop ABCDEFGHIJKLMNOPQRS abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFZZ abcxyz ABCXYZ abcxyzabcxyz ABCXYZABCXYZ acbdef alnum amzamz AMZXAMZ bbbd cclass cefgm cntrl compl dabcdef dncase Gzabcdefg PQRST upcase wxyzz xdigit XXXYYY xycde xyyye xyyz xyzzzzxyzzzz ZABCDEF Zamz Cdefghijkl Cdefghijklmn asdfqqwweerr qwerr asdfqwer qwer aassddffqwer asdfqwer
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::{ffi::OsStr, os::unix::ffi::OsStrExt};
|
use std::{ffi::OsStr, os::unix::ffi::OsStrExt};
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_no_args() {
|
fn test_no_args() {
|
||||||
|
|
|
@ -5,8 +5,11 @@
|
||||||
|
|
||||||
// spell-checker:ignore (words) RFILE
|
// spell-checker:ignore (words) RFILE
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use std::io::{Seek, SeekFrom, Write};
|
use std::io::{Seek, SeekFrom, Write};
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
static FILE1: &str = "truncate_test_1";
|
static FILE1: &str = "truncate_test_1";
|
||||||
static FILE2: &str = "truncate_test_2";
|
static FILE2: &str = "truncate_test_2";
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
#![allow(clippy::cast_possible_wrap)]
|
#![allow(clippy::cast_possible_wrap)]
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
// spell-checker:ignore contenta
|
// spell-checker:ignore contenta
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -4,8 +4,11 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
// spell-checker:ignore nabcd badoption schar
|
// spell-checker:ignore nabcd badoption schar
|
||||||
use crate::common::util::TestScenario;
|
|
||||||
use uucore::posix::OBSOLETE;
|
use uucore::posix::OBSOLETE;
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
static INPUT: &str = "sorted.txt";
|
static INPUT: &str = "sorted.txt";
|
||||||
static OUTPUT: &str = "sorted-output.txt";
|
static OUTPUT: &str = "sorted-output.txt";
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -6,7 +6,10 @@
|
||||||
// spell-checker:ignore bincode serde utmp runlevel testusr testx
|
// spell-checker:ignore bincode serde utmp runlevel testusr testx
|
||||||
#![allow(clippy::cast_possible_wrap, clippy::unreadable_literal)]
|
#![allow(clippy::cast_possible_wrap, clippy::unreadable_literal)]
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use uutests::at_and_ucmd;
|
||||||
|
use uutests::new_ucmd;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "macos", target_os = "openbsd")))]
|
#[cfg(not(any(target_os = "macos", target_os = "openbsd")))]
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// 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]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue