Skip to content

Commit ccd5e3d

Browse files
authored
logname: add help and output format tests (#11118)
* logname: add help and output format tests
1 parent d437fe4 commit ccd5e3d

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/by-util/test_logname.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
5+
use regex::Regex;
56
use std::env;
67
use uutests::new_ucmd;
78
use uutests::util::is_ci;
@@ -29,3 +30,27 @@ fn test_normal() {
2930
result.success();
3031
assert!(!result.stdout_str().trim().is_empty());
3132
}
33+
34+
#[test]
35+
fn test_help() {
36+
new_ucmd!()
37+
.arg("--help")
38+
.succeeds()
39+
.stdout_contains("Print user's login name");
40+
}
41+
42+
#[test]
43+
fn test_output_format() {
44+
let result = new_ucmd!().run();
45+
if (is_ci() || uucore::os::is_wsl()) && result.stderr_str().contains("no login name") {
46+
return;
47+
}
48+
result.success();
49+
assert!(
50+
Regex::new(r"^\w+\n$")
51+
.unwrap()
52+
.is_match(result.stdout_str()),
53+
"unexpected logname output: {:?}",
54+
result.stdout_str()
55+
);
56+
}

0 commit comments

Comments
 (0)