mirror of
https://github.com/uutils/coreutils
synced 2024-07-21 09:54:42 +00:00
who: add tests
This commit is contained in:
parent
8c6cd72848
commit
7637115e51
3
Makefile
3
Makefile
|
@ -196,7 +196,8 @@ TEST_PROGS := \
|
|||
unexpand \
|
||||
uniq \
|
||||
unlink \
|
||||
wc
|
||||
wc \
|
||||
who
|
||||
|
||||
TESTS := \
|
||||
$(sort $(filter $(UTILS),$(filter-out $(SKIP_UTILS),$(TEST_PROGS))))
|
||||
|
|
88
tests/test_who.rs
Normal file
88
tests/test_who.rs
Normal file
|
@ -0,0 +1,88 @@
|
|||
use common::util::*;
|
||||
|
||||
static UTIL_NAME: &'static str = "who";
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn test_count() {
|
||||
for opt in ["-q", "--count"].into_iter() {
|
||||
let scene = TestScenario::new(UTIL_NAME);
|
||||
let args = [*opt];
|
||||
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn test_boot() {
|
||||
for opt in ["-b", "--boot"].into_iter() {
|
||||
let scene = TestScenario::new(UTIL_NAME);
|
||||
let args = [*opt];
|
||||
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn test_heading() {
|
||||
for opt in ["-H"].into_iter() {
|
||||
let scene = TestScenario::new(UTIL_NAME);
|
||||
let args = [*opt];
|
||||
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn test_short() {
|
||||
for opt in ["-s", "--short"].into_iter() {
|
||||
let scene = TestScenario::new(UTIL_NAME);
|
||||
let args = [*opt];
|
||||
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn test_login() {
|
||||
for opt in ["-l", "--login"].into_iter() {
|
||||
let scene = TestScenario::new(UTIL_NAME);
|
||||
let args = [*opt];
|
||||
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn test_m() {
|
||||
for opt in ["-m"].into_iter() {
|
||||
let scene = TestScenario::new(UTIL_NAME);
|
||||
let args = [*opt];
|
||||
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn test_dead() {
|
||||
for opt in ["-d", "--dead"].into_iter() {
|
||||
let scene = TestScenario::new(UTIL_NAME);
|
||||
let args = [*opt];
|
||||
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn test_all() {
|
||||
for opt in ["-a", "--all"].into_iter() {
|
||||
let scene = TestScenario::new(UTIL_NAME);
|
||||
let args = [*opt];
|
||||
scene.ucmd().args(&args).run().stdout_is(expected_result(&args));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn expected_result(args: &[&str]) -> String {
|
||||
TestScenario::new(UTIL_NAME).cmd_keepenv(UTIL_NAME).args(args).run().stdout
|
||||
}
|
|
@ -21,6 +21,7 @@ unix_only! {
|
|||
"stdbuf", test_stdbuf;
|
||||
"touch", test_touch;
|
||||
"unlink", test_unlink;
|
||||
"who", test_who;
|
||||
// Be aware of the trailing semicolon after the last item
|
||||
"stat", test_stat
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue