mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
Merge branch 'main' into refactor/add_nix_error_auto_conversion
This commit is contained in:
commit
f117f36313
8 changed files with 62 additions and 16 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -367,6 +367,7 @@ dependencies = [
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"procfs",
|
"procfs",
|
||||||
"rand",
|
"rand",
|
||||||
|
"rand_pcg",
|
||||||
"regex",
|
"regex",
|
||||||
"rlimit",
|
"rlimit",
|
||||||
"selinux",
|
"selinux",
|
||||||
|
@ -862,14 +863,14 @@ checksum = "31a7a908b8f32538a2143e59a6e4e2508988832d5d4d6f7c156b3cbc762643a5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "filetime"
|
name = "filetime"
|
||||||
version = "0.2.17"
|
version = "0.2.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e94a7bbaa59354bc20dd75b67f23e2797b4490e9d6928203fb105c79e448c86c"
|
checksum = "4b9663d381d07ae25dc88dbdf27df458faa83a9b25336bcac83d5e452b5fc9d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
"redox_syscall",
|
||||||
"windows-sys 0.36.1",
|
"windows-sys 0.42.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1664,6 +1665,15 @@ dependencies = [
|
||||||
"getrandom",
|
"getrandom",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_pcg"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "59cad018caf63deb318e5a4586d99a24424a364f40f1e5778c29aca23f4fc73e"
|
||||||
|
dependencies = [
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rayon"
|
name = "rayon"
|
||||||
version = "1.5.3"
|
version = "1.5.3"
|
||||||
|
|
|
@ -408,6 +408,7 @@ rlimit = "0.8.3"
|
||||||
[target.'cfg(unix)'.dev-dependencies]
|
[target.'cfg(unix)'.dev-dependencies]
|
||||||
nix = { version = "0.25", default-features = false, features = ["process", "signal", "user"] }
|
nix = { version = "0.25", default-features = false, features = ["process", "signal", "user"] }
|
||||||
rust-users = { version="0.11", package="users" }
|
rust-users = { version="0.11", package="users" }
|
||||||
|
rand_pcg = "0.3"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
phf_codegen = "0.11.1"
|
phf_codegen = "0.11.1"
|
||||||
|
|
|
@ -276,11 +276,10 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
|
||||||
};
|
};
|
||||||
let check = matches.get_flag("check");
|
let check = matches.get_flag("check");
|
||||||
let tag = matches.get_flag("tag");
|
let tag = matches.get_flag("tag");
|
||||||
let nonames = if binary_name == "b3sum" {
|
let nonames = *matches
|
||||||
matches.get_flag("no-names")
|
.try_get_one("no-names")
|
||||||
} else {
|
.unwrap_or(Some(&false))
|
||||||
false
|
.unwrap();
|
||||||
};
|
|
||||||
let status = matches.get_flag("status");
|
let status = matches.get_flag("status");
|
||||||
let quiet = matches.get_flag("quiet") || status;
|
let quiet = matches.get_flag("quiet") || status;
|
||||||
let strict = matches.get_flag("strict");
|
let strict = matches.get_flag("strict");
|
||||||
|
|
|
@ -15,7 +15,7 @@ edition = "2021"
|
||||||
path = "src/touch.rs"
|
path = "src/touch.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
filetime = "0.2.17"
|
filetime = "0.2.18"
|
||||||
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
|
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
|
||||||
time = { version = "0.3", features = ["parsing", "formatting", "local-offset", "macros"] }
|
time = { version = "0.3", features = ["parsing", "formatting", "local-offset", "macros"] }
|
||||||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["libc"] }
|
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["libc"] }
|
||||||
|
|
|
@ -402,12 +402,26 @@ pub fn canonicalize<P: AsRef<Path>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
#[allow(unused_variables)]
|
|
||||||
pub fn display_permissions(metadata: &fs::Metadata, display_file_type: bool) -> String {
|
pub fn display_permissions(metadata: &fs::Metadata, display_file_type: bool) -> String {
|
||||||
|
let write = if metadata.permissions().readonly() {
|
||||||
|
'-'
|
||||||
|
} else {
|
||||||
|
'w'
|
||||||
|
};
|
||||||
|
|
||||||
if display_file_type {
|
if display_file_type {
|
||||||
return String::from("----------");
|
let file_type = if metadata.is_symlink() {
|
||||||
|
'l'
|
||||||
|
} else if metadata.is_dir() {
|
||||||
|
'd'
|
||||||
|
} else {
|
||||||
|
'-'
|
||||||
|
};
|
||||||
|
|
||||||
|
format!("{0}r{1}xr{1}xr{1}x", file_type, write)
|
||||||
|
} else {
|
||||||
|
format!("r{0}xr{0}xr{0}x", write)
|
||||||
}
|
}
|
||||||
String::from("---------")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
|
|
@ -34,7 +34,7 @@ macro_rules! test_digest {
|
||||||
fn test_nonames() {
|
fn test_nonames() {
|
||||||
let ts = TestScenario::new("hashsum");
|
let ts = TestScenario::new("hashsum");
|
||||||
// EXPECTED_FILE has no newline character at the end
|
// EXPECTED_FILE has no newline character at the end
|
||||||
if DIGEST_ARG == "b3sum" {
|
if DIGEST_ARG == "--b3sum" {
|
||||||
// Option only available on b3sum
|
// Option only available on b3sum
|
||||||
assert_eq!(format!("{0}\n{0}\n", ts.fixtures.read(EXPECTED_FILE)),
|
assert_eq!(format!("{0}\n{0}\n", ts.fixtures.read(EXPECTED_FILE)),
|
||||||
ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).arg("--no-names").arg("input.txt").arg("-").pipe_in_fixture("input.txt")
|
ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).arg("--no-names").arg("input.txt").arg("-").pipe_in_fixture("input.txt")
|
||||||
|
|
|
@ -966,7 +966,7 @@ fn test_ls_long() {
|
||||||
result.stdout_matches(&Regex::new(r"[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}.*").unwrap());
|
result.stdout_matches(&Regex::new(r"[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}.*").unwrap());
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
result.stdout_contains("---------- 1 somebody somegroup");
|
result.stdout_matches(&Regex::new(r"[-dl](r[w-]x){3}.*").unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1117,14 +1117,36 @@ fn test_tmp_files_deleted_on_sigint() {
|
||||||
|
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
at.mkdir("tmp_dir");
|
at.mkdir("tmp_dir");
|
||||||
|
let file_name = "big_file_to_sort.txt";
|
||||||
|
{
|
||||||
|
use rand::{Rng, SeedableRng};
|
||||||
|
use std::io::Write;
|
||||||
|
let mut file = at.make_file(file_name);
|
||||||
|
// approximately 20 MB
|
||||||
|
for _ in 0..40 {
|
||||||
|
let lines = rand_pcg::Pcg32::seed_from_u64(123)
|
||||||
|
.sample_iter(rand::distributions::uniform::Uniform::new(0, 10000))
|
||||||
|
.take(100000)
|
||||||
|
.map(|x| x.to_string() + "\n")
|
||||||
|
.collect::<String>();
|
||||||
|
file.write_all(lines.as_bytes()).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
ucmd.args(&[
|
ucmd.args(&[
|
||||||
"ext_sort.txt",
|
file_name,
|
||||||
"--buffer-size=1", // with a small buffer size `sort` will be forced to create a temporary directory very soon.
|
"--buffer-size=1", // with a small buffer size `sort` will be forced to create a temporary directory very soon.
|
||||||
"--temporary-directory=tmp_dir",
|
"--temporary-directory=tmp_dir",
|
||||||
]);
|
]);
|
||||||
let mut child = ucmd.run_no_wait();
|
let mut child = ucmd.run_no_wait();
|
||||||
// wait a short amount of time so that `sort` can create a temporary directory.
|
// wait a short amount of time so that `sort` can create a temporary directory.
|
||||||
std::thread::sleep(Duration::from_millis(100));
|
let mut timeout = Duration::from_millis(100);
|
||||||
|
for _ in 0..5 {
|
||||||
|
std::thread::sleep(timeout);
|
||||||
|
if read_dir(at.plus("tmp_dir")).unwrap().next().is_some() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
timeout *= 2;
|
||||||
|
}
|
||||||
// `sort` should have created a temporary directory.
|
// `sort` should have created a temporary directory.
|
||||||
assert!(read_dir(at.plus("tmp_dir")).unwrap().next().is_some());
|
assert!(read_dir(at.plus("tmp_dir")).unwrap().next().is_some());
|
||||||
// kill sort with SIGINT
|
// kill sort with SIGINT
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue