mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
pinky: correct the test
This commit is contained in:
parent
d0b5b9a9fd
commit
34d2224098
2 changed files with 28 additions and 24 deletions
|
@ -244,7 +244,7 @@ impl Pinky {
|
||||||
|
|
||||||
if self.include_where && !ut.host().is_empty() {
|
if self.include_where && !ut.host().is_empty() {
|
||||||
let ut_host = ut.host();
|
let ut_host = ut.host();
|
||||||
let mut res = ut_host.split(':');
|
let mut res = ut_host.splitn(2, ':');
|
||||||
let host = match res.next() {
|
let host = match res.next() {
|
||||||
Some(_) => ut.canon_host().unwrap_or(ut_host.clone()),
|
Some(_) => ut.canon_host().unwrap_or(ut_host.clone()),
|
||||||
None => ut_host.clone(),
|
None => ut_host.clone(),
|
||||||
|
|
|
@ -5,6 +5,21 @@ fn new_ucmd() -> UCommand {
|
||||||
TestScenario::new(UTIL_NAME).ucmd()
|
TestScenario::new(UTIL_NAME).ucmd()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use ::std::fs::File;
|
||||||
|
use ::std::io::BufReader;
|
||||||
|
use ::std::io::BufRead;
|
||||||
|
|
||||||
|
thread_local! {
|
||||||
|
static PASSWD: Vec<String> = BufReader::new(File::open("/etc/passwd").unwrap())
|
||||||
|
.lines()
|
||||||
|
.filter_map(|l| l.ok())
|
||||||
|
.filter(|l| l.starts_with("root:"))
|
||||||
|
.map(|l| {
|
||||||
|
l.split(':').map(|s| s.to_owned()).collect::<Vec<_>>()
|
||||||
|
})
|
||||||
|
.next().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
extern crate uu_pinky;
|
extern crate uu_pinky;
|
||||||
pub use self::uu_pinky::*;
|
pub use self::uu_pinky::*;
|
||||||
|
|
||||||
|
@ -17,31 +32,20 @@ fn test_capitalize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
fn test_long_format() {
|
fn test_long_format() {
|
||||||
new_ucmd()
|
PASSWD.with(|v| {
|
||||||
.arg("-l").arg("root")
|
let gecos = v[4].replace("&", &v[4].capitalize());
|
||||||
.run()
|
new_ucmd()
|
||||||
.stdout_is("Login name: root In real life: root\nDirectory: /root Shell: /bin/bash\n\n");
|
.arg("-l").arg("root")
|
||||||
|
.run()
|
||||||
|
.stdout_is(format!("Login name: {:<28}In real life: {}\nDirectory: {:<29}Shell: {}\n", v[0], gecos, v[5], v[6]));
|
||||||
|
|
||||||
new_ucmd()
|
new_ucmd()
|
||||||
.arg("-lb").arg("root")
|
.arg("-lb")
|
||||||
.run()
|
.arg("root")
|
||||||
.stdout_is("Login name: root In real life: root\n\n");
|
.run()
|
||||||
}
|
.stdout_is(format!("Login name: {:<28}In real life: {1}\n\n", v[0], gecos));
|
||||||
|
})
|
||||||
#[test]
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
fn test_long_format() {
|
|
||||||
new_ucmd()
|
|
||||||
.arg("-l").arg("root")
|
|
||||||
.run()
|
|
||||||
.stdout_is("Login name: root In real life: System Administrator\nDirectory: /var/root Shell: /bin/sh\n\n");
|
|
||||||
|
|
||||||
new_ucmd()
|
|
||||||
.arg("-lb").arg("root")
|
|
||||||
.run()
|
|
||||||
.stdout_is("Login name: root In real life: System Administrator\n\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue