1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-15 19:36:16 +00:00

Merge branch 'main' into rm-correct-prompts

This commit is contained in:
Pat Laster 2022-10-27 13:38:41 -05:00 committed by GitHub
commit c4417bf9b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 145 additions and 32 deletions

View file

@ -423,6 +423,38 @@ fn test_chown_only_user_id() {
.stderr_contains("failed to change");
}
#[test]
fn test_chown_fail_id() {
// test chown 1111. file.txt
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let result = scene.cmd_keepenv("id").arg("-u").run();
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
return;
}
let user_id = String::from(result.stdout_str().trim());
assert!(!user_id.is_empty());
let file1 = "test_chown_file1";
at.touch(file1);
scene
.ucmd()
.arg(format!("{}:", user_id))
.arg(file1)
.fails()
.stderr_contains("invalid spec");
scene
.ucmd()
.arg(format!("{}.", user_id))
.arg(file1)
.fails()
.stderr_contains("invalid spec");
}
/// Test for setting the owner to a user ID for a user that does not exist.
///
/// For example:

View file

@ -530,7 +530,7 @@ fn test_round() {
new_ucmd!()
.args(&[
"--to=si",
&format!("--round={}", method),
&format!("--round={method}"),
"--",
"9001",
"-9001",
@ -542,6 +542,32 @@ fn test_round() {
}
}
#[test]
fn test_round_with_to_unit() {
for (method, exp) in [
("from-zero", ["6", "-6", "5.9", "-5.9", "5.86", "-5.86"]),
("towards-zero", ["5", "-5", "5.8", "-5.8", "5.85", "-5.85"]),
("up", ["6", "-5", "5.9", "-5.8", "5.86", "-5.85"]),
("down", ["5", "-6", "5.8", "-5.9", "5.85", "-5.86"]),
("nearest", ["6", "-6", "5.9", "-5.9", "5.86", "-5.86"]),
] {
new_ucmd!()
.args(&[
"--to-unit=1024",
&format!("--round={method}"),
"--",
"6000",
"-6000",
"6000.0",
"-6000.0",
"6000.00",
"-6000.00",
])
.succeeds()
.stdout_only(exp.join("\n") + "\n");
}
}
#[test]
fn test_suffix_is_added_if_not_supplied() {
new_ucmd!()

View file

@ -90,6 +90,35 @@ fn test_symlinked_default() {
env.ucmd.succeeds().stdout_is(env.subdir + "\n");
}
#[test]
fn test_symlinked_default_posix() {
let mut env = symlinked_env();
env.ucmd
.env("POSIXLY_CORRECT", "1")
.succeeds()
.stdout_is(env.symdir.clone() + "\n");
}
#[test]
fn test_symlinked_default_posix_l() {
let mut env = symlinked_env();
env.ucmd
.env("POSIXLY_CORRECT", "1")
.arg("-L")
.succeeds()
.stdout_is(env.symdir + "\n");
}
#[test]
fn test_symlinked_default_posix_p() {
let mut env = symlinked_env();
env.ucmd
.env("POSIXLY_CORRECT", "1")
.arg("-P")
.succeeds()
.stdout_is(env.symdir + "\n");
}
#[cfg(not(windows))]
pub mod untrustworthy_pwd_var {
use std::path::Path;