mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
tests: patch tests to simplify imports
This commit is contained in:
parent
5ce678b1cd
commit
6e23d4e979
63 changed files with 242 additions and 343 deletions
|
@ -3,8 +3,6 @@
|
||||||
// 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;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_arch() {
|
fn test_arch() {
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_encode() {
|
fn test_encode() {
|
||||||
|
@ -114,10 +112,10 @@ fn test_wrap() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_wrap_no_arg() {
|
fn test_wrap_no_arg() {
|
||||||
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";
|
let expected_stderr = "a value is required for '--wrap <COLS>' but none was supplied";
|
||||||
ts.ucmd()
|
|
||||||
|
for wrap_param in ["-w", "--wrap"] {
|
||||||
|
new_ucmd!()
|
||||||
.arg(wrap_param)
|
.arg(wrap_param)
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_contains(expected_stderr)
|
.stderr_contains(expected_stderr)
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
use uutests::util::TestScenario;
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_encode() {
|
fn test_encode() {
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
#[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::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_help() {
|
fn test_help() {
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
// spell-checker: ignore (encodings) lsbf msbf
|
// spell-checker: ignore (encodings) lsbf msbf
|
||||||
|
|
||||||
use uutests::new_ucmd;
|
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() {
|
||||||
|
|
|
@ -12,8 +12,6 @@ use std::{io, iter, str};
|
||||||
|
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn version() {
|
fn version() {
|
||||||
|
|
|
@ -5,10 +5,9 @@
|
||||||
// spell-checker:ignore (words) nosuchgroup groupname
|
// spell-checker:ignore (words) nosuchgroup groupname
|
||||||
|
|
||||||
use uucore::process::getegid;
|
use uucore::process::getegid;
|
||||||
use uutests::at_and_ucmd;
|
use uutests::{at_and_ucmd, new_ucmd};
|
||||||
use uutests::new_ucmd;
|
#[cfg(not(target_vendor = "apple"))]
|
||||||
use uutests::util::TestScenario;
|
use uutests::{util::TestScenario, util_name};
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_option() {
|
fn test_invalid_option() {
|
||||||
|
@ -370,7 +369,7 @@ fn test_traverse_symlinks() {
|
||||||
(&["-P"][..], false, false),
|
(&["-P"][..], false, false),
|
||||||
(&["-L"][..], true, true),
|
(&["-L"][..], true, true),
|
||||||
] {
|
] {
|
||||||
let scenario = TestScenario::new("chgrp");
|
let scenario = TestScenario::new(util_name!());
|
||||||
|
|
||||||
let (at, mut ucmd) = (scenario.fixtures.clone(), scenario.ucmd());
|
let (at, mut ucmd) = (scenario.fixtures.clone(), scenario.ucmd());
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
use glob::glob;
|
use glob::glob;
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_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.
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
static INPUT: &str = "lists.txt";
|
static INPUT: &str = "lists.txt";
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,6 @@ use std::collections::HashSet;
|
||||||
#[cfg(not(any(target_os = "freebsd", target_os = "windows")))]
|
#[cfg(not(any(target_os = "freebsd", target_os = "windows")))]
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_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,6 @@
|
||||||
// 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 uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
use dircolors::{OutputFmt, StrUtils, guess_syntax};
|
use dircolors::{OutputFmt, StrUtils, guess_syntax};
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// 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;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
use uutests::util::TestScenario;
|
||||||
use uutests::util::UCommand;
|
use uutests::util::UCommand;
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_default() {
|
fn test_default() {
|
||||||
|
@ -654,7 +653,7 @@ fn test_cmd_result_stdout_str_check_when_false_then_panics() {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cmd_result_signal_when_normal_exit_then_no_signal() {
|
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());
|
assert!(result.signal().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uutests::new_ucmd;
|
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]
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
// spell-checker:ignore orempty oror
|
// spell-checker:ignore orempty oror
|
||||||
|
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_no_arguments() {
|
fn test_no_arguments() {
|
||||||
|
@ -643,8 +641,6 @@ 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 uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_a() {
|
fn test_a() {
|
||||||
|
|
|
@ -6,8 +6,7 @@ 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::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();
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
// spell-checker:ignore plass samp
|
// spell-checker:ignore plass samp
|
||||||
|
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// 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;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -18,6 +18,7 @@ macro_rules! test_digest {
|
||||||
|
|
||||||
mod $id {
|
mod $id {
|
||||||
use uutests::util::*;
|
use uutests::util::*;
|
||||||
|
use uutests::util_name;
|
||||||
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");
|
||||||
|
@ -26,21 +27,21 @@ macro_rules! test_digest {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_single_file() {
|
fn test_single_file() {
|
||||||
let ts = TestScenario::new("hashsum");
|
let ts = TestScenario::new(util_name!());
|
||||||
assert_eq!(ts.fixtures.read(EXPECTED_FILE),
|
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()));
|
get_hash!(ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).arg(INPUT_FILE).succeeds().no_stderr().stdout_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_stdin() {
|
fn test_stdin() {
|
||||||
let ts = TestScenario::new("hashsum");
|
let ts = TestScenario::new(util_name!());
|
||||||
assert_eq!(ts.fixtures.read(EXPECTED_FILE),
|
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()));
|
get_hash!(ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).pipe_in_fixture(INPUT_FILE).succeeds().no_stderr().stdout_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_nonames() {
|
fn test_nonames() {
|
||||||
let ts = TestScenario::new("hashsum");
|
let ts = TestScenario::new(util_name!());
|
||||||
// EXPECTED_FILE has no newline character at the end
|
// EXPECTED_FILE has no newline character at the end
|
||||||
if DIGEST_ARG == "--b3sum" {
|
if DIGEST_ARG == "--b3sum" {
|
||||||
// Option only available on b3sum
|
// Option only available on b3sum
|
||||||
|
@ -53,7 +54,7 @@ macro_rules! test_digest {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_check() {
|
fn test_check() {
|
||||||
let ts = TestScenario::new("hashsum");
|
let ts = TestScenario::new(util_name!());
|
||||||
println!("File content='{}'", ts.fixtures.read(INPUT_FILE));
|
println!("File content='{}'", ts.fixtures.read(INPUT_FILE));
|
||||||
println!("Check file='{}'", ts.fixtures.read(CHECK_FILE));
|
println!("Check file='{}'", ts.fixtures.read(CHECK_FILE));
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ macro_rules! test_digest {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_zero() {
|
fn test_zero() {
|
||||||
let ts = TestScenario::new("hashsum");
|
let ts = TestScenario::new(util_name!());
|
||||||
assert_eq!(ts.fixtures.read(EXPECTED_FILE),
|
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()));
|
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]
|
#[test]
|
||||||
fn test_text_mode() {
|
fn test_text_mode() {
|
||||||
use uutests::new_ucmd;
|
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
|
||||||
|
@ -101,7 +101,7 @@ macro_rules! test_digest {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_missing_file() {
|
fn test_missing_file() {
|
||||||
let ts = TestScenario::new("hashsum");
|
let ts = TestScenario::new(util_name!());
|
||||||
let at = &ts.fixtures;
|
let at = &ts.fixtures;
|
||||||
|
|
||||||
at.write("a", "file1\n");
|
at.write("a", "file1\n");
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_normal() {
|
fn test_normal() {
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// 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;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_hostname() {
|
fn test_hostname() {
|
||||||
|
|
|
@ -7,8 +7,6 @@ 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::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 {
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_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,7 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use std::env;
|
use std::env;
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::{TestScenario, is_ci};
|
use uutests::util::is_ci;
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
use std::io::IsTerminal;
|
use std::io::IsTerminal;
|
||||||
|
|
||||||
use uutests::{at_and_ucmd, new_ucmd, util::TestScenario, util_name};
|
use uutests::{at_and_ucmd, new_ucmd};
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -75,8 +75,8 @@ fn test_file_arg() {
|
||||||
// but I am leaving this for later
|
// but I am leaving this for later
|
||||||
if std::io::stdout().is_terminal() {
|
if std::io::stdout().is_terminal() {
|
||||||
// Directory as argument
|
// Directory as argument
|
||||||
let mut ucmd = TestScenario::new(util_name!()).ucmd();
|
new_ucmd!()
|
||||||
ucmd.arg(".")
|
.arg(".")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stderr_contains("'.' is a directory.");
|
.stderr_contains("'.' is a directory.");
|
||||||
|
|
||||||
|
@ -87,14 +87,14 @@ fn test_file_arg() {
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stderr_contains("is a directory");
|
.stderr_contains("is a directory");
|
||||||
|
|
||||||
ucmd = TestScenario::new(util_name!()).ucmd();
|
new_ucmd!()
|
||||||
ucmd.arg("nonexistent_file")
|
.arg("nonexistent_file")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stderr_contains("No such file or directory");
|
.stderr_contains("No such file or directory");
|
||||||
|
|
||||||
// Multiple nonexistent files
|
// Multiple nonexistent files
|
||||||
ucmd = TestScenario::new(util_name!()).ucmd();
|
new_ucmd!()
|
||||||
ucmd.arg("file2")
|
.arg("file2")
|
||||||
.arg("file3")
|
.arg("file3")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stderr_contains("file2")
|
.stderr_contains("file2")
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
// 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 uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(target_os = "android"))]
|
#[cfg(not(target_os = "android"))]
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
// spell-checker:ignore (paths) gnutest ronna quetta
|
// spell-checker:ignore (paths) gnutest ronna quetta
|
||||||
|
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_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,
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// 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;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_no_args() {
|
fn test_no_args() {
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
use chrono::{DateTime, Duration, Utc};
|
use chrono::{DateTime, Duration, Utc};
|
||||||
use std::fs::metadata;
|
use std::fs::metadata;
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::{TestScenario, UCommand};
|
use uutests::util::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,13 +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 uutests::util::TestScenario;
|
use uutests::new_ucmd;
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_all() {
|
fn test_get_all() {
|
||||||
TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.env("HOME", "FOO")
|
.env("HOME", "FOO")
|
||||||
.env("KEY", "VALUE")
|
.env("KEY", "VALUE")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
|
@ -18,21 +16,15 @@ fn test_get_all() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_var() {
|
fn test_get_var() {
|
||||||
let result = TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.env("KEY", "VALUE")
|
.env("KEY", "VALUE")
|
||||||
.arg("KEY")
|
.arg("KEY")
|
||||||
.succeeds();
|
.succeeds()
|
||||||
|
.stdout_contains("VALUE\n");
|
||||||
assert!(!result.stdout_str().is_empty());
|
|
||||||
assert_eq!(result.stdout_str().trim(), "VALUE");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ignore_equal_var() {
|
fn test_ignore_equal_var() {
|
||||||
let scene = TestScenario::new(util_name!());
|
|
||||||
// tested by gnu/tests/misc/printenv.sh
|
// tested by gnu/tests/misc/printenv.sh
|
||||||
let result = scene.ucmd().env("a=b", "c").arg("a=b").fails();
|
new_ucmd!().env("a=b", "c").arg("a=b").fails().no_stdout();
|
||||||
|
|
||||||
assert!(result.stdout_str().is_empty());
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
|
|
||||||
// spell-checker:ignore fffffffffffffffc
|
// spell-checker:ignore fffffffffffffffc
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_literal() {
|
fn basic_literal() {
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
// spell-checker:ignore roff
|
// spell-checker:ignore roff
|
||||||
|
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -6,10 +6,9 @@
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::{TestScenario, UCommand};
|
use uutests::util::UCommand;
|
||||||
//use uutests::at_and_ucmd;
|
|
||||||
use uutests::{at_and_ucmd, util_name};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
@ -32,6 +31,8 @@ fn test_failed() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_deleted_dir() {
|
fn test_deleted_dir() {
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
let at = &ts.fixtures;
|
let at = &ts.fixtures;
|
||||||
|
|
|
@ -22,13 +22,12 @@ fn test_invalid_arg() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_resolve() {
|
fn test_resolve() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
|
|
||||||
at.touch("foo");
|
at.touch("foo");
|
||||||
at.symlink_file("foo", "bar");
|
at.symlink_file("foo", "bar");
|
||||||
|
|
||||||
scene.ucmd().arg("bar").succeeds().stdout_contains("foo\n");
|
ucmd.arg("bar").succeeds().stdout_contains("foo\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_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";
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
#![cfg(feature = "feat_selinux")]
|
#![cfg(feature = "feat_selinux")]
|
||||||
|
|
||||||
use uutests::new_ucmd;
|
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.
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
// 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 uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -102,8 +102,7 @@ fn test_shred_remove_wipesync() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_shred_u() {
|
fn test_shred_u() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
|
|
||||||
let file_a = "test_shred_remove_a";
|
let file_a = "test_shred_remove_a";
|
||||||
let file_b = "test_shred_remove_b";
|
let file_b = "test_shred_remove_b";
|
||||||
|
@ -113,7 +112,7 @@ fn test_shred_u() {
|
||||||
at.touch(file_b);
|
at.touch(file_b);
|
||||||
|
|
||||||
// Shred file_a.
|
// 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.
|
// file_a was deleted, file_b exists.
|
||||||
assert!(!at.file_exists(file_a));
|
assert!(!at.file_exists(file_a));
|
||||||
|
@ -239,13 +238,12 @@ fn test_shred_verbose_no_padding_10() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_all_patterns_present() {
|
fn test_all_patterns_present() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
|
|
||||||
let file = "foo.txt";
|
let file = "foo.txt";
|
||||||
at.write(file, "bar");
|
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 {
|
for pat in PATTERNS {
|
||||||
result.stderr_contains(pat);
|
result.stderr_contains(pat);
|
||||||
|
@ -254,24 +252,28 @@ fn test_all_patterns_present() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_random_source_regular_file() {
|
fn test_random_source_regular_file() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
// Currently, our block size is 4096. If it changes, this test has to be adapted.
|
// Currently, our block size is 4096. If it changes, this test has to be adapted.
|
||||||
let mut many_bytes = Vec::with_capacity(4096 * 4);
|
let mut many_bytes = Vec::with_capacity(4096 * 4);
|
||||||
|
|
||||||
for i in 0..4096u32 {
|
for i in 0..4096u32 {
|
||||||
many_bytes.extend(i.to_le_bytes());
|
many_bytes.extend(i.to_le_bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(many_bytes.len(), 4096 * 4);
|
assert_eq!(many_bytes.len(), 4096 * 4);
|
||||||
at.write_bytes("source_long", &many_bytes);
|
at.write_bytes("source_long", &many_bytes);
|
||||||
|
|
||||||
let file = "foo.txt";
|
let file = "foo.txt";
|
||||||
at.write(file, "a");
|
at.write(file, "a");
|
||||||
scene
|
|
||||||
.ucmd()
|
ucmd
|
||||||
.arg("-vn3")
|
.arg("-vn3")
|
||||||
.arg("--random-source=source_long")
|
.arg("--random-source=source_long")
|
||||||
.arg(file)
|
.arg(file)
|
||||||
.succeeds()
|
.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");
|
.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
|
// Should rewrite the file exactly three times
|
||||||
assert_eq!(at.read_bytes(file), many_bytes[(4096 * 2)..(4096 * 3)]);
|
assert_eq!(at.read_bytes(file), many_bytes[(4096 * 2)..(4096 * 3)]);
|
||||||
}
|
}
|
||||||
|
@ -279,13 +281,13 @@ fn test_random_source_regular_file() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore = "known issue #7947"]
|
#[ignore = "known issue #7947"]
|
||||||
fn test_random_source_dir() {
|
fn test_random_source_dir() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
at.mkdir("source");
|
at.mkdir("source");
|
||||||
let file = "foo.txt";
|
let file = "foo.txt";
|
||||||
at.write(file, "a");
|
at.write(file, "a");
|
||||||
scene
|
|
||||||
.ucmd()
|
ucmd
|
||||||
.arg("-v")
|
.arg("-v")
|
||||||
.arg("--random-source=source")
|
.arg("--random-source=source")
|
||||||
.arg(file)
|
.arg(file)
|
||||||
|
@ -302,12 +304,15 @@ fn test_shred_rename_exhaustion() {
|
||||||
at.touch("test");
|
at.touch("test");
|
||||||
at.touch("000");
|
at.touch("000");
|
||||||
|
|
||||||
let result = scene.ucmd().arg("-vu").arg("test").succeeds();
|
scene
|
||||||
|
.ucmd()
|
||||||
result.stderr_contains("renamed to 0000");
|
.arg("-vu")
|
||||||
result.stderr_contains("renamed to 001");
|
.arg("test")
|
||||||
result.stderr_contains("renamed to 00");
|
.succeeds()
|
||||||
result.stderr_contains("removed");
|
.stderr_contains("renamed to 0000")
|
||||||
|
.stderr_contains("renamed to 001")
|
||||||
|
.stderr_contains("renamed to 00")
|
||||||
|
.stderr_contains("removed");
|
||||||
|
|
||||||
assert!(!at.file_exists("test"));
|
assert!(!at.file_exists("test"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
// spell-checker:ignore (ToDO) unwritable
|
// spell-checker:ignore (ToDO) unwritable
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -7,8 +7,6 @@ use rstest::rstest;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
// spell-checker:ignore dont SIGBUS SIGSEGV sigsegv sigbus infd
|
// spell-checker:ignore dont SIGBUS SIGSEGV sigsegv sigbus infd
|
||||||
use uutests::new_ucmd;
|
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};
|
||||||
|
@ -317,7 +315,7 @@ fn test_invalid_duration(#[case] input: &str) {
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic = "Program must be run first or has not finished"]
|
#[should_panic = "Program must be run first or has not finished"]
|
||||||
fn test_cmd_result_signal_when_still_running_then_panic() {
|
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
|
child
|
||||||
.make_assertion()
|
.make_assertion()
|
||||||
|
@ -329,7 +327,7 @@ fn test_cmd_result_signal_when_still_running_then_panic() {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cmd_result_signal_when_kill_then_signal() {
|
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.kill();
|
||||||
child
|
child
|
||||||
|
@ -343,8 +341,9 @@ fn test_cmd_result_signal_when_kill_then_signal() {
|
||||||
.signal()
|
.signal()
|
||||||
.expect("Signal was none");
|
.expect("Signal was none");
|
||||||
|
|
||||||
let result = child.wait().unwrap();
|
child
|
||||||
result
|
.wait()
|
||||||
|
.unwrap()
|
||||||
.signal_is(9)
|
.signal_is(9)
|
||||||
.signal_name_is("SIGKILL")
|
.signal_name_is("SIGKILL")
|
||||||
.signal_name_is("KILL")
|
.signal_name_is("KILL")
|
||||||
|
@ -361,16 +360,16 @@ fn test_cmd_result_signal_when_kill_then_signal() {
|
||||||
#[case::signal_value_negative("-1")]
|
#[case::signal_value_negative("-1")]
|
||||||
#[should_panic = "Invalid signal name or value"]
|
#[should_panic = "Invalid signal name or value"]
|
||||||
fn test_cmd_result_signal_when_invalid_signal_name_then_panic(#[case] signal_name: &str) {
|
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();
|
child.kill();
|
||||||
let result = child.wait().unwrap();
|
child.wait().unwrap().signal_name_is(signal_name);
|
||||||
result.signal_name_is(signal_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn test_cmd_result_signal_name_is_accepts_lowercase() {
|
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();
|
child.kill();
|
||||||
let result = child.wait().unwrap();
|
let result = child.wait().unwrap();
|
||||||
result.signal_name_is("sigkill");
|
result.signal_name_is("sigkill");
|
||||||
|
@ -379,9 +378,7 @@ fn test_cmd_result_signal_name_is_accepts_lowercase() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uchild_when_wait_and_timeout_is_reached_then_timeout_error() {
|
fn test_uchild_when_wait_and_timeout_is_reached_then_timeout_error() {
|
||||||
let ts = TestScenario::new("sleep");
|
let child = new_ucmd!()
|
||||||
let child = ts
|
|
||||||
.ucmd()
|
|
||||||
.timeout(Duration::from_secs(1))
|
.timeout(Duration::from_secs(1))
|
||||||
.arg("10.0")
|
.arg("10.0")
|
||||||
.run_no_wait();
|
.run_no_wait();
|
||||||
|
@ -398,9 +395,7 @@ fn test_uchild_when_wait_and_timeout_is_reached_then_timeout_error() {
|
||||||
#[rstest]
|
#[rstest]
|
||||||
#[timeout(Duration::from_secs(5))]
|
#[timeout(Duration::from_secs(5))]
|
||||||
fn test_uchild_when_kill_and_timeout_higher_than_kill_time_then_no_panic() {
|
fn test_uchild_when_kill_and_timeout_higher_than_kill_time_then_no_panic() {
|
||||||
let ts = TestScenario::new("sleep");
|
let mut child = new_ucmd!()
|
||||||
let mut child = ts
|
|
||||||
.ucmd()
|
|
||||||
.timeout(Duration::from_secs(60))
|
.timeout(Duration::from_secs(60))
|
||||||
.arg("20.0")
|
.arg("20.0")
|
||||||
.run_no_wait();
|
.run_no_wait();
|
||||||
|
@ -410,8 +405,10 @@ fn test_uchild_when_kill_and_timeout_higher_than_kill_time_then_no_panic() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uchild_when_try_kill_and_timeout_is_reached_then_error() {
|
fn test_uchild_when_try_kill_and_timeout_is_reached_then_error() {
|
||||||
let ts = TestScenario::new("sleep");
|
let mut child = new_ucmd!()
|
||||||
let mut child = ts.ucmd().timeout(Duration::ZERO).arg("10.0").run_no_wait();
|
.timeout(Duration::ZERO)
|
||||||
|
.arg("10.0")
|
||||||
|
.run_no_wait();
|
||||||
|
|
||||||
match child.try_kill() {
|
match child.try_kill() {
|
||||||
Err(error) if error.kind() == ErrorKind::Other => {
|
Err(error) if error.kind() == ErrorKind::Other => {
|
||||||
|
@ -425,8 +422,10 @@ fn test_uchild_when_try_kill_and_timeout_is_reached_then_error() {
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic = "kill: Timeout of '0s' reached"]
|
#[should_panic = "kill: Timeout of '0s' reached"]
|
||||||
fn test_uchild_when_kill_with_timeout_and_timeout_is_reached_then_panic() {
|
fn test_uchild_when_kill_with_timeout_and_timeout_is_reached_then_panic() {
|
||||||
let ts = TestScenario::new("sleep");
|
let mut child = new_ucmd!()
|
||||||
let mut child = ts.ucmd().timeout(Duration::ZERO).arg("10.0").run_no_wait();
|
.timeout(Duration::ZERO)
|
||||||
|
.arg("10.0")
|
||||||
|
.run_no_wait();
|
||||||
|
|
||||||
child.kill();
|
child.kill();
|
||||||
panic!("Assertion failed: Expected timeout of `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]
|
#[test]
|
||||||
#[should_panic(expected = "wait: Timeout of '1.1s' reached")]
|
#[should_panic(expected = "wait: Timeout of '1.1s' reached")]
|
||||||
fn test_ucommand_when_run_with_timeout_and_timeout_is_reached_then_panic() {
|
fn test_ucommand_when_run_with_timeout_and_timeout_is_reached_then_panic() {
|
||||||
let ts = TestScenario::new("sleep");
|
new_ucmd!()
|
||||||
ts.ucmd()
|
|
||||||
.timeout(Duration::from_millis(1100))
|
.timeout(Duration::from_millis(1100))
|
||||||
.arg("10.0")
|
.arg("10.0")
|
||||||
.run();
|
.run();
|
||||||
|
@ -447,6 +445,8 @@ fn test_ucommand_when_run_with_timeout_and_timeout_is_reached_then_panic() {
|
||||||
#[rstest]
|
#[rstest]
|
||||||
#[timeout(Duration::from_secs(10))]
|
#[timeout(Duration::from_secs(10))]
|
||||||
fn test_ucommand_when_run_with_timeout_higher_then_execution_time_then_no_panic() {
|
fn test_ucommand_when_run_with_timeout_higher_then_execution_time_then_no_panic() {
|
||||||
let ts = TestScenario::new("sleep");
|
new_ucmd!()
|
||||||
ts.ucmd().timeout(Duration::from_secs(60)).arg("1.0").run();
|
.timeout(Duration::from_secs(60))
|
||||||
|
.arg("1.0")
|
||||||
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,6 @@ use std::time::Duration;
|
||||||
|
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_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 {
|
||||||
|
@ -38,8 +36,7 @@ fn test_buffer_sizes() {
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
let buffer_sizes = ["0", "50K", "50k", "1M", "100M"];
|
let buffer_sizes = ["0", "50K", "50k", "1M", "100M"];
|
||||||
for buffer_size in &buffer_sizes {
|
for buffer_size in &buffer_sizes {
|
||||||
TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.arg("-n")
|
.arg("-n")
|
||||||
.arg("-S")
|
.arg("-S")
|
||||||
.arg(buffer_size)
|
.arg(buffer_size)
|
||||||
|
@ -52,8 +49,7 @@ fn test_buffer_sizes() {
|
||||||
{
|
{
|
||||||
let buffer_sizes = ["1000G", "10T"];
|
let buffer_sizes = ["1000G", "10T"];
|
||||||
for buffer_size in &buffer_sizes {
|
for buffer_size in &buffer_sizes {
|
||||||
TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.arg("-n")
|
.arg("-n")
|
||||||
.arg("-S")
|
.arg("-S")
|
||||||
.arg(buffer_size)
|
.arg(buffer_size)
|
||||||
|
@ -1007,8 +1003,7 @@ fn test_compress_merge() {
|
||||||
#[cfg(not(target_os = "android"))]
|
#[cfg(not(target_os = "android"))]
|
||||||
fn test_compress_fail() {
|
fn test_compress_fail() {
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.args(&[
|
.args(&[
|
||||||
"ext_sort.txt",
|
"ext_sort.txt",
|
||||||
"-n",
|
"-n",
|
||||||
|
@ -1023,8 +1018,7 @@ fn test_compress_fail() {
|
||||||
// "thread 'main' panicked at 'called `Option::unwrap()` on ...
|
// "thread 'main' panicked at 'called `Option::unwrap()` on ...
|
||||||
// So, don't check the output
|
// So, don't check the output
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.args(&[
|
.args(&[
|
||||||
"ext_sort.txt",
|
"ext_sort.txt",
|
||||||
"-n",
|
"-n",
|
||||||
|
@ -1038,8 +1032,7 @@ fn test_compress_fail() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_merge_batches() {
|
fn test_merge_batches() {
|
||||||
TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.timeout(Duration::from_secs(120))
|
.timeout(Duration::from_secs(120))
|
||||||
.args(&["ext_sort.txt", "-n", "-S", "150b"])
|
.args(&["ext_sort.txt", "-n", "-S", "150b"])
|
||||||
.succeeds()
|
.succeeds()
|
||||||
|
@ -1048,15 +1041,14 @@ fn test_merge_batches() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_batch_size_invalid() {
|
fn test_batch_size_invalid() {
|
||||||
TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.arg("--batch-size=0")
|
.arg("--batch-size=0")
|
||||||
.fails_with_code(2)
|
.fails_with_code(2)
|
||||||
.stderr_contains("sort: invalid --batch-size argument '0'")
|
.stderr_contains("sort: invalid --batch-size argument '0'")
|
||||||
.stderr_contains("sort: minimum --batch-size argument is '2'");
|
.stderr_contains("sort: minimum --batch-size argument is '2'");
|
||||||
|
|
||||||
// with -m, the error path is a bit different
|
// with -m, the error path is a bit different
|
||||||
TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.args(&["-m", "--batch-size=a"])
|
.args(&["-m", "--batch-size=a"])
|
||||||
.fails_with_code(2)
|
.fails_with_code(2)
|
||||||
.stderr_contains("sort: invalid --batch-size argument 'a'");
|
.stderr_contains("sort: invalid --batch-size argument 'a'");
|
||||||
|
@ -1065,16 +1057,15 @@ fn test_batch_size_invalid() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_batch_size_too_large() {
|
fn test_batch_size_too_large() {
|
||||||
let large_batch_size = "18446744073709551616";
|
let large_batch_size = "18446744073709551616";
|
||||||
TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.arg(format!("--batch-size={large_batch_size}"))
|
.arg(format!("--batch-size={large_batch_size}"))
|
||||||
.fails_with_code(2)
|
.fails_with_code(2)
|
||||||
.stderr_contains(format!(
|
.stderr_contains(format!(
|
||||||
"--batch-size argument '{large_batch_size}' too large"
|
"--batch-size argument '{large_batch_size}' too large"
|
||||||
));
|
));
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.arg(format!("--batch-size={large_batch_size}"))
|
.arg(format!("--batch-size={large_batch_size}"))
|
||||||
.fails_with_code(2)
|
.fails_with_code(2)
|
||||||
.stderr_contains("maximum --batch-size argument with current rlimit is");
|
.stderr_contains("maximum --batch-size argument with current rlimit is");
|
||||||
|
@ -1082,8 +1073,7 @@ fn test_batch_size_too_large() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_merge_batch_size() {
|
fn test_merge_batch_size() {
|
||||||
TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.arg("--batch-size=2")
|
.arg("--batch-size=2")
|
||||||
.arg("-m")
|
.arg("-m")
|
||||||
.arg("--unique")
|
.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 CTRL+C handling logic (to be reworked at some point)
|
||||||
// 2 descriptors for the input files (i.e. batch-size of 2).
|
// 2 descriptors for the input files (i.e. batch-size of 2).
|
||||||
let limit_fd = 3 + 2 + 2;
|
let limit_fd = 3 + 2 + 2;
|
||||||
TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.limit(Resource::NOFILE, limit_fd, limit_fd)
|
.limit(Resource::NOFILE, limit_fd, limit_fd)
|
||||||
.arg("--batch-size=2")
|
.arg("--batch-size=2")
|
||||||
.arg("-m")
|
.arg("-m")
|
||||||
|
@ -1210,13 +1199,12 @@ fn test_separator_null() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_output_is_input() {
|
fn test_output_is_input() {
|
||||||
let input = "a\nb\nc\n";
|
let input = "a\nb\nc\n";
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
at.touch("file");
|
at.touch("file");
|
||||||
at.append("file", input);
|
at.append("file", input);
|
||||||
scene
|
|
||||||
.ucmd()
|
ucmd.args(&["-m", "-u", "-o", "file", "file", "file", "file"])
|
||||||
.args(&["-m", "-u", "-o", "file", "file", "file", "file"])
|
|
||||||
.succeeds();
|
.succeeds();
|
||||||
assert_eq!(at.read("file"), input);
|
assert_eq!(at.read("file"), input);
|
||||||
}
|
}
|
||||||
|
@ -1400,12 +1388,11 @@ fn test_files0_from_minus_in_stdin() {
|
||||||
#[test]
|
#[test]
|
||||||
// Test for GNU tests/sort/sort-files0-from.pl "empty"
|
// Test for GNU tests/sort/sort-files0-from.pl "empty"
|
||||||
fn test_files0_from_empty() {
|
fn test_files0_from_empty() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
at.touch("file");
|
at.touch("file");
|
||||||
scene
|
|
||||||
.ucmd()
|
ucmd.args(&["--files0-from", "file"])
|
||||||
.args(&["--files0-from", "file"])
|
|
||||||
.fails_with_code(2)
|
.fails_with_code(2)
|
||||||
.stderr_only("sort: no input from 'file'\n");
|
.stderr_only("sort: no input from 'file'\n");
|
||||||
}
|
}
|
||||||
|
@ -1443,13 +1430,12 @@ fn test_files0_from_nul2() {
|
||||||
#[test]
|
#[test]
|
||||||
// Test for GNU tests/sort/sort-files0-from.pl "1"
|
// Test for GNU tests/sort/sort-files0-from.pl "1"
|
||||||
fn test_files0_from_1() {
|
fn test_files0_from_1() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
at.touch("file");
|
at.touch("file");
|
||||||
at.append("file", "a");
|
at.append("file", "a");
|
||||||
scene
|
|
||||||
.ucmd()
|
ucmd.args(&["--files0-from", "-"])
|
||||||
.args(&["--files0-from", "-"])
|
|
||||||
.pipe_in("file")
|
.pipe_in("file")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only("a\n");
|
.stdout_only("a\n");
|
||||||
|
@ -1458,13 +1444,12 @@ fn test_files0_from_1() {
|
||||||
#[test]
|
#[test]
|
||||||
// Test for GNU tests/sort/sort-files0-from.pl "1a"
|
// Test for GNU tests/sort/sort-files0-from.pl "1a"
|
||||||
fn test_files0_from_1a() {
|
fn test_files0_from_1a() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
at.touch("file");
|
at.touch("file");
|
||||||
at.append("file", "a");
|
at.append("file", "a");
|
||||||
scene
|
|
||||||
.ucmd()
|
ucmd.args(&["--files0-from", "-"])
|
||||||
.args(&["--files0-from", "-"])
|
|
||||||
.pipe_in("file\0")
|
.pipe_in("file\0")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only("a\n");
|
.stdout_only("a\n");
|
||||||
|
@ -1473,13 +1458,12 @@ fn test_files0_from_1a() {
|
||||||
#[test]
|
#[test]
|
||||||
// Test for GNU tests/sort/sort-files0-from.pl "2"
|
// Test for GNU tests/sort/sort-files0-from.pl "2"
|
||||||
fn test_files0_from_2() {
|
fn test_files0_from_2() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
at.touch("file");
|
at.touch("file");
|
||||||
at.append("file", "a");
|
at.append("file", "a");
|
||||||
scene
|
|
||||||
.ucmd()
|
ucmd.args(&["--files0-from", "-"])
|
||||||
.args(&["--files0-from", "-"])
|
|
||||||
.pipe_in("file\0file")
|
.pipe_in("file\0file")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only("a\na\n");
|
.stdout_only("a\na\n");
|
||||||
|
@ -1488,13 +1472,12 @@ fn test_files0_from_2() {
|
||||||
#[test]
|
#[test]
|
||||||
// Test for GNU tests/sort/sort-files0-from.pl "2a"
|
// Test for GNU tests/sort/sort-files0-from.pl "2a"
|
||||||
fn test_files0_from_2a() {
|
fn test_files0_from_2a() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
at.touch("file");
|
at.touch("file");
|
||||||
at.append("file", "a");
|
at.append("file", "a");
|
||||||
scene
|
|
||||||
.ucmd()
|
ucmd.args(&["--files0-from", "-"])
|
||||||
.args(&["--files0-from", "-"])
|
|
||||||
.pipe_in("file\0file\0")
|
.pipe_in("file\0file\0")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only("a\na\n");
|
.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 for obsolete lines option as part of invalid combined short options
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_obs_lines_within_invalid_combined_shorts() {
|
fn test_split_obs_lines_within_invalid_combined_shorts() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
at.touch("file");
|
at.touch("file");
|
||||||
|
|
||||||
scene
|
ucmd.args(&["-2fb", "file"])
|
||||||
.ucmd()
|
|
||||||
.args(&["-2fb", "file"])
|
|
||||||
.fails_with_code(1)
|
.fails_with_code(1)
|
||||||
.stderr_contains("error: unexpected argument '-f' found\n");
|
.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 for obsolete lines option as part of combined short options
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_obs_lines_within_combined_shorts() {
|
fn test_split_obs_lines_within_combined_shorts() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
let name = "obs-lines-within-shorts";
|
|
||||||
RandomFile::new(at, name).add_lines(400);
|
|
||||||
|
|
||||||
scene
|
let name = "obs-lines-within-shorts";
|
||||||
.ucmd()
|
RandomFile::new(&at, name).add_lines(400);
|
||||||
.args(&["-x200de", name])
|
|
||||||
|
ucmd.args(&["-x200de", name])
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.no_stderr()
|
.no_stderr()
|
||||||
.no_stdout();
|
.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.count(), 2);
|
||||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
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 (at, mut ucmd) = at_and_ucmd!();
|
||||||
let name = "obs-lines-combined-shorts-tailing-suffix-length";
|
let name = "obs-lines-combined-shorts-tailing-suffix-length";
|
||||||
RandomFile::new(&at, name).add_lines(1000);
|
RandomFile::new(&at, name).add_lines(1000);
|
||||||
|
|
||||||
ucmd.args(&["-d200a4", name]).succeeds();
|
ucmd.args(&["-d200a4", name]).succeeds();
|
||||||
|
|
||||||
let glob = Glob::new(&at, ".", r"x\d\d\d\d$");
|
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 for obsolete lines option starts as part of combined short options
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_obs_lines_starts_combined_shorts() {
|
fn test_split_obs_lines_starts_combined_shorts() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
let name = "obs-lines-starts-shorts";
|
|
||||||
RandomFile::new(at, name).add_lines(400);
|
|
||||||
|
|
||||||
scene
|
let name = "obs-lines-starts-shorts";
|
||||||
.ucmd()
|
RandomFile::new(&at, name).add_lines(400);
|
||||||
.args(&["-200xd", name])
|
|
||||||
|
ucmd.args(&["-200xd", name])
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.no_stderr()
|
.no_stderr()
|
||||||
.no_stdout();
|
.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.count(), 2);
|
||||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||||
}
|
}
|
||||||
|
@ -647,18 +643,17 @@ fn test_split_obs_lines_as_other_option_value() {
|
||||||
/// last one wins
|
/// last one wins
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_multiple_obs_lines_standalone() {
|
fn test_split_multiple_obs_lines_standalone() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
let name = "multiple-obs-lines";
|
|
||||||
RandomFile::new(at, name).add_lines(400);
|
|
||||||
|
|
||||||
scene
|
let name = "multiple-obs-lines";
|
||||||
.ucmd()
|
RandomFile::new(&at, name).add_lines(400);
|
||||||
.args(&["-3000", "-200", name])
|
|
||||||
|
ucmd.args(&["-3000", "-200", name])
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.no_stderr()
|
.no_stderr()
|
||||||
.no_stdout();
|
.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.count(), 2);
|
||||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||||
}
|
}
|
||||||
|
@ -667,18 +662,17 @@ fn test_split_multiple_obs_lines_standalone() {
|
||||||
/// last one wins
|
/// last one wins
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_multiple_obs_lines_within_combined() {
|
fn test_split_multiple_obs_lines_within_combined() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
let name = "multiple-obs-lines";
|
|
||||||
RandomFile::new(at, name).add_lines(400);
|
|
||||||
|
|
||||||
scene
|
let name = "multiple-obs-lines";
|
||||||
.ucmd()
|
RandomFile::new(&at, name).add_lines(400);
|
||||||
.args(&["-d5000x", "-e200d", name])
|
|
||||||
|
ucmd.args(&["-d5000x", "-e200d", name])
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.no_stderr()
|
.no_stderr()
|
||||||
.no_stdout();
|
.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.count(), 2);
|
||||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||||
}
|
}
|
||||||
|
@ -720,9 +714,12 @@ fn test_split_invalid_bytes_size() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_overflow_bytes_size() {
|
fn test_split_overflow_bytes_size() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
||||||
let name = "test_split_overflow_bytes_size";
|
let name = "test_split_overflow_bytes_size";
|
||||||
RandomFile::new(&at, name).add_bytes(1000);
|
RandomFile::new(&at, name).add_bytes(1000);
|
||||||
|
|
||||||
ucmd.args(&["-b", "1Y", name]).succeeds();
|
ucmd.args(&["-b", "1Y", name]).succeeds();
|
||||||
|
|
||||||
let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$");
|
let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$");
|
||||||
assert_eq!(glob.count(), 1);
|
assert_eq!(glob.count(), 1);
|
||||||
assert_eq!(glob.collate(), at.read_bytes(name));
|
assert_eq!(glob.collate(), at.read_bytes(name));
|
||||||
|
@ -731,7 +728,9 @@ fn test_split_overflow_bytes_size() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_stdin_num_chunks() {
|
fn test_split_stdin_num_chunks() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
||||||
ucmd.args(&["--number=1"]).pipe_in("").succeeds();
|
ucmd.args(&["--number=1"]).pipe_in("").succeeds();
|
||||||
|
|
||||||
assert_eq!(at.read("xaa"), "");
|
assert_eq!(at.read("xaa"), "");
|
||||||
assert!(!at.plus("xab").exists());
|
assert!(!at.plus("xab").exists());
|
||||||
}
|
}
|
||||||
|
@ -1374,10 +1373,11 @@ fn test_line_bytes_no_eof() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_guard_input() {
|
fn test_guard_input() {
|
||||||
let ts = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
let at = &ts.fixtures;
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
ts.ucmd()
|
scene
|
||||||
|
.ucmd()
|
||||||
.args(&["-C", "6"])
|
.args(&["-C", "6"])
|
||||||
.pipe_in("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n")
|
.pipe_in("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
|
@ -1385,7 +1385,8 @@ fn test_guard_input() {
|
||||||
.no_stderr();
|
.no_stderr();
|
||||||
assert_eq!(at.read("xaa"), "1\n2\n3\n");
|
assert_eq!(at.read("xaa"), "1\n2\n3\n");
|
||||||
|
|
||||||
ts.ucmd()
|
scene
|
||||||
|
.ucmd()
|
||||||
.args(&["-C", "6"])
|
.args(&["-C", "6"])
|
||||||
.pipe_in("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n")
|
.pipe_in("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
|
@ -1393,7 +1394,8 @@ fn test_guard_input() {
|
||||||
.no_stderr();
|
.no_stderr();
|
||||||
assert_eq!(at.read("xaa"), "1\n2\n3\n");
|
assert_eq!(at.read("xaa"), "1\n2\n3\n");
|
||||||
|
|
||||||
ts.ucmd()
|
scene
|
||||||
|
.ucmd()
|
||||||
.args(&["-C", "6", "xaa"])
|
.args(&["-C", "6", "xaa"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("split: 'xaa' would overwrite input; aborting\n");
|
.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
|
// spell-checker:ignore parenb parmrk ixany iuclc onlcr ofdel icanon noflsh econl igpar ispeed ospeed
|
||||||
|
|
||||||
use uutests::new_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,6 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_ucmd;
|
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,6 @@
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
@ -62,6 +60,9 @@ fn test_sync_data_but_not_file() {
|
||||||
#[cfg(feature = "chmod")]
|
#[cfg(feature = "chmod")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_sync_no_permission_dir() {
|
fn test_sync_no_permission_dir() {
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
let at = &ts.fixtures;
|
let at = &ts.fixtures;
|
||||||
let dir = "foo";
|
let dir = "foo";
|
||||||
|
@ -78,6 +79,9 @@ fn test_sync_no_permission_dir() {
|
||||||
#[cfg(feature = "chmod")]
|
#[cfg(feature = "chmod")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_sync_no_permission_file() {
|
fn test_sync_no_permission_file() {
|
||||||
|
use uutests::util::TestScenario;
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
let at = &ts.fixtures;
|
let at = &ts.fixtures;
|
||||||
let f = "file";
|
let f = "file";
|
||||||
|
|
|
@ -147,12 +147,11 @@ fn test_stdin_redirect_file_follow() {
|
||||||
// foo
|
// foo
|
||||||
//
|
//
|
||||||
|
|
||||||
let ts = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &ts.fixtures;
|
|
||||||
at.write("f", "foo");
|
at.write("f", "foo");
|
||||||
|
|
||||||
let mut p = ts
|
let mut p = ucmd
|
||||||
.ucmd()
|
|
||||||
.arg("-f")
|
.arg("-f")
|
||||||
.set_stdin(File::open(at.plus("f")).unwrap())
|
.set_stdin(File::open(at.plus("f")).unwrap())
|
||||||
.run_no_wait();
|
.run_no_wait();
|
||||||
|
@ -169,14 +168,13 @@ fn test_stdin_redirect_file_follow() {
|
||||||
fn test_stdin_redirect_offset() {
|
fn test_stdin_redirect_offset() {
|
||||||
// inspired by: "gnu/tests/tail-2/start-middle.sh"
|
// inspired by: "gnu/tests/tail-2/start-middle.sh"
|
||||||
|
|
||||||
let ts = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &ts.fixtures;
|
|
||||||
|
|
||||||
at.write("k", "1\n2\n");
|
at.write("k", "1\n2\n");
|
||||||
let mut fh = File::open(at.plus("k")).unwrap();
|
let mut fh = File::open(at.plus("k")).unwrap();
|
||||||
fh.seek(SeekFrom::Start(2)).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]
|
#[test]
|
||||||
|
@ -184,8 +182,7 @@ fn test_stdin_redirect_offset() {
|
||||||
fn test_stdin_redirect_offset2() {
|
fn test_stdin_redirect_offset2() {
|
||||||
// like test_stdin_redirect_offset but with multiple files
|
// like test_stdin_redirect_offset but with multiple files
|
||||||
|
|
||||||
let ts = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &ts.fixtures;
|
|
||||||
|
|
||||||
at.write("k", "1\n2\n");
|
at.write("k", "1\n2\n");
|
||||||
at.write("l", "3\n4\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();
|
let mut fh = File::open(at.plus("k")).unwrap();
|
||||||
fh.seek(SeekFrom::Start(2)).unwrap();
|
fh.seek(SeekFrom::Start(2)).unwrap();
|
||||||
|
|
||||||
ts.ucmd()
|
ucmd.set_stdin(fh)
|
||||||
.set_stdin(fh)
|
|
||||||
.args(&["k", "-", "l", "m"])
|
.args(&["k", "-", "l", "m"])
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only(
|
.stdout_only(
|
||||||
|
@ -260,8 +256,7 @@ fn test_permission_denied() {
|
||||||
fn test_permission_denied_multiple() {
|
fn test_permission_denied_multiple() {
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
|
||||||
let ts = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &ts.fixtures;
|
|
||||||
|
|
||||||
at.touch("file1");
|
at.touch("file1");
|
||||||
at.touch("file2");
|
at.touch("file2");
|
||||||
|
@ -270,8 +265,7 @@ fn test_permission_denied_multiple() {
|
||||||
.set_permissions(PermissionsExt::from_mode(0o000))
|
.set_permissions(PermissionsExt::from_mode(0o000))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
ts.ucmd()
|
ucmd.args(&["file1", "unreadable", "file2"])
|
||||||
.args(&["file1", "unreadable", "file2"])
|
|
||||||
.fails_with_code(1)
|
.fails_with_code(1)
|
||||||
.stderr_is("tail: cannot open 'unreadable' for reading: Permission denied\n")
|
.stderr_is("tail: cannot open 'unreadable' for reading: Permission denied\n")
|
||||||
.stdout_is("==> file1 <==\n\n==> file2 <==\n");
|
.stdout_is("==> file1 <==\n\n==> file2 <==\n");
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
// 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 uutests::util::TestScenario;
|
use uutests::{at_and_ucmd, new_ucmd};
|
||||||
use uutests::{at_and_ucmd, new_ucmd, util_name};
|
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
|
@ -161,7 +160,7 @@ fn test_tee_output_not_buffered() {
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
mod linux_only {
|
mod linux_only {
|
||||||
use uutests::util::{AtPath, CmdResult, TestScenario, UCommand};
|
use uutests::util::{AtPath, CmdResult, UCommand};
|
||||||
|
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -169,7 +168,6 @@ mod linux_only {
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_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;
|
||||||
|
|
|
@ -9,8 +9,6 @@ use rstest::rstest;
|
||||||
|
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -436,7 +436,7 @@ fn test_touch_no_dereference() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_touch_reference() {
|
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 (at, mut _ucmd) = (scenario.fixtures.clone(), scenario.ucmd());
|
||||||
let file_a = "test_touch_reference_a";
|
let file_a = "test_touch_reference_a";
|
||||||
let file_b = "test_touch_reference_b";
|
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
|
// 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::at_and_ucmd;
|
||||||
use uutests::new_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};
|
||||||
|
|
|
@ -6,8 +6,6 @@ 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::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_no_args() {
|
fn test_no_args() {
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
|
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_ucmd;
|
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,6 @@
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
|
@ -70,7 +68,9 @@ fn test_help() {
|
||||||
#[cfg(all(unix, not(target_os = "freebsd")))]
|
#[cfg(all(unix, not(target_os = "freebsd")))]
|
||||||
fn test_stdout_fail() {
|
fn test_stdout_fail() {
|
||||||
use std::process::{Command, Stdio};
|
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
|
// Sleep inside a shell to ensure the process doesn't finish before we've
|
||||||
// closed its stdout
|
// closed its stdout
|
||||||
let mut proc = Command::new("sh")
|
let mut proc = Command::new("sh")
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_ucmd;
|
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,6 @@
|
||||||
// spell-checker:ignore contenta
|
// spell-checker:ignore contenta
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
use uucore::posix::OBSOLETE;
|
use uucore::posix::OBSOLETE;
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_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";
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
@ -26,9 +24,8 @@ fn test_unlink_file() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_unlink_multiple_files() {
|
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_a = "test_unlink_multiple_file_a";
|
||||||
let file_b = "test_unlink_multiple_file_b";
|
let file_b = "test_unlink_multiple_file_b";
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
// 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)]
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "openbsd", target_os = "freebsd")))]
|
#[cfg(not(target_os = "openbsd"))]
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::util::TestScenario;
|
use uutests::util::TestScenario;
|
||||||
use uutests::{new_ucmd, util_name};
|
use uutests::{new_ucmd, util_name};
|
||||||
|
@ -20,8 +20,7 @@ fn test_invalid_arg() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uptime() {
|
fn test_uptime() {
|
||||||
TestScenario::new(util_name!())
|
new_ucmd!()
|
||||||
.ucmd()
|
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_contains("load average:")
|
.stdout_contains("load average:")
|
||||||
.stdout_contains(" up ");
|
.stdout_contains(" up ");
|
||||||
|
@ -79,9 +78,7 @@ fn test_uptime_with_fifo() {
|
||||||
fn test_uptime_with_non_existent_file() {
|
fn test_uptime_with_non_existent_file() {
|
||||||
// Disabled for freebsd, since it doesn't use the utmpxname() sys call to change the default utmpx
|
// Disabled for freebsd, since it doesn't use the utmpxname() sys call to change the default utmpx
|
||||||
// file that is accessed using getutxent()
|
// file that is accessed using getutxent()
|
||||||
let ts = TestScenario::new(util_name!());
|
new_ucmd!()
|
||||||
|
|
||||||
ts.ucmd()
|
|
||||||
.arg("file1")
|
.arg("file1")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_contains("uptime: couldn't get boot time: No such file or directory")
|
.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
|
// This test will pass for freebsd but we currently don't support changing the utmpx file for
|
||||||
// freebsd.
|
// freebsd.
|
||||||
let ts = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &ts.fixtures;
|
|
||||||
// Regex matches for "up 00::00" ,"up 12 days 00::00", the time can be any valid time and
|
// 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
|
// 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.
|
// wrong between the days and the time.
|
||||||
|
|
||||||
let re = Regex::new(r"up [(\d){1,} days]*\d{1,2}:\d\d").unwrap();
|
let re = Regex::new(r"up [(\d){1,} days]*\d{1,2}:\d\d").unwrap();
|
||||||
utmp(&at.plus("testx"));
|
utmp(&at.plus("testx"));
|
||||||
ts.ucmd()
|
|
||||||
.arg("testx")
|
ucmd.arg("testx")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_matches(&re)
|
.stdout_matches(&re)
|
||||||
.stdout_contains("load average");
|
.stdout_contains("load average");
|
||||||
|
@ -240,9 +236,7 @@ fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uptime_with_extra_argument() {
|
fn test_uptime_with_extra_argument() {
|
||||||
let ts = TestScenario::new(util_name!());
|
new_ucmd!()
|
||||||
|
|
||||||
ts.ucmd()
|
|
||||||
.arg("a")
|
.arg("a")
|
||||||
.arg("b")
|
.arg("b")
|
||||||
.fails()
|
.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
|
/// Checks whether uptime displays the correct stderr msg when its called with a directory
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uptime_with_dir() {
|
fn test_uptime_with_dir() {
|
||||||
let ts = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &ts.fixtures;
|
|
||||||
at.mkdir("dir1");
|
at.mkdir("dir1");
|
||||||
|
|
||||||
ts.ucmd()
|
ucmd.arg("dir1")
|
||||||
.arg("dir1")
|
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_contains("uptime: couldn't get boot time: Is a directory")
|
.stderr_contains("uptime: couldn't get boot time: Is a directory")
|
||||||
.stdout_contains("up ???? days ??:??");
|
.stdout_contains("up ???? days ??:??");
|
||||||
|
|
|
@ -3,11 +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.
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(unix)]
|
||||||
use uutests::at_and_ucmd;
|
use uutests::at_and_ucmd;
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::{TestScenario, vec_of_size};
|
use uutests::util::vec_of_size;
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
// spell-checker:ignore (flags) lwmcL clmwL ; (path) bogusfile emptyfile manyemptylines moby notrailingnewline onelongemptyline onelongword weirdchars
|
// spell-checker:ignore (flags) lwmcL clmwL ; (path) bogusfile emptyfile manyemptylines moby notrailingnewline onelongemptyline onelongword weirdchars
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -276,13 +275,12 @@ fn test_single_all_counts() {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_gnu_compatible_quotation() {
|
fn test_gnu_compatible_quotation() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let at = &scene.fixtures;
|
|
||||||
at.mkdir("some-dir1");
|
at.mkdir("some-dir1");
|
||||||
at.touch("some-dir1/12\n34.txt");
|
at.touch("some-dir1/12\n34.txt");
|
||||||
scene
|
|
||||||
.ucmd()
|
ucmd.args(&["some-dir1/12\n34.txt"])
|
||||||
.args(&["some-dir1/12\n34.txt"])
|
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_is("0 0 0 'some-dir1/12'$'\\n''34.txt'\n");
|
.stdout_is("0 0 0 'some-dir1/12'$'\\n''34.txt'\n");
|
||||||
}
|
}
|
||||||
|
@ -290,20 +288,18 @@ fn test_gnu_compatible_quotation() {
|
||||||
#[cfg(feature = "test_risky_names")]
|
#[cfg(feature = "test_risky_names")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_non_unicode_names() {
|
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")
|
let target1 = uucore::os_str_from_bytes(b"some-dir1/1\xC0\n.txt")
|
||||||
.expect("Only unix platforms can test non-unicode names");
|
.expect("Only unix platforms can test non-unicode names");
|
||||||
let target2 = uucore::os_str_from_bytes(b"some-dir1/2\xC0\t.txt")
|
let target2 = uucore::os_str_from_bytes(b"some-dir1/2\xC0\t.txt")
|
||||||
.expect("Only unix platforms can test non-unicode names");
|
.expect("Only unix platforms can test non-unicode names");
|
||||||
let at = &scene.fixtures;
|
|
||||||
at.mkdir("some-dir1");
|
at.mkdir("some-dir1");
|
||||||
at.touch(&target1);
|
at.touch(&target1);
|
||||||
at.touch(&target2);
|
at.touch(&target2);
|
||||||
scene
|
|
||||||
.ucmd()
|
ucmd.args(&[target1, target2]).succeeds().stdout_is_bytes(
|
||||||
.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/1'$'\\300\\n''.txt'\n".to_vec(),
|
||||||
b"0 0 0 some-dir1/2\xC0\t.txt\n".to_vec(),
|
b"0 0 0 some-dir1/2\xC0\t.txt\n".to_vec(),
|
||||||
|
|
|
@ -7,9 +7,8 @@ use uutests::new_ucmd;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use uutests::unwrap_or_return;
|
use uutests::unwrap_or_return;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use uutests::util::expected_result;
|
use uutests::util::{TestScenario, expected_result};
|
||||||
use uutests::util::{TestScenario, is_ci, whoami};
|
use uutests::util::{is_ci, whoami};
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
@ -19,11 +18,13 @@ fn test_invalid_arg() {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn test_normal() {
|
fn test_normal() {
|
||||||
|
use uutests::util_name;
|
||||||
|
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
let exp_result = unwrap_or_return!(expected_result(&ts, &[]));
|
let exp_result = unwrap_or_return!(expected_result(&ts, &[]));
|
||||||
let result = ts.ucmd().succeeds();
|
|
||||||
|
|
||||||
result
|
ts.ucmd()
|
||||||
|
.succeeds()
|
||||||
.stdout_is(exp_result.stdout_str())
|
.stdout_is(exp_result.stdout_str())
|
||||||
.stderr_is(exp_result.stderr_str());
|
.stderr_is(exp_result.stderr_str());
|
||||||
}
|
}
|
||||||
|
@ -33,6 +34,7 @@ fn test_normal() {
|
||||||
fn test_normal_compare_id() {
|
fn test_normal_compare_id() {
|
||||||
let ts = TestScenario::new("id");
|
let ts = TestScenario::new("id");
|
||||||
let id_un = unwrap_or_return!(expected_result(&ts, &["-un"]));
|
let id_un = unwrap_or_return!(expected_result(&ts, &["-un"]));
|
||||||
|
|
||||||
if id_un.succeeded() {
|
if id_un.succeeded() {
|
||||||
new_ucmd!().succeeds().stdout_is(id_un.stdout_str());
|
new_ucmd!().succeeds().stdout_is(id_un.stdout_str());
|
||||||
} else if is_ci() && id_un.stderr_str().contains("cannot find name for user ID") {
|
} 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]
|
#[test]
|
||||||
fn test_normal_compare_env() {
|
fn test_normal_compare_env() {
|
||||||
let whoami = whoami();
|
let whoami = whoami();
|
||||||
|
|
||||||
if whoami == "nobody" {
|
if whoami == "nobody" {
|
||||||
println!("test skipped:");
|
println!("test skipped:");
|
||||||
} else if !is_ci() {
|
} else if !is_ci() {
|
||||||
|
|
|
@ -9,8 +9,6 @@ use std::process::ExitStatus;
|
||||||
use std::os::unix::process::ExitStatusExt;
|
use std::os::unix::process::ExitStatusExt;
|
||||||
|
|
||||||
use uutests::new_ucmd;
|
use uutests::new_ucmd;
|
||||||
use uutests::util::TestScenario;
|
|
||||||
use uutests::util_name;
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn check_termination(result: ExitStatus) {
|
fn check_termination(result: ExitStatus) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ macro_rules! util_name {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! new_ucmd {
|
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
|
/// 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,
|
/// 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.
|
/// 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