logname: add help and output format tests (#11118)

* logname: add help and output format tests
This commit is contained in:
Nihal Ajayakumar
2026-02-26 12:32:34 -05:00
committed by GitHub
parent d437fe4ce9
commit ccd5e3d8f3
+25
View File
@@ -2,6 +2,7 @@
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use regex::Regex;
use std::env;
use uutests::new_ucmd;
use uutests::util::is_ci;
@@ -29,3 +30,27 @@ fn test_normal() {
result.success();
assert!(!result.stdout_str().trim().is_empty());
}
#[test]
fn test_help() {
new_ucmd!()
.arg("--help")
.succeeds()
.stdout_contains("Print user's login name");
}
#[test]
fn test_output_format() {
let result = new_ucmd!().run();
if (is_ci() || uucore::os::is_wsl()) && result.stderr_str().contains("no login name") {
return;
}
result.success();
assert!(
Regex::new(r"^\w+\n$")
.unwrap()
.is_match(result.stdout_str()),
"unexpected logname output: {:?}",
result.stdout_str()
);
}