mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27: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
|
@ -6,7 +6,7 @@
|
|||
// spell-checker:ignore bincode serde utmp runlevel testusr testx
|
||||
#![allow(clippy::cast_possible_wrap, clippy::unreadable_literal)]
|
||||
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "freebsd")))]
|
||||
#[cfg(not(target_os = "openbsd"))]
|
||||
use uutests::at_and_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::{new_ucmd, util_name};
|
||||
|
@ -20,8 +20,7 @@ fn test_invalid_arg() {
|
|||
|
||||
#[test]
|
||||
fn test_uptime() {
|
||||
TestScenario::new(util_name!())
|
||||
.ucmd()
|
||||
new_ucmd!()
|
||||
.succeeds()
|
||||
.stdout_contains("load average:")
|
||||
.stdout_contains(" up ");
|
||||
|
@ -79,9 +78,7 @@ fn test_uptime_with_fifo() {
|
|||
fn test_uptime_with_non_existent_file() {
|
||||
// Disabled for freebsd, since it doesn't use the utmpxname() sys call to change the default utmpx
|
||||
// file that is accessed using getutxent()
|
||||
let ts = TestScenario::new(util_name!());
|
||||
|
||||
ts.ucmd()
|
||||
new_ucmd!()
|
||||
.arg("file1")
|
||||
.fails()
|
||||
.stderr_contains("uptime: couldn't get boot time: No such file or directory")
|
||||
|
@ -107,16 +104,15 @@ fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() {
|
|||
|
||||
// This test will pass for freebsd but we currently don't support changing the utmpx file for
|
||||
// freebsd.
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
// Regex matches for "up 00::00" ,"up 12 days 00::00", the time can be any valid time and
|
||||
// the days can be more than 1 digit or not there. This will match even if the amount of whitespace is
|
||||
// wrong between the days and the time.
|
||||
|
||||
let re = Regex::new(r"up [(\d){1,} days]*\d{1,2}:\d\d").unwrap();
|
||||
utmp(&at.plus("testx"));
|
||||
ts.ucmd()
|
||||
.arg("testx")
|
||||
|
||||
ucmd.arg("testx")
|
||||
.succeeds()
|
||||
.stdout_matches(&re)
|
||||
.stdout_contains("load average");
|
||||
|
@ -240,9 +236,7 @@ fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() {
|
|||
|
||||
#[test]
|
||||
fn test_uptime_with_extra_argument() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
|
||||
ts.ucmd()
|
||||
new_ucmd!()
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.fails()
|
||||
|
@ -251,12 +245,11 @@ fn test_uptime_with_extra_argument() {
|
|||
/// Checks whether uptime displays the correct stderr msg when its called with a directory
|
||||
#[test]
|
||||
fn test_uptime_with_dir() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.mkdir("dir1");
|
||||
|
||||
ts.ucmd()
|
||||
.arg("dir1")
|
||||
ucmd.arg("dir1")
|
||||
.fails()
|
||||
.stderr_contains("uptime: couldn't get boot time: Is a directory")
|
||||
.stdout_contains("up ???? days ??:??");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue