mirror of
https://github.com/uutils/coreutils.git
synced 2025-07-07 21:45:01 +00:00
Merge pull request #8293 from RenjiSann/uutest-refactor
Some checks are pending
CICD / Dependencies (push) Waiting to run
CICD / Build/Makefile (push) Blocked by required conditions
CICD / Build/stable (push) Blocked by required conditions
CICD / Build/nightly (push) Blocked by required conditions
CICD / Binary sizes (push) Blocked by required conditions
CICD / Build (push) Blocked by required conditions
CICD / Test all features separately (push) Blocked by required conditions
CICD / Build/SELinux (push) Blocked by required conditions
GnuTests / Run GNU tests (push) Waiting to run
Android / Test builds (push) Waiting to run
Code Quality / Style/format (push) Waiting to run
Code Quality / Style/lint (push) Waiting to run
Code Quality / Style/spelling (push) Waiting to run
Code Quality / Style/toml (push) Waiting to run
Code Quality / Style/Python (push) Waiting to run
Code Quality / Pre-commit hooks (push) Waiting to run
FreeBSD / Style and Lint (push) Waiting to run
CICD / Style/cargo-deny (push) Waiting to run
CICD / Style/deps (push) Waiting to run
CICD / Documentation/warnings (push) Waiting to run
CICD / MinRustV (push) Waiting to run
CICD / Tests/BusyBox test suite (push) Blocked by required conditions
CICD / Tests/Toybox test suite (push) Blocked by required conditions
CICD / Code Coverage (push) Waiting to run
CICD / Separate Builds (push) Waiting to run
FreeBSD / Tests (push) Waiting to run
Some checks are pending
CICD / Dependencies (push) Waiting to run
CICD / Build/Makefile (push) Blocked by required conditions
CICD / Build/stable (push) Blocked by required conditions
CICD / Build/nightly (push) Blocked by required conditions
CICD / Binary sizes (push) Blocked by required conditions
CICD / Build (push) Blocked by required conditions
CICD / Test all features separately (push) Blocked by required conditions
CICD / Build/SELinux (push) Blocked by required conditions
GnuTests / Run GNU tests (push) Waiting to run
Android / Test builds (push) Waiting to run
Code Quality / Style/format (push) Waiting to run
Code Quality / Style/lint (push) Waiting to run
Code Quality / Style/spelling (push) Waiting to run
Code Quality / Style/toml (push) Waiting to run
Code Quality / Style/Python (push) Waiting to run
Code Quality / Pre-commit hooks (push) Waiting to run
FreeBSD / Style and Lint (push) Waiting to run
CICD / Style/cargo-deny (push) Waiting to run
CICD / Style/deps (push) Waiting to run
CICD / Documentation/warnings (push) Waiting to run
CICD / MinRustV (push) Waiting to run
CICD / Tests/BusyBox test suite (push) Blocked by required conditions
CICD / Tests/Toybox test suite (push) Blocked by required conditions
CICD / Code Coverage (push) Waiting to run
CICD / Separate Builds (push) Waiting to run
FreeBSD / Tests (push) Waiting to run
tests: Fix macros, rewrite tests to use idiomatic macros
This commit is contained in:
commit
5f0077ecf8
63 changed files with 242 additions and 343 deletions
|
@ -3,8 +3,6 @@
|
|||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_arch() {
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
//
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_encode() {
|
||||
|
@ -114,10 +112,10 @@ fn test_wrap() {
|
|||
|
||||
#[test]
|
||||
fn test_wrap_no_arg() {
|
||||
let expected_stderr = "a value is required for '--wrap <COLS>' but none was supplied";
|
||||
|
||||
for wrap_param in ["-w", "--wrap"] {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let expected_stderr = "a value is required for '--wrap <COLS>' but none was supplied";
|
||||
ts.ucmd()
|
||||
new_ucmd!()
|
||||
.arg(wrap_param)
|
||||
.fails()
|
||||
.stderr_contains(expected_stderr)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
// file that was distributed with this source code.
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_encode() {
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#[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() {
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
// spell-checker: ignore (encodings) lsbf msbf
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_z85_not_padded_decode() {
|
||||
|
|
|
@ -12,8 +12,6 @@ use std::{io, iter, str};
|
|||
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn version() {
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
// spell-checker:ignore (words) nosuchgroup groupname
|
||||
|
||||
use uucore::process::getegid;
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
use uutests::{at_and_ucmd, new_ucmd};
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
use uutests::{util::TestScenario, util_name};
|
||||
|
||||
#[test]
|
||||
fn test_invalid_option() {
|
||||
|
@ -370,7 +369,7 @@ fn test_traverse_symlinks() {
|
|||
(&["-P"][..], false, false),
|
||||
(&["-L"][..], true, true),
|
||||
] {
|
||||
let scenario = TestScenario::new("chgrp");
|
||||
let scenario = TestScenario::new(util_name!());
|
||||
|
||||
let (at, mut ucmd) = (scenario.fixtures.clone(), scenario.ucmd());
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
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.
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
static INPUT: &str = "lists.txt";
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@ use std::collections::HashSet;
|
|||
#[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() {
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore overridable colorterm
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
use dircolors::{OutputFmt, StrUtils, guess_syntax};
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util::UCommand;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_default() {
|
||||
|
@ -654,7 +653,7 @@ fn test_cmd_result_stdout_str_check_when_false_then_panics() {
|
|||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn test_cmd_result_signal_when_normal_exit_then_no_signal() {
|
||||
let result = TestScenario::new("echo").ucmd().run();
|
||||
let result = new_ucmd!().run();
|
||||
assert!(result.signal().is_none());
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
// file that was distributed with this source code.
|
||||
use uucore::display::Quotable;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
// spell-checker:ignore (ToDO) taaaa tbbbb tcccc
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
// spell-checker:ignore orempty oror
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_no_arguments() {
|
||||
|
@ -643,8 +641,6 @@ fn test_long_input() {
|
|||
/// Regroup the testcases of the GNU test expr.pl
|
||||
mod gnu_expr {
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_a() {
|
||||
|
|
|
@ -6,8 +6,7 @@ use regex::Regex;
|
|||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
||||
use std::fs::OpenOptions;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_no_args() {
|
||||
new_ucmd!().fails().no_output();
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
// spell-checker:ignore plass samp
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -18,6 +18,7 @@ macro_rules! test_digest {
|
|||
|
||||
mod $id {
|
||||
use uutests::util::*;
|
||||
use uutests::util_name;
|
||||
static DIGEST_ARG: &'static str = concat!("--", stringify!($t));
|
||||
static BITS_ARG: &'static str = concat!("--bits=", stringify!($size));
|
||||
static EXPECTED_FILE: &'static str = concat!(stringify!($id), ".expected");
|
||||
|
@ -26,21 +27,21 @@ macro_rules! test_digest {
|
|||
|
||||
#[test]
|
||||
fn test_single_file() {
|
||||
let ts = TestScenario::new("hashsum");
|
||||
let ts = TestScenario::new(util_name!());
|
||||
assert_eq!(ts.fixtures.read(EXPECTED_FILE),
|
||||
get_hash!(ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).arg(INPUT_FILE).succeeds().no_stderr().stdout_str()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stdin() {
|
||||
let ts = TestScenario::new("hashsum");
|
||||
let ts = TestScenario::new(util_name!());
|
||||
assert_eq!(ts.fixtures.read(EXPECTED_FILE),
|
||||
get_hash!(ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).pipe_in_fixture(INPUT_FILE).succeeds().no_stderr().stdout_str()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_nonames() {
|
||||
let ts = TestScenario::new("hashsum");
|
||||
let ts = TestScenario::new(util_name!());
|
||||
// EXPECTED_FILE has no newline character at the end
|
||||
if DIGEST_ARG == "--b3sum" {
|
||||
// Option only available on b3sum
|
||||
|
@ -53,7 +54,7 @@ macro_rules! test_digest {
|
|||
|
||||
#[test]
|
||||
fn test_check() {
|
||||
let ts = TestScenario::new("hashsum");
|
||||
let ts = TestScenario::new(util_name!());
|
||||
println!("File content='{}'", ts.fixtures.read(INPUT_FILE));
|
||||
println!("Check file='{}'", ts.fixtures.read(CHECK_FILE));
|
||||
|
||||
|
@ -66,7 +67,7 @@ macro_rules! test_digest {
|
|||
|
||||
#[test]
|
||||
fn test_zero() {
|
||||
let ts = TestScenario::new("hashsum");
|
||||
let ts = TestScenario::new(util_name!());
|
||||
assert_eq!(ts.fixtures.read(EXPECTED_FILE),
|
||||
get_hash!(ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).arg("--zero").arg(INPUT_FILE).succeeds().no_stderr().stdout_str()));
|
||||
}
|
||||
|
@ -76,7 +77,6 @@ macro_rules! test_digest {
|
|||
#[test]
|
||||
fn test_text_mode() {
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util_name;
|
||||
|
||||
// TODO Replace this with hard-coded files that store the
|
||||
// expected output of text mode on an input file that has
|
||||
|
@ -101,7 +101,7 @@ macro_rules! test_digest {
|
|||
|
||||
#[test]
|
||||
fn test_missing_file() {
|
||||
let ts = TestScenario::new("hashsum");
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
|
||||
at.write("a", "file1\n");
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
// file that was distributed with this source code.
|
||||
use regex::Regex;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_normal() {
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_hostname() {
|
||||
|
|
|
@ -7,8 +7,6 @@ use regex::Regex;
|
|||
use std::os::unix::process::ExitStatusExt;
|
||||
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.
|
||||
struct Target {
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
// file that was distributed with this source code.
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
// file that was distributed with this source code.
|
||||
use std::env;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::{TestScenario, is_ci};
|
||||
use uutests::util_name;
|
||||
use uutests::util::is_ci;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
use std::io::IsTerminal;
|
||||
|
||||
use uutests::{at_and_ucmd, new_ucmd, util::TestScenario, util_name};
|
||||
use uutests::{at_and_ucmd, new_ucmd};
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
|
@ -75,8 +75,8 @@ fn test_file_arg() {
|
|||
// but I am leaving this for later
|
||||
if std::io::stdout().is_terminal() {
|
||||
// Directory as argument
|
||||
let mut ucmd = TestScenario::new(util_name!()).ucmd();
|
||||
ucmd.arg(".")
|
||||
new_ucmd!()
|
||||
.arg(".")
|
||||
.succeeds()
|
||||
.stderr_contains("'.' is a directory.");
|
||||
|
||||
|
@ -87,14 +87,14 @@ fn test_file_arg() {
|
|||
.succeeds()
|
||||
.stderr_contains("is a directory");
|
||||
|
||||
ucmd = TestScenario::new(util_name!()).ucmd();
|
||||
ucmd.arg("nonexistent_file")
|
||||
new_ucmd!()
|
||||
.arg("nonexistent_file")
|
||||
.succeeds()
|
||||
.stderr_contains("No such file or directory");
|
||||
|
||||
// Multiple nonexistent files
|
||||
ucmd = TestScenario::new(util_name!()).ucmd();
|
||||
ucmd.arg("file2")
|
||||
new_ucmd!()
|
||||
.arg("file2")
|
||||
.arg("file3")
|
||||
.succeeds()
|
||||
.stderr_contains("file2")
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore libc's setpriority
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "android"))]
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
// spell-checker:ignore (paths) gnutest ronna quetta
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
struct TestData<'b> {
|
||||
name: &'b str,
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_no_args() {
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
use chrono::{DateTime, Duration, Utc};
|
||||
use std::fs::metadata;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::{TestScenario, UCommand};
|
||||
use uutests::util_name;
|
||||
use uutests::util::UCommand;
|
||||
|
||||
const DATE_TIME_FORMAT: &str = "%b %d %H:%M %Y";
|
||||
|
||||
|
|
|
@ -2,13 +2,11 @@
|
|||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
use uutests::new_ucmd;
|
||||
|
||||
#[test]
|
||||
fn test_get_all() {
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.env("HOME", "FOO")
|
||||
.env("KEY", "VALUE")
|
||||
.succeeds()
|
||||
|
@ -18,21 +16,15 @@ fn test_get_all() {
|
|||
|
||||
#[test]
|
||||
fn test_get_var() {
|
||||
let result = TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.env("KEY", "VALUE")
|
||||
.arg("KEY")
|
||||
.succeeds();
|
||||
|
||||
assert!(!result.stdout_str().is_empty());
|
||||
assert_eq!(result.stdout_str().trim(), "VALUE");
|
||||
.succeeds()
|
||||
.stdout_contains("VALUE\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ignore_equal_var() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
// tested by gnu/tests/misc/printenv.sh
|
||||
let result = scene.ucmd().env("a=b", "c").arg("a=b").fails();
|
||||
|
||||
assert!(result.stdout_str().is_empty());
|
||||
new_ucmd!().env("a=b", "c").arg("a=b").fails().no_stdout();
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
// spell-checker:ignore fffffffffffffffc
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn basic_literal() {
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
// spell-checker:ignore roff
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -6,10 +6,9 @@
|
|||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::{TestScenario, UCommand};
|
||||
//use uutests::at_and_ucmd;
|
||||
use uutests::{at_and_ucmd, util_name};
|
||||
use uutests::util::UCommand;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
@ -32,6 +31,8 @@ fn test_failed() {
|
|||
#[test]
|
||||
fn test_deleted_dir() {
|
||||
use std::process::Command;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
|
|
|
@ -22,13 +22,12 @@ fn test_invalid_arg() {
|
|||
|
||||
#[test]
|
||||
fn test_resolve() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.touch("foo");
|
||||
at.symlink_file("foo", "bar");
|
||||
|
||||
scene.ucmd().arg("bar").succeeds().stdout_contains("foo\n");
|
||||
ucmd.arg("bar").succeeds().stdout_contains("foo\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
// file that was distributed with this source code.
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
const DIR: &str = "dir";
|
||||
const DIR_FILE: &str = "dir/file";
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#![cfg(feature = "feat_selinux")]
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
// TODO: Check the implementation of `--compute` somehow.
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore lmnop xlmnop
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -102,8 +102,7 @@ fn test_shred_remove_wipesync() {
|
|||
|
||||
#[test]
|
||||
fn test_shred_u() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let file_a = "test_shred_remove_a";
|
||||
let file_b = "test_shred_remove_b";
|
||||
|
@ -113,7 +112,7 @@ fn test_shred_u() {
|
|||
at.touch(file_b);
|
||||
|
||||
// Shred file_a.
|
||||
scene.ucmd().arg("-u").arg(file_a).succeeds();
|
||||
ucmd.arg("-u").arg(file_a).succeeds();
|
||||
|
||||
// file_a was deleted, file_b exists.
|
||||
assert!(!at.file_exists(file_a));
|
||||
|
@ -239,13 +238,12 @@ fn test_shred_verbose_no_padding_10() {
|
|||
|
||||
#[test]
|
||||
fn test_all_patterns_present() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let file = "foo.txt";
|
||||
at.write(file, "bar");
|
||||
|
||||
let result = scene.ucmd().arg("-vn25").arg(file).succeeds();
|
||||
let result = ucmd.arg("-vn25").arg(file).succeeds();
|
||||
|
||||
for pat in PATTERNS {
|
||||
result.stderr_contains(pat);
|
||||
|
@ -254,24 +252,28 @@ fn test_all_patterns_present() {
|
|||
|
||||
#[test]
|
||||
fn test_random_source_regular_file() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
// Currently, our block size is 4096. If it changes, this test has to be adapted.
|
||||
let mut many_bytes = Vec::with_capacity(4096 * 4);
|
||||
|
||||
for i in 0..4096u32 {
|
||||
many_bytes.extend(i.to_le_bytes());
|
||||
}
|
||||
|
||||
assert_eq!(many_bytes.len(), 4096 * 4);
|
||||
at.write_bytes("source_long", &many_bytes);
|
||||
|
||||
let file = "foo.txt";
|
||||
at.write(file, "a");
|
||||
scene
|
||||
.ucmd()
|
||||
|
||||
ucmd
|
||||
.arg("-vn3")
|
||||
.arg("--random-source=source_long")
|
||||
.arg(file)
|
||||
.succeeds()
|
||||
.stderr_only("shred: foo.txt: pass 1/3 (random)...\nshred: foo.txt: pass 2/3 (random)...\nshred: foo.txt: pass 3/3 (random)...\n");
|
||||
|
||||
// Should rewrite the file exactly three times
|
||||
assert_eq!(at.read_bytes(file), many_bytes[(4096 * 2)..(4096 * 3)]);
|
||||
}
|
||||
|
@ -279,13 +281,13 @@ fn test_random_source_regular_file() {
|
|||
#[test]
|
||||
#[ignore = "known issue #7947"]
|
||||
fn test_random_source_dir() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.mkdir("source");
|
||||
let file = "foo.txt";
|
||||
at.write(file, "a");
|
||||
scene
|
||||
.ucmd()
|
||||
|
||||
ucmd
|
||||
.arg("-v")
|
||||
.arg("--random-source=source")
|
||||
.arg(file)
|
||||
|
@ -302,12 +304,15 @@ fn test_shred_rename_exhaustion() {
|
|||
at.touch("test");
|
||||
at.touch("000");
|
||||
|
||||
let result = scene.ucmd().arg("-vu").arg("test").succeeds();
|
||||
|
||||
result.stderr_contains("renamed to 0000");
|
||||
result.stderr_contains("renamed to 001");
|
||||
result.stderr_contains("renamed to 00");
|
||||
result.stderr_contains("removed");
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-vu")
|
||||
.arg("test")
|
||||
.succeeds()
|
||||
.stderr_contains("renamed to 0000")
|
||||
.stderr_contains("renamed to 001")
|
||||
.stderr_contains("renamed to 00")
|
||||
.stderr_contains("removed");
|
||||
|
||||
assert!(!at.file_exists("test"));
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
// spell-checker:ignore (ToDO) unwritable
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -7,8 +7,6 @@ use rstest::rstest;
|
|||
use uucore::display::Quotable;
|
||||
// spell-checker:ignore dont SIGBUS SIGSEGV sigsegv sigbus infd
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[cfg(unix)]
|
||||
use nix::sys::signal::Signal::{SIGBUS, SIGSEGV};
|
||||
|
@ -317,7 +315,7 @@ fn test_invalid_duration(#[case] input: &str) {
|
|||
#[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();
|
||||
let mut child = new_ucmd!().arg("60").run_no_wait();
|
||||
|
||||
child
|
||||
.make_assertion()
|
||||
|
@ -329,7 +327,7 @@ fn test_cmd_result_signal_when_still_running_then_panic() {
|
|||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn test_cmd_result_signal_when_kill_then_signal() {
|
||||
let mut child = TestScenario::new("sleep").ucmd().arg("60").run_no_wait();
|
||||
let mut child = new_ucmd!().arg("60").run_no_wait();
|
||||
|
||||
child.kill();
|
||||
child
|
||||
|
@ -343,8 +341,9 @@ fn test_cmd_result_signal_when_kill_then_signal() {
|
|||
.signal()
|
||||
.expect("Signal was none");
|
||||
|
||||
let result = child.wait().unwrap();
|
||||
result
|
||||
child
|
||||
.wait()
|
||||
.unwrap()
|
||||
.signal_is(9)
|
||||
.signal_name_is("SIGKILL")
|
||||
.signal_name_is("KILL")
|
||||
|
@ -361,16 +360,16 @@ fn test_cmd_result_signal_when_kill_then_signal() {
|
|||
#[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();
|
||||
let mut child = new_ucmd!().arg("60").run_no_wait();
|
||||
|
||||
child.kill();
|
||||
let result = child.wait().unwrap();
|
||||
result.signal_name_is(signal_name);
|
||||
child.wait().unwrap().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();
|
||||
let mut child = new_ucmd!().arg("60").run_no_wait();
|
||||
child.kill();
|
||||
let result = child.wait().unwrap();
|
||||
result.signal_name_is("sigkill");
|
||||
|
@ -379,9 +378,7 @@ fn test_cmd_result_signal_name_is_accepts_lowercase() {
|
|||
|
||||
#[test]
|
||||
fn test_uchild_when_wait_and_timeout_is_reached_then_timeout_error() {
|
||||
let ts = TestScenario::new("sleep");
|
||||
let child = ts
|
||||
.ucmd()
|
||||
let child = new_ucmd!()
|
||||
.timeout(Duration::from_secs(1))
|
||||
.arg("10.0")
|
||||
.run_no_wait();
|
||||
|
@ -398,9 +395,7 @@ fn test_uchild_when_wait_and_timeout_is_reached_then_timeout_error() {
|
|||
#[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()
|
||||
let mut child = new_ucmd!()
|
||||
.timeout(Duration::from_secs(60))
|
||||
.arg("20.0")
|
||||
.run_no_wait();
|
||||
|
@ -410,8 +405,10 @@ fn test_uchild_when_kill_and_timeout_higher_than_kill_time_then_no_panic() {
|
|||
|
||||
#[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();
|
||||
let mut child = new_ucmd!()
|
||||
.timeout(Duration::ZERO)
|
||||
.arg("10.0")
|
||||
.run_no_wait();
|
||||
|
||||
match child.try_kill() {
|
||||
Err(error) if error.kind() == ErrorKind::Other => {
|
||||
|
@ -425,8 +422,10 @@ fn test_uchild_when_try_kill_and_timeout_is_reached_then_error() {
|
|||
#[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();
|
||||
let mut child = new_ucmd!()
|
||||
.timeout(Duration::ZERO)
|
||||
.arg("10.0")
|
||||
.run_no_wait();
|
||||
|
||||
child.kill();
|
||||
panic!("Assertion failed: Expected timeout of `kill`.");
|
||||
|
@ -435,8 +434,7 @@ fn test_uchild_when_kill_with_timeout_and_timeout_is_reached_then_panic() {
|
|||
#[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()
|
||||
new_ucmd!()
|
||||
.timeout(Duration::from_millis(1100))
|
||||
.arg("10.0")
|
||||
.run();
|
||||
|
@ -447,6 +445,8 @@ fn test_ucommand_when_run_with_timeout_and_timeout_is_reached_then_panic() {
|
|||
#[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();
|
||||
new_ucmd!()
|
||||
.timeout(Duration::from_secs(60))
|
||||
.arg("1.0")
|
||||
.run();
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@ use std::time::Duration;
|
|||
|
||||
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]) {
|
||||
for args in possible_args {
|
||||
|
@ -38,8 +36,7 @@ fn test_buffer_sizes() {
|
|||
#[cfg(not(target_os = "linux"))]
|
||||
let buffer_sizes = ["0", "50K", "50k", "1M", "100M"];
|
||||
for buffer_size in &buffer_sizes {
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.arg("-n")
|
||||
.arg("-S")
|
||||
.arg(buffer_size)
|
||||
|
@ -52,8 +49,7 @@ fn test_buffer_sizes() {
|
|||
{
|
||||
let buffer_sizes = ["1000G", "10T"];
|
||||
for buffer_size in &buffer_sizes {
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.arg("-n")
|
||||
.arg("-S")
|
||||
.arg(buffer_size)
|
||||
|
@ -1007,8 +1003,7 @@ fn test_compress_merge() {
|
|||
#[cfg(not(target_os = "android"))]
|
||||
fn test_compress_fail() {
|
||||
#[cfg(not(windows))]
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.args(&[
|
||||
"ext_sort.txt",
|
||||
"-n",
|
||||
|
@ -1023,8 +1018,7 @@ fn test_compress_fail() {
|
|||
// "thread 'main' panicked at 'called `Option::unwrap()` on ...
|
||||
// So, don't check the output
|
||||
#[cfg(windows)]
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.args(&[
|
||||
"ext_sort.txt",
|
||||
"-n",
|
||||
|
@ -1038,8 +1032,7 @@ fn test_compress_fail() {
|
|||
|
||||
#[test]
|
||||
fn test_merge_batches() {
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.timeout(Duration::from_secs(120))
|
||||
.args(&["ext_sort.txt", "-n", "-S", "150b"])
|
||||
.succeeds()
|
||||
|
@ -1048,15 +1041,14 @@ fn test_merge_batches() {
|
|||
|
||||
#[test]
|
||||
fn test_batch_size_invalid() {
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.arg("--batch-size=0")
|
||||
.fails_with_code(2)
|
||||
.stderr_contains("sort: invalid --batch-size argument '0'")
|
||||
.stderr_contains("sort: minimum --batch-size argument is '2'");
|
||||
|
||||
// with -m, the error path is a bit different
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.args(&["-m", "--batch-size=a"])
|
||||
.fails_with_code(2)
|
||||
.stderr_contains("sort: invalid --batch-size argument 'a'");
|
||||
|
@ -1065,16 +1057,15 @@ fn test_batch_size_invalid() {
|
|||
#[test]
|
||||
fn test_batch_size_too_large() {
|
||||
let large_batch_size = "18446744073709551616";
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.arg(format!("--batch-size={large_batch_size}"))
|
||||
.fails_with_code(2)
|
||||
.stderr_contains(format!(
|
||||
"--batch-size argument '{large_batch_size}' too large"
|
||||
));
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.arg(format!("--batch-size={large_batch_size}"))
|
||||
.fails_with_code(2)
|
||||
.stderr_contains("maximum --batch-size argument with current rlimit is");
|
||||
|
@ -1082,8 +1073,7 @@ fn test_batch_size_too_large() {
|
|||
|
||||
#[test]
|
||||
fn test_merge_batch_size() {
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.arg("--batch-size=2")
|
||||
.arg("-m")
|
||||
.arg("--unique")
|
||||
|
@ -1108,8 +1098,7 @@ fn test_merge_batch_size_with_limit() {
|
|||
// 2 descriptors for CTRL+C handling logic (to be reworked at some point)
|
||||
// 2 descriptors for the input files (i.e. batch-size of 2).
|
||||
let limit_fd = 3 + 2 + 2;
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.limit(Resource::NOFILE, limit_fd, limit_fd)
|
||||
.arg("--batch-size=2")
|
||||
.arg("-m")
|
||||
|
@ -1210,13 +1199,12 @@ fn test_separator_null() {
|
|||
#[test]
|
||||
fn test_output_is_input() {
|
||||
let input = "a\nb\nc\n";
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.touch("file");
|
||||
at.append("file", input);
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-m", "-u", "-o", "file", "file", "file", "file"])
|
||||
|
||||
ucmd.args(&["-m", "-u", "-o", "file", "file", "file", "file"])
|
||||
.succeeds();
|
||||
assert_eq!(at.read("file"), input);
|
||||
}
|
||||
|
@ -1400,12 +1388,11 @@ fn test_files0_from_minus_in_stdin() {
|
|||
#[test]
|
||||
// Test for GNU tests/sort/sort-files0-from.pl "empty"
|
||||
fn test_files0_from_empty() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.touch("file");
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["--files0-from", "file"])
|
||||
|
||||
ucmd.args(&["--files0-from", "file"])
|
||||
.fails_with_code(2)
|
||||
.stderr_only("sort: no input from 'file'\n");
|
||||
}
|
||||
|
@ -1443,13 +1430,12 @@ fn test_files0_from_nul2() {
|
|||
#[test]
|
||||
// Test for GNU tests/sort/sort-files0-from.pl "1"
|
||||
fn test_files0_from_1() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.touch("file");
|
||||
at.append("file", "a");
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["--files0-from", "-"])
|
||||
|
||||
ucmd.args(&["--files0-from", "-"])
|
||||
.pipe_in("file")
|
||||
.succeeds()
|
||||
.stdout_only("a\n");
|
||||
|
@ -1458,13 +1444,12 @@ fn test_files0_from_1() {
|
|||
#[test]
|
||||
// Test for GNU tests/sort/sort-files0-from.pl "1a"
|
||||
fn test_files0_from_1a() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.touch("file");
|
||||
at.append("file", "a");
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["--files0-from", "-"])
|
||||
|
||||
ucmd.args(&["--files0-from", "-"])
|
||||
.pipe_in("file\0")
|
||||
.succeeds()
|
||||
.stdout_only("a\n");
|
||||
|
@ -1473,13 +1458,12 @@ fn test_files0_from_1a() {
|
|||
#[test]
|
||||
// Test for GNU tests/sort/sort-files0-from.pl "2"
|
||||
fn test_files0_from_2() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.touch("file");
|
||||
at.append("file", "a");
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["--files0-from", "-"])
|
||||
|
||||
ucmd.args(&["--files0-from", "-"])
|
||||
.pipe_in("file\0file")
|
||||
.succeeds()
|
||||
.stdout_only("a\na\n");
|
||||
|
@ -1488,13 +1472,12 @@ fn test_files0_from_2() {
|
|||
#[test]
|
||||
// Test for GNU tests/sort/sort-files0-from.pl "2a"
|
||||
fn test_files0_from_2a() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.touch("file");
|
||||
at.append("file", "a");
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["--files0-from", "-"])
|
||||
|
||||
ucmd.args(&["--files0-from", "-"])
|
||||
.pipe_in("file\0file\0")
|
||||
.succeeds()
|
||||
.stdout_only("a\na\n");
|
||||
|
|
|
@ -498,13 +498,11 @@ fn test_split_obs_lines_standalone_overflow() {
|
|||
/// Test for obsolete lines option as part of invalid combined short options
|
||||
#[test]
|
||||
fn test_split_obs_lines_within_invalid_combined_shorts() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.touch("file");
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-2fb", "file"])
|
||||
ucmd.args(&["-2fb", "file"])
|
||||
.fails_with_code(1)
|
||||
.stderr_contains("error: unexpected argument '-f' found\n");
|
||||
}
|
||||
|
@ -512,18 +510,16 @@ fn test_split_obs_lines_within_invalid_combined_shorts() {
|
|||
/// Test for obsolete lines option as part of combined short options
|
||||
#[test]
|
||||
fn test_split_obs_lines_within_combined_shorts() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let name = "obs-lines-within-shorts";
|
||||
RandomFile::new(at, name).add_lines(400);
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-x200de", name])
|
||||
let name = "obs-lines-within-shorts";
|
||||
RandomFile::new(&at, name).add_lines(400);
|
||||
|
||||
ucmd.args(&["-x200de", name])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
let glob = Glob::new(at, ".", r"x\d\d$");
|
||||
let glob = Glob::new(&at, ".", r"x\d\d$");
|
||||
assert_eq!(glob.count(), 2);
|
||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||
}
|
||||
|
@ -534,6 +530,7 @@ fn test_split_obs_lines_within_combined_shorts_tailing_suffix_length() {
|
|||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let name = "obs-lines-combined-shorts-tailing-suffix-length";
|
||||
RandomFile::new(&at, name).add_lines(1000);
|
||||
|
||||
ucmd.args(&["-d200a4", name]).succeeds();
|
||||
|
||||
let glob = Glob::new(&at, ".", r"x\d\d\d\d$");
|
||||
|
@ -544,18 +541,17 @@ fn test_split_obs_lines_within_combined_shorts_tailing_suffix_length() {
|
|||
/// Test for obsolete lines option starts as part of combined short options
|
||||
#[test]
|
||||
fn test_split_obs_lines_starts_combined_shorts() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let name = "obs-lines-starts-shorts";
|
||||
RandomFile::new(at, name).add_lines(400);
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-200xd", name])
|
||||
let name = "obs-lines-starts-shorts";
|
||||
RandomFile::new(&at, name).add_lines(400);
|
||||
|
||||
ucmd.args(&["-200xd", name])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
let glob = Glob::new(at, ".", r"x\d\d$");
|
||||
|
||||
let glob = Glob::new(&at, ".", r"x\d\d$");
|
||||
assert_eq!(glob.count(), 2);
|
||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||
}
|
||||
|
@ -647,18 +643,17 @@ fn test_split_obs_lines_as_other_option_value() {
|
|||
/// last one wins
|
||||
#[test]
|
||||
fn test_split_multiple_obs_lines_standalone() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let name = "multiple-obs-lines";
|
||||
RandomFile::new(at, name).add_lines(400);
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-3000", "-200", name])
|
||||
let name = "multiple-obs-lines";
|
||||
RandomFile::new(&at, name).add_lines(400);
|
||||
|
||||
ucmd.args(&["-3000", "-200", name])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
let glob = Glob::new(at, ".", r"x[[:alpha:]][[:alpha:]]$");
|
||||
|
||||
let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$");
|
||||
assert_eq!(glob.count(), 2);
|
||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||
}
|
||||
|
@ -667,18 +662,17 @@ fn test_split_multiple_obs_lines_standalone() {
|
|||
/// last one wins
|
||||
#[test]
|
||||
fn test_split_multiple_obs_lines_within_combined() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let name = "multiple-obs-lines";
|
||||
RandomFile::new(at, name).add_lines(400);
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-d5000x", "-e200d", name])
|
||||
let name = "multiple-obs-lines";
|
||||
RandomFile::new(&at, name).add_lines(400);
|
||||
|
||||
ucmd.args(&["-d5000x", "-e200d", name])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
let glob = Glob::new(at, ".", r"x\d\d$");
|
||||
|
||||
let glob = Glob::new(&at, ".", r"x\d\d$");
|
||||
assert_eq!(glob.count(), 2);
|
||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||
}
|
||||
|
@ -720,9 +714,12 @@ fn test_split_invalid_bytes_size() {
|
|||
#[test]
|
||||
fn test_split_overflow_bytes_size() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let name = "test_split_overflow_bytes_size";
|
||||
RandomFile::new(&at, name).add_bytes(1000);
|
||||
|
||||
ucmd.args(&["-b", "1Y", name]).succeeds();
|
||||
|
||||
let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$");
|
||||
assert_eq!(glob.count(), 1);
|
||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||
|
@ -731,7 +728,9 @@ fn test_split_overflow_bytes_size() {
|
|||
#[test]
|
||||
fn test_split_stdin_num_chunks() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
ucmd.args(&["--number=1"]).pipe_in("").succeeds();
|
||||
|
||||
assert_eq!(at.read("xaa"), "");
|
||||
assert!(!at.plus("xab").exists());
|
||||
}
|
||||
|
@ -1374,10 +1373,11 @@ fn test_line_bytes_no_eof() {
|
|||
|
||||
#[test]
|
||||
fn test_guard_input() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
ts.ucmd()
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-C", "6"])
|
||||
.pipe_in("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n")
|
||||
.succeeds()
|
||||
|
@ -1385,7 +1385,8 @@ fn test_guard_input() {
|
|||
.no_stderr();
|
||||
assert_eq!(at.read("xaa"), "1\n2\n3\n");
|
||||
|
||||
ts.ucmd()
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-C", "6"])
|
||||
.pipe_in("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n")
|
||||
.succeeds()
|
||||
|
@ -1393,7 +1394,8 @@ fn test_guard_input() {
|
|||
.no_stderr();
|
||||
assert_eq!(at.read("xaa"), "1\n2\n3\n");
|
||||
|
||||
ts.ucmd()
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-C", "6", "xaa"])
|
||||
.fails()
|
||||
.stderr_only("split: 'xaa' would overwrite input; aborting\n");
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
// spell-checker:ignore parenb parmrk ixany iuclc onlcr ofdel icanon noflsh econl igpar ispeed ospeed
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
// file that was distributed with this source code.
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
use std::fs;
|
||||
use tempfile::tempdir;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
@ -62,6 +60,9 @@ fn test_sync_data_but_not_file() {
|
|||
#[cfg(feature = "chmod")]
|
||||
#[test]
|
||||
fn test_sync_no_permission_dir() {
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
let dir = "foo";
|
||||
|
@ -78,6 +79,9 @@ fn test_sync_no_permission_dir() {
|
|||
#[cfg(feature = "chmod")]
|
||||
#[test]
|
||||
fn test_sync_no_permission_file() {
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
let f = "file";
|
||||
|
|
|
@ -147,12 +147,11 @@ fn test_stdin_redirect_file_follow() {
|
|||
// foo
|
||||
//
|
||||
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.write("f", "foo");
|
||||
|
||||
let mut p = ts
|
||||
.ucmd()
|
||||
let mut p = ucmd
|
||||
.arg("-f")
|
||||
.set_stdin(File::open(at.plus("f")).unwrap())
|
||||
.run_no_wait();
|
||||
|
@ -169,14 +168,13 @@ fn test_stdin_redirect_file_follow() {
|
|||
fn test_stdin_redirect_offset() {
|
||||
// inspired by: "gnu/tests/tail-2/start-middle.sh"
|
||||
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.write("k", "1\n2\n");
|
||||
let mut fh = File::open(at.plus("k")).unwrap();
|
||||
fh.seek(SeekFrom::Start(2)).unwrap();
|
||||
|
||||
ts.ucmd().set_stdin(fh).succeeds().stdout_only("2\n");
|
||||
ucmd.set_stdin(fh).succeeds().stdout_only("2\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -184,8 +182,7 @@ fn test_stdin_redirect_offset() {
|
|||
fn test_stdin_redirect_offset2() {
|
||||
// like test_stdin_redirect_offset but with multiple files
|
||||
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.write("k", "1\n2\n");
|
||||
at.write("l", "3\n4\n");
|
||||
|
@ -193,8 +190,7 @@ fn test_stdin_redirect_offset2() {
|
|||
let mut fh = File::open(at.plus("k")).unwrap();
|
||||
fh.seek(SeekFrom::Start(2)).unwrap();
|
||||
|
||||
ts.ucmd()
|
||||
.set_stdin(fh)
|
||||
ucmd.set_stdin(fh)
|
||||
.args(&["k", "-", "l", "m"])
|
||||
.succeeds()
|
||||
.stdout_only(
|
||||
|
@ -260,8 +256,7 @@ fn test_permission_denied() {
|
|||
fn test_permission_denied_multiple() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.touch("file1");
|
||||
at.touch("file2");
|
||||
|
@ -270,8 +265,7 @@ fn test_permission_denied_multiple() {
|
|||
.set_permissions(PermissionsExt::from_mode(0o000))
|
||||
.unwrap();
|
||||
|
||||
ts.ucmd()
|
||||
.args(&["file1", "unreadable", "file2"])
|
||||
ucmd.args(&["file1", "unreadable", "file2"])
|
||||
.fails_with_code(1)
|
||||
.stderr_is("tail: cannot open 'unreadable' for reading: Permission denied\n")
|
||||
.stdout_is("==> file1 <==\n\n==> file2 <==\n");
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
// file that was distributed with this source code.
|
||||
#![allow(clippy::borrow_as_ptr)]
|
||||
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::{at_and_ucmd, new_ucmd, util_name};
|
||||
use uutests::{at_and_ucmd, new_ucmd};
|
||||
|
||||
use regex::Regex;
|
||||
use std::process::Stdio;
|
||||
|
@ -161,7 +160,7 @@ fn test_tee_output_not_buffered() {
|
|||
|
||||
#[cfg(target_os = "linux")]
|
||||
mod linux_only {
|
||||
use uutests::util::{AtPath, CmdResult, TestScenario, UCommand};
|
||||
use uutests::util::{AtPath, CmdResult, UCommand};
|
||||
|
||||
use std::fmt::Write;
|
||||
use std::fs::File;
|
||||
|
@ -169,7 +168,6 @@ mod linux_only {
|
|||
use std::time::Duration;
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util_name;
|
||||
|
||||
fn make_broken_pipe() -> File {
|
||||
use libc::c_int;
|
||||
|
|
|
@ -9,8 +9,6 @@ use rstest::rstest;
|
|||
|
||||
use uucore::display::Quotable;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -436,7 +436,7 @@ fn test_touch_no_dereference() {
|
|||
|
||||
#[test]
|
||||
fn test_touch_reference() {
|
||||
let scenario = TestScenario::new("touch");
|
||||
let scenario = TestScenario::new(util_name!());
|
||||
let (at, mut _ucmd) = (scenario.fixtures.clone(), scenario.ucmd());
|
||||
let file_a = "test_touch_reference_a";
|
||||
let file_b = "test_touch_reference_b";
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
// 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 uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::{ffi::OsStr, os::unix::ffi::OsStrExt};
|
||||
|
|
|
@ -6,8 +6,6 @@ use regex::Regex;
|
|||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
||||
use std::fs::OpenOptions;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_no_args() {
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
use std::fs::File;
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
#[cfg(not(windows))]
|
||||
|
@ -70,7 +68,9 @@ fn test_help() {
|
|||
#[cfg(all(unix, not(target_os = "freebsd")))]
|
||||
fn test_stdout_fail() {
|
||||
use std::process::{Command, Stdio};
|
||||
let ts = TestScenario::new(util_name!());
|
||||
use uutests::at_and_ts;
|
||||
|
||||
let (_, ts) = at_and_ts!();
|
||||
// Sleep inside a shell to ensure the process doesn't finish before we've
|
||||
// closed its stdout
|
||||
let mut proc = Command::new("sh")
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
// file that was distributed with this source code.
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
// spell-checker:ignore contenta
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
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 OUTPUT: &str = "sorted-output.txt";
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
// file that was distributed with this source code.
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
@ -26,9 +24,8 @@ fn test_unlink_file() {
|
|||
|
||||
#[test]
|
||||
fn test_unlink_multiple_files() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let (at, mut ucmd) = (ts.fixtures.clone(), ts.ucmd());
|
||||
let file_a = "test_unlink_multiple_file_a";
|
||||
let file_b = "test_unlink_multiple_file_b";
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// spell-checker:ignore bincode serde utmp runlevel testusr testx
|
||||
#![allow(clippy::cast_possible_wrap, clippy::unreadable_literal)]
|
||||
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "freebsd")))]
|
||||
#[cfg(not(target_os = "openbsd"))]
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::{new_ucmd, util_name};
|
||||
|
@ -20,8 +20,7 @@ fn test_invalid_arg() {
|
|||
|
||||
#[test]
|
||||
fn test_uptime() {
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.succeeds()
|
||||
.stdout_contains("load average:")
|
||||
.stdout_contains(" up ");
|
||||
|
@ -79,9 +78,7 @@ fn test_uptime_with_fifo() {
|
|||
fn test_uptime_with_non_existent_file() {
|
||||
// Disabled for freebsd, since it doesn't use the utmpxname() sys call to change the default utmpx
|
||||
// file that is accessed using getutxent()
|
||||
let ts = TestScenario::new(util_name!());
|
||||
|
||||
ts.ucmd()
|
||||
new_ucmd!()
|
||||
.arg("file1")
|
||||
.fails()
|
||||
.stderr_contains("uptime: couldn't get boot time: No such file or directory")
|
||||
|
@ -107,16 +104,15 @@ fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() {
|
|||
|
||||
// This test will pass for freebsd but we currently don't support changing the utmpx file for
|
||||
// freebsd.
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
// Regex matches for "up 00::00" ,"up 12 days 00::00", the time can be any valid time and
|
||||
// the days can be more than 1 digit or not there. This will match even if the amount of whitespace is
|
||||
// wrong between the days and the time.
|
||||
|
||||
let re = Regex::new(r"up [(\d){1,} days]*\d{1,2}:\d\d").unwrap();
|
||||
utmp(&at.plus("testx"));
|
||||
ts.ucmd()
|
||||
.arg("testx")
|
||||
|
||||
ucmd.arg("testx")
|
||||
.succeeds()
|
||||
.stdout_matches(&re)
|
||||
.stdout_contains("load average");
|
||||
|
@ -240,9 +236,7 @@ fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() {
|
|||
|
||||
#[test]
|
||||
fn test_uptime_with_extra_argument() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
|
||||
ts.ucmd()
|
||||
new_ucmd!()
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.fails()
|
||||
|
@ -251,12 +245,11 @@ fn test_uptime_with_extra_argument() {
|
|||
/// Checks whether uptime displays the correct stderr msg when its called with a directory
|
||||
#[test]
|
||||
fn test_uptime_with_dir() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.mkdir("dir1");
|
||||
|
||||
ts.ucmd()
|
||||
.arg("dir1")
|
||||
ucmd.arg("dir1")
|
||||
.fails()
|
||||
.stderr_contains("uptime: couldn't get boot time: Is a directory")
|
||||
.stdout_contains("up ???? days ??:??");
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(unix)]
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::{TestScenario, vec_of_size};
|
||||
use uutests::util_name;
|
||||
use uutests::util::vec_of_size;
|
||||
|
||||
// spell-checker:ignore (flags) lwmcL clmwL ; (path) bogusfile emptyfile manyemptylines moby notrailingnewline onelongemptyline onelongword weirdchars
|
||||
#[test]
|
||||
|
@ -276,13 +275,12 @@ fn test_single_all_counts() {
|
|||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn test_gnu_compatible_quotation() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.mkdir("some-dir1");
|
||||
at.touch("some-dir1/12\n34.txt");
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["some-dir1/12\n34.txt"])
|
||||
|
||||
ucmd.args(&["some-dir1/12\n34.txt"])
|
||||
.succeeds()
|
||||
.stdout_is("0 0 0 'some-dir1/12'$'\\n''34.txt'\n");
|
||||
}
|
||||
|
@ -290,27 +288,25 @@ fn test_gnu_compatible_quotation() {
|
|||
#[cfg(feature = "test_risky_names")]
|
||||
#[test]
|
||||
fn test_non_unicode_names() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let target1 = uucore::os_str_from_bytes(b"some-dir1/1\xC0\n.txt")
|
||||
.expect("Only unix platforms can test non-unicode names");
|
||||
let target2 = uucore::os_str_from_bytes(b"some-dir1/2\xC0\t.txt")
|
||||
.expect("Only unix platforms can test non-unicode names");
|
||||
let at = &scene.fixtures;
|
||||
|
||||
at.mkdir("some-dir1");
|
||||
at.touch(&target1);
|
||||
at.touch(&target2);
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&[target1, target2])
|
||||
.succeeds()
|
||||
.stdout_is_bytes(
|
||||
[
|
||||
b"0 0 0 'some-dir1/1'$'\\300\\n''.txt'\n".to_vec(),
|
||||
b"0 0 0 some-dir1/2\xC0\t.txt\n".to_vec(),
|
||||
b"0 0 0 total\n".to_vec(),
|
||||
]
|
||||
.concat(),
|
||||
);
|
||||
|
||||
ucmd.args(&[target1, target2]).succeeds().stdout_is_bytes(
|
||||
[
|
||||
b"0 0 0 'some-dir1/1'$'\\300\\n''.txt'\n".to_vec(),
|
||||
b"0 0 0 some-dir1/2\xC0\t.txt\n".to_vec(),
|
||||
b"0 0 0 total\n".to_vec(),
|
||||
]
|
||||
.concat(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -7,9 +7,8 @@ use uutests::new_ucmd;
|
|||
#[cfg(unix)]
|
||||
use uutests::unwrap_or_return;
|
||||
#[cfg(unix)]
|
||||
use uutests::util::expected_result;
|
||||
use uutests::util::{TestScenario, is_ci, whoami};
|
||||
use uutests::util_name;
|
||||
use uutests::util::{TestScenario, expected_result};
|
||||
use uutests::util::{is_ci, whoami};
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
|
@ -19,11 +18,13 @@ fn test_invalid_arg() {
|
|||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn test_normal() {
|
||||
use uutests::util_name;
|
||||
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let exp_result = unwrap_or_return!(expected_result(&ts, &[]));
|
||||
let result = ts.ucmd().succeeds();
|
||||
|
||||
result
|
||||
ts.ucmd()
|
||||
.succeeds()
|
||||
.stdout_is(exp_result.stdout_str())
|
||||
.stderr_is(exp_result.stderr_str());
|
||||
}
|
||||
|
@ -33,6 +34,7 @@ fn test_normal() {
|
|||
fn test_normal_compare_id() {
|
||||
let ts = TestScenario::new("id");
|
||||
let id_un = unwrap_or_return!(expected_result(&ts, &["-un"]));
|
||||
|
||||
if id_un.succeeded() {
|
||||
new_ucmd!().succeeds().stdout_is(id_un.stdout_str());
|
||||
} else if is_ci() && id_un.stderr_str().contains("cannot find name for user ID") {
|
||||
|
@ -45,6 +47,7 @@ fn test_normal_compare_id() {
|
|||
#[test]
|
||||
fn test_normal_compare_env() {
|
||||
let whoami = whoami();
|
||||
|
||||
if whoami == "nobody" {
|
||||
println!("test skipped:");
|
||||
} else if !is_ci() {
|
||||
|
|
|
@ -9,8 +9,6 @@ use std::process::ExitStatus;
|
|||
use std::os::unix::process::ExitStatusExt;
|
||||
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util_name;
|
||||
|
||||
#[cfg(unix)]
|
||||
fn check_termination(result: ExitStatus) {
|
||||
|
|
|
@ -52,7 +52,7 @@ macro_rules! util_name {
|
|||
#[macro_export]
|
||||
macro_rules! new_ucmd {
|
||||
() => {
|
||||
TestScenario::new(util_name!()).ucmd()
|
||||
::uutests::util::TestScenario::new(::uutests::util_name!()).ucmd()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,22 @@ macro_rules! at_and_ucmd {
|
|||
}};
|
||||
}
|
||||
|
||||
/// Convenience macro for acquiring a [`TestScenario`] with its test path.
|
||||
///
|
||||
/// Returns a tuple containing the following:
|
||||
/// - a [`TestScenario`] for invoking commands
|
||||
/// - an [`AtPath`] that points to a unique temporary test directory
|
||||
///
|
||||
/// [`AtPath`]: crate::util::AtPath
|
||||
/// [`TestScenario`]: crate::util::TestScenario
|
||||
#[macro_export]
|
||||
macro_rules! at_and_ts {
|
||||
() => {{
|
||||
let ts = ::uutests::util::TestScenario::new(::uutests::util_name!());
|
||||
(ts.fixtures.clone(), ts)
|
||||
}};
|
||||
}
|
||||
|
||||
/// If `common::util::expected_result` returns an error, i.e. the `util` in `$PATH` doesn't
|
||||
/// include a coreutils version string or the version is too low,
|
||||
/// this macro can be used to automatically skip the test and print the reason.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue