tests: patch tests to simplify imports

This commit is contained in:
Dorian Peron
2025-07-01 03:36:46 +02:00
parent 5ce678b1cd
commit 6e23d4e979
63 changed files with 242 additions and 343 deletions
-2
View File
@@ -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() {
+3 -5
View File
@@ -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)
-1
View File
@@ -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() {
-2
View File
@@ -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() {
-2
View File
@@ -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() {
-2
View File
@@ -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() {
+4 -5
View File
@@ -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());
-2
View File
@@ -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.
-2
View File
@@ -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";
-2
View File
@@ -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() {
-2
View File
@@ -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};
-2
View File
@@ -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() {
+1 -2
View File
@@ -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());
}
-2
View File
@@ -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]
-4
View File
@@ -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() {
+1 -2
View File
@@ -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();
-2
View File
@@ -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() {
-2
View File
@@ -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
View File
@@ -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");
-2
View File
@@ -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() {

Some files were not shown because too many files have changed in this diff Show More