mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
uutests: adjust the tests to use them
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use crate::common::util::TestScenario;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_arch() {
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// file that was distributed with this source code.
|
||||
//
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_encode() {
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use crate::common::util::TestScenario;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_encode() {
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (words) reallylongexecutable nbaz
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
use std::ffi::OsStr;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_help() {
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
|
||||
// spell-checker: ignore (encodings) lsbf msbf
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_z85_not_padded_decode() {
|
||||
|
||||
@@ -4,16 +4,18 @@
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore NOFILE nonewline cmdline
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
#[cfg(not(windows))]
|
||||
use crate::common::util::vec_of_size;
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use rlimit::Resource;
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(unix)]
|
||||
use std::fs::File;
|
||||
use std::fs::OpenOptions;
|
||||
#[cfg(not(windows))]
|
||||
use std::process::Stdio;
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
#[cfg(not(windows))]
|
||||
use uutests::util::vec_of_size;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_output_simple() {
|
||||
@@ -668,3 +670,40 @@ fn test_appending_same_input_output() {
|
||||
.no_stdout()
|
||||
.stderr_contains("input file is output file");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn test_uchild_when_no_capture_reading_from_infinite_source() {
|
||||
use regex::Regex;
|
||||
|
||||
let ts = TestScenario::new("cat");
|
||||
|
||||
let expected_stdout = b"\0".repeat(12345);
|
||||
let mut child = ts
|
||||
.ucmd()
|
||||
.set_stdin(Stdio::from(File::open("/dev/zero").unwrap()))
|
||||
.set_stdout(Stdio::piped())
|
||||
.run_no_wait();
|
||||
|
||||
child
|
||||
.make_assertion()
|
||||
.with_exact_output(12345, 0)
|
||||
.stdout_only_bytes(expected_stdout);
|
||||
|
||||
child
|
||||
.kill()
|
||||
.make_assertion()
|
||||
.with_current_output()
|
||||
.stdout_matches(&Regex::new("[\0].*").unwrap())
|
||||
.no_stderr();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_child_when_pipe_in() {
|
||||
let ts = TestScenario::new("cat");
|
||||
let mut child = ts.ucmd().set_stdin(Stdio::piped()).run_no_wait();
|
||||
child.pipe_in("content");
|
||||
child.wait().unwrap().stdout_only("content").success();
|
||||
|
||||
ts.ucmd().pipe_in("content").run().stdout_is("content");
|
||||
}
|
||||
|
||||
@@ -10,7 +10,10 @@ use std::ffi::CString;
|
||||
use std::path::Path;
|
||||
use std::{io, iter, str};
|
||||
|
||||
use crate::common::util::*;
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn version() {
|
||||
|
||||
@@ -4,8 +4,11 @@
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (words) nosuchgroup groupname
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
use uucore::process::getegid;
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_option() {
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
use crate::common::util::{AtPath, TestScenario, UCommand};
|
||||
use std::fs::{OpenOptions, Permissions, metadata, set_permissions};
|
||||
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::util::{AtPath, TestScenario, UCommand};
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util_name;
|
||||
|
||||
static TEST_FILE: &str = "file";
|
||||
static REFERENCE_FILE: &str = "reference";
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (words) agroupthatdoesntexist auserthatdoesntexist cuuser groupname notexisting passgrp
|
||||
|
||||
use crate::common::util::{CmdResult, TestScenario, is_ci, run_ucmd_as_root};
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use uucore::process::geteuid;
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::{CmdResult, TestScenario, is_ci, run_ucmd_as_root};
|
||||
use uutests::util_name;
|
||||
// Apparently some CI environments have configuration issues, e.g. with 'whoami' and 'id'.
|
||||
// If we are running inside the CI and "needle" is in "stderr" skipping this test is
|
||||
// considered okay. If we are not inside the CI this calls assert!(result.success).
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (words) araba newroot userspec chdir pwd's isroot
|
||||
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
#[cfg(not(target_os = "android"))]
|
||||
use crate::common::util::is_ci;
|
||||
use crate::common::util::{TestScenario, run_ucmd_as_root};
|
||||
use uutests::util::is_ci;
|
||||
use uutests::util::{TestScenario, run_ucmd_as_root};
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (words) asdf algo algos asha mgmt xffname hexa GFYEQ HYQK Yqxb dont
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
const ALGOS: [&str; 11] = [
|
||||
"sysv", "bsd", "crc", "md5", "sha1", "sha224", "sha256", "sha384", "sha512", "blake2b", "sm3",
|
||||
@@ -1681,7 +1684,7 @@ fn test_check_incorrectly_formatted_checksum_keeps_processing_hex() {
|
||||
/// This module reimplements the cksum-base64.pl GNU test.
|
||||
mod gnu_cksum_base64 {
|
||||
use super::*;
|
||||
use crate::common::util::log_info;
|
||||
use uutests::util::log_info;
|
||||
|
||||
const PAIRS: [(&str, &str); 12] = [
|
||||
("sysv", "0 0 f"),
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// file that was distributed with this source code.
|
||||
// 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]
|
||||
fn test_invalid_arg() {
|
||||
|
||||
@@ -4,7 +4,12 @@
|
||||
// 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 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))]
|
||||
use std::fs::set_permissions;
|
||||
|
||||
@@ -34,7 +39,7 @@ use std::time::Duration;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
#[cfg(feature = "truncate")]
|
||||
use crate::common::util::PATH;
|
||||
use uutests::util::PATH;
|
||||
|
||||
static TEST_EXISTING_FILE: &str = "existing_file.txt";
|
||||
static TEST_HELLO_WORLD_SOURCE: &str = "hello_world.txt";
|
||||
@@ -60,7 +65,7 @@ static TEST_NONEXISTENT_FILE: &str = "nonexistent_file.txt";
|
||||
unix,
|
||||
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.
|
||||
#[cfg(all(not(windows), not(target_os = "freebsd")))]
|
||||
@@ -2372,7 +2377,7 @@ fn test_cp_target_file_dev_null() {
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
|
||||
fn test_cp_one_file_system() {
|
||||
use crate::common::util::AtPath;
|
||||
use uutests::util::AtPath;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
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
|
||||
mod same_file {
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
const FILE_NAME: &str = "foo";
|
||||
const SYMLINK_NAME: &str = "symlink";
|
||||
@@ -5594,8 +5600,9 @@ mod same_file {
|
||||
#[cfg(all(unix, not(target_os = "android")))]
|
||||
mod link_deref {
|
||||
|
||||
use crate::common::util::{AtPath, TestScenario};
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
use uutests::util::{AtPath, TestScenario};
|
||||
use uutests::util_name;
|
||||
|
||||
const FILE: &str = "file";
|
||||
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"))
|
||||
))]
|
||||
fn test_cp_preserve_xattr_readonly_source() {
|
||||
use crate::common::util::compare_xattrs;
|
||||
use std::process::Command;
|
||||
use uutests::util::compare_xattrs;
|
||||
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use crate::common::util::TestScenario;
|
||||
use 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.
|
||||
/// The upper bound is not included.
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
|
||||
// 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";
|
||||
|
||||
|
||||
@@ -3,10 +3,13 @@ use chrono::{DateTime, Duration, Utc};
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use crate::common::util::TestScenario;
|
||||
use regex::Regex;
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
use uucore::process::geteuid;
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
// 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
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
#[cfg(all(unix, not(feature = "feat_selinux")))]
|
||||
use crate::common::util::run_ucmd_as_root_with_stdin_stdout;
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
#[cfg(unix)]
|
||||
use uutests::util::run_ucmd_as_root_with_stdin_stdout;
|
||||
#[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 uucore::io::OwnedFileDescriptorOrHandle;
|
||||
@@ -1505,9 +1508,9 @@ fn test_skip_input_fifo() {
|
||||
#[test]
|
||||
fn test_multiple_processes_reading_stdin() {
|
||||
// TODO Investigate if this is possible on Windows.
|
||||
let printf = format!("{TESTS_BINARY} printf 'abcdef\n'");
|
||||
let dd_skip = format!("{TESTS_BINARY} dd bs=1 skip=3 count=0");
|
||||
let dd = format!("{TESTS_BINARY} dd");
|
||||
let printf = format!("{} printf 'abcdef\n'", get_tests_binary());
|
||||
let dd_skip = format!("{} dd bs=1 skip=3 count=0", get_tests_binary());
|
||||
let dd = format!("{} dd", get_tests_binary());
|
||||
UCommand::new()
|
||||
.arg(format!("{printf} | ( {dd_skip} && {dd} ) 2> /dev/null"))
|
||||
.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
|
||||
// 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
|
||||
.args(["dd", "ibs=3", "obs=3", &format!("if={fifoname}")])
|
||||
.stdout(Stdio::piped())
|
||||
@@ -1653,7 +1656,7 @@ fn test_reading_partial_blocks_from_fifo_unbuffered() {
|
||||
// until the writer process starts).
|
||||
//
|
||||
// `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
|
||||
.args(["dd", "bs=3", "ibs=1", "obs=1", &format!("if={fifoname}")])
|
||||
.stdout(Stdio::piped())
|
||||
|
||||
@@ -12,7 +12,11 @@
|
||||
|
||||
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]
|
||||
fn test_invalid_arg() {
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use crate::common::util::TestScenario;
|
||||
use 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.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user