mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
pinky: fix tests on MacOS
This commit is contained in:
parent
daba29b832
commit
f5d08336fb
1 changed files with 17 additions and 27 deletions
|
@ -1,20 +1,8 @@
|
||||||
|
extern crate uucore;
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
|
use self::uucore::entries::{Locate, Passwd};
|
||||||
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::*;
|
||||||
|
@ -29,19 +17,21 @@ fn test_capitalize() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_long_format() {
|
fn test_long_format() {
|
||||||
PASSWD.with(|v| {
|
let ulogin = "root";
|
||||||
let gecos = v[4].replace("&", &v[4].capitalize());
|
let pw: Passwd = Passwd::locate(ulogin).unwrap();
|
||||||
new_ucmd!()
|
let real_name = pw.user_info().replace("&", &pw.name().capitalize());
|
||||||
.arg("-l").arg("root")
|
new_ucmd!()
|
||||||
.run()
|
.arg("-l").arg(ulogin)
|
||||||
.stdout_is(format!("Login name: {:<28}In real life: {}\nDirectory: {:<29}Shell: {}\n", v[0], gecos, v[5], v[6]));
|
.run()
|
||||||
|
.stdout_is(format!("Login name: {:<28}In real life: {}\nDirectory: {:<29}Shell: {}\n",
|
||||||
|
ulogin, real_name, pw.user_dir(), pw.user_shell()));
|
||||||
|
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("-lb")
|
.arg("-lb")
|
||||||
.arg("root")
|
.arg(ulogin)
|
||||||
.run()
|
.run()
|
||||||
.stdout_is(format!("Login name: {:<28}In real life: {1}\n\n", v[0], gecos));
|
.stdout_is(format!("Login name: {:<28}In real life: {1}\n\n",
|
||||||
})
|
ulogin, real_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue