Skip to content

Commit 5f0077e

Browse files
authored
Merge pull request #8293 from RenjiSann/uutest-refactor
tests: Fix macros, rewrite tests to use idiomatic macros
2 parents e5b1cd3 + 6e23d4e commit 5f0077e

63 files changed

Lines changed: 238 additions & 339 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tests/by-util/test_arch.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55
use uutests::new_ucmd;
6-
use uutests::util::TestScenario;
7-
use uutests::util_name;
86

97
#[test]
108
fn test_arch() {

tests/by-util/test_base32.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
//
66

77
use uutests::new_ucmd;
8-
use uutests::util::TestScenario;
9-
use uutests::util_name;
108

119
#[test]
1210
fn test_encode() {
@@ -114,10 +112,10 @@ fn test_wrap() {
114112

115113
#[test]
116114
fn test_wrap_no_arg() {
115+
let expected_stderr = "a value is required for '--wrap <COLS>' but none was supplied";
116+
117117
for wrap_param in ["-w", "--wrap"] {
118-
let ts = TestScenario::new(util_name!());
119-
let expected_stderr = "a value is required for '--wrap <COLS>' but none was supplied";
120-
ts.ucmd()
118+
new_ucmd!()
121119
.arg(wrap_param)
122120
.fails()
123121
.stderr_contains(expected_stderr)

tests/by-util/test_base64.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// file that was distributed with this source code.
55
use uutests::new_ucmd;
66
use uutests::util::TestScenario;
7-
use uutests::util_name;
87

98
#[test]
109
fn test_encode() {

tests/by-util/test_basename.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#[cfg(any(unix, target_os = "redox"))]
88
use std::ffi::OsStr;
99
use uutests::new_ucmd;
10-
use uutests::util::TestScenario;
11-
use uutests::util_name;
1210

1311
#[test]
1412
fn test_help() {

tests/by-util/test_basenc.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
// spell-checker: ignore (encodings) lsbf msbf
77

88
use uutests::new_ucmd;
9-
use uutests::util::TestScenario;
10-
use uutests::util_name;
119

1210
#[test]
1311
fn test_z85_not_padded_decode() {

tests/by-util/test_chcon.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ use std::{io, iter, str};
1212

1313
use uutests::at_and_ucmd;
1414
use uutests::new_ucmd;
15-
use uutests::util::TestScenario;
16-
use uutests::util_name;
1715

1816
#[test]
1917
fn version() {

tests/by-util/test_chgrp.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
// spell-checker:ignore (words) nosuchgroup groupname
66

77
use uucore::process::getegid;
8-
use uutests::at_and_ucmd;
9-
use uutests::new_ucmd;
10-
use uutests::util::TestScenario;
11-
use uutests::util_name;
8+
use uutests::{at_and_ucmd, new_ucmd};
9+
#[cfg(not(target_vendor = "apple"))]
10+
use uutests::{util::TestScenario, util_name};
1211

1312
#[test]
1413
fn test_invalid_option() {
@@ -370,7 +369,7 @@ fn test_traverse_symlinks() {
370369
(&["-P"][..], false, false),
371370
(&["-L"][..], true, true),
372371
] {
373-
let scenario = TestScenario::new("chgrp");
372+
let scenario = TestScenario::new(util_name!());
374373

375374
let (at, mut ucmd) = (scenario.fixtures.clone(), scenario.ucmd());
376375

tests/by-util/test_csplit.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
use glob::glob;
66
use uutests::at_and_ucmd;
77
use uutests::new_ucmd;
8-
use uutests::util::TestScenario;
9-
use uutests::util_name;
108

119
/// Returns a string of numbers with the given range, each on a new line.
1210
/// The upper bound is not included.

tests/by-util/test_cut.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
use uutests::at_and_ucmd;
99
use uutests::new_ucmd;
10-
use uutests::util::TestScenario;
11-
use uutests::util_name;
1210

1311
static INPUT: &str = "lists.txt";
1412

tests/by-util/test_df.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ use std::collections::HashSet;
1515
#[cfg(not(any(target_os = "freebsd", target_os = "windows")))]
1616
use uutests::at_and_ucmd;
1717
use uutests::new_ucmd;
18-
use uutests::util::TestScenario;
19-
use uutests::util_name;
2018

2119
#[test]
2220
fn test_invalid_arg() {

0 commit comments

Comments
 (0)