mirror of
https://github.com/uutils/coreutils
synced 2024-12-15 15:52:42 +00:00
1c230fd779
Summary of changes in UCommand: * Extend UCommand by builder methods and simplify methods in TestScenario * Simplify code structures where possible. Add documentation. * Store bin_path as PathBuf and util_name as String in all structs * Remove UCommand::util and make bin_path, temp_dir private * Rename UCommand::with_limit -> UCommand::limit Summary of changes in TestScenario: * Rename some parameters in TestScenario methods to be more descriptive * Remove ucmd_keepenv, cmd_keepenv from TestScenario. Use UCommand::keep_env instead.
32 lines
675 B
Rust
32 lines
675 B
Rust
extern crate regex;
|
|
use self::regex::Regex;
|
|
use crate::common::util::*;
|
|
|
|
#[test]
|
|
fn test_invalid_arg() {
|
|
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
|
}
|
|
|
|
#[test]
|
|
fn test_uptime() {
|
|
TestScenario::new(util_name!())
|
|
.ucmd()
|
|
.keep_env()
|
|
.succeeds()
|
|
.stdout_contains("load average:")
|
|
.stdout_contains(" up ");
|
|
|
|
// Don't check for users as it doesn't show in some CI
|
|
}
|
|
|
|
#[test]
|
|
fn test_uptime_since() {
|
|
let re = Regex::new(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}").unwrap();
|
|
|
|
new_ucmd!().arg("--since").succeeds().stdout_matches(&re);
|
|
}
|
|
|
|
#[test]
|
|
fn test_failed() {
|
|
new_ucmd!().arg("will-fail").fails();
|
|
}
|