1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

rustfmt the recent change

This commit is contained in:
Sylvestre Ledru 2021-04-17 11:22:49 +02:00 committed by Sylvestre Ledru
parent d0c7e8c09e
commit c5b43c0994
10 changed files with 43 additions and 32 deletions

View file

@ -144,7 +144,9 @@ fn check_option(matches: &ArgMatches, name: &str) -> Result<BufferType, ProgramO
Some(value) => match value { Some(value) => match value {
"L" => { "L" => {
if name == options::INPUT { if name == options::INPUT {
Err(ProgramOptionsError("line buffering stdin is meaningless".to_string())) Err(ProgramOptionsError(
"line buffering stdin is meaningless".to_string(),
))
} else { } else {
Ok(BufferType::Line) Ok(BufferType::Line)
} }

View file

@ -150,7 +150,7 @@ fn next_tabstop(tabstops: &[usize], col: usize) -> Option<usize> {
} else { } else {
// find next larger tab // find next larger tab
// if there isn't one in the list, tab becomes a single space // if there isn't one in the list, tab becomes a single space
tabstops.iter().find(|&&t| t > col).map(|t| t-col) tabstops.iter().find(|&&t| t > col).map(|t| t - col)
} }
} }

View file

@ -357,7 +357,8 @@ fn test_chmod_symlink_non_existing_file() {
at.symlink_file(non_existing, test_symlink); at.symlink_file(non_existing, test_symlink);
// this cannot succeed since the symbolic link dangles // this cannot succeed since the symbolic link dangles
scene.ucmd() scene
.ucmd()
.arg("755") .arg("755")
.arg("-v") .arg("-v")
.arg(test_symlink) .arg(test_symlink)
@ -367,7 +368,8 @@ fn test_chmod_symlink_non_existing_file() {
.stderr_contains(expected_stderr); .stderr_contains(expected_stderr);
// this should be the same than with just '-v' but without stderr // this should be the same than with just '-v' but without stderr
scene.ucmd() scene
.ucmd()
.arg("755") .arg("755")
.arg("-v") .arg("-v")
.arg("-f") .arg("-f")
@ -394,7 +396,8 @@ fn test_chmod_symlink_non_existing_file_recursive() {
); );
// this should succeed // this should succeed
scene.ucmd() scene
.ucmd()
.arg("-R") .arg("-R")
.arg("755") .arg("755")
.arg(test_directory) .arg(test_directory)
@ -408,7 +411,8 @@ fn test_chmod_symlink_non_existing_file_recursive() {
); );
// '-v': this should succeed without stderr // '-v': this should succeed without stderr
scene.ucmd() scene
.ucmd()
.arg("-R") .arg("-R")
.arg("-v") .arg("-v")
.arg("755") .arg("755")
@ -418,7 +422,8 @@ fn test_chmod_symlink_non_existing_file_recursive() {
.no_stderr(); .no_stderr();
// '-vf': this should be the same than with just '-v' // '-vf': this should be the same than with just '-v'
scene.ucmd() scene
.ucmd()
.arg("-R") .arg("-R")
.arg("-v") .arg("-v")
.arg("-f") .arg("-f")

View file

@ -7,9 +7,7 @@ const SUB_LINK: &str = "subdir/links/sublink.txt";
#[test] #[test]
fn test_du_basics() { fn test_du_basics() {
new_ucmd!() new_ucmd!().succeeds().no_stderr();
.succeeds()
.no_stderr();
} }
#[cfg(target_vendor = "apple")] #[cfg(target_vendor = "apple")]
fn _du_basics(s: String) { fn _du_basics(s: String) {
@ -178,7 +176,14 @@ fn test_du_h_flag_empty_file() {
fn test_du_time() { fn test_du_time() {
let ts = TestScenario::new("du"); let ts = TestScenario::new("du");
let touch = ts.ccmd("touch").arg("-a").arg("-m").arg("-t").arg("201505150000").arg("date_test").run(); let touch = ts
.ccmd("touch")
.arg("-a")
.arg("-m")
.arg("-t")
.arg("201505150000")
.arg("date_test")
.run();
assert!(touch.success); assert!(touch.success);
let result = ts.ucmd().arg("--time").arg("date_test").run(); let result = ts.ucmd().arg("--time").arg("date_test").run();

View file

@ -2,10 +2,7 @@ use crate::common::util::*;
#[test] #[test]
fn test_default() { fn test_default() {
new_ucmd!() new_ucmd!().arg("hi").succeeds().stdout_only("hi\n");
.arg("hi")
.succeeds()
.stdout_only("hi\n");
} }
#[test] #[test]

View file

@ -26,17 +26,18 @@ fn test_env_version() {
#[test] #[test]
fn test_echo() { fn test_echo() {
let result = new_ucmd!() let result = new_ucmd!().arg("echo").arg("FOO-bar").succeeds();
.arg("echo")
.arg("FOO-bar")
.succeeds();
assert_eq!(result.stdout_str().trim(), "FOO-bar"); assert_eq!(result.stdout_str().trim(), "FOO-bar");
} }
#[test] #[test]
fn test_file_option() { fn test_file_option() {
let out = new_ucmd!().arg("-f").arg("vars.conf.txt").run().stdout_move_str(); let out = new_ucmd!()
.arg("-f")
.arg("vars.conf.txt")
.run()
.stdout_move_str();
assert_eq!( assert_eq!(
out.lines() out.lines()
@ -89,7 +90,8 @@ fn test_multiple_name_value_pairs() {
let out = new_ucmd!().arg("FOO=bar").arg("ABC=xyz").run(); let out = new_ucmd!().arg("FOO=bar").arg("ABC=xyz").run();
assert_eq!( assert_eq!(
out.stdout_str().lines() out.stdout_str()
.lines()
.filter(|&line| line == "FOO=bar" || line == "ABC=xyz") .filter(|&line| line == "FOO=bar" || line == "ABC=xyz")
.count(), .count(),
2 2

View file

@ -25,6 +25,8 @@ fn test_hostname_full() {
let ls_short_res = new_ucmd!().arg("-s").succeeds(); let ls_short_res = new_ucmd!().arg("-s").succeeds();
assert!(!ls_short_res.stdout_str().trim().is_empty()); assert!(!ls_short_res.stdout_str().trim().is_empty());
new_ucmd!().arg("-f").succeeds() new_ucmd!()
.arg("-f")
.succeeds()
.stdout_contains(ls_short_res.stdout_str().trim()); .stdout_contains(ls_short_res.stdout_str().trim());
} }

View file

@ -46,7 +46,8 @@ fn test_id_from_name() {
let result = new_ucmd!().arg(&username).succeeds(); let result = new_ucmd!().arg(&username).succeeds();
let uid = result.stdout_str().trim(); let uid = result.stdout_str().trim();
new_ucmd!().succeeds() new_ucmd!()
.succeeds()
// Verify that the id found by --user/-u exists in the list // Verify that the id found by --user/-u exists in the list
.stdout_contains(uid) .stdout_contains(uid)
// Verify that the username found by whoami exists in the list // Verify that the username found by whoami exists in the list
@ -65,10 +66,7 @@ fn test_id_name_from_id() {
return; return;
} }
let username_id = result let username_id = result.success().stdout_str().trim();
.success()
.stdout_str()
.trim();
let scene = TestScenario::new("whoami"); let scene = TestScenario::new("whoami");
let result = scene.cmd("whoami").succeeds(); let result = scene.cmd("whoami").succeeds();