mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
sha512sum: introduce standalone binary
This commit is contained in:
Generated
+13
@@ -631,6 +631,7 @@ dependencies = [
|
||||
"uu_sha224sum",
|
||||
"uu_sha256sum",
|
||||
"uu_sha384sum",
|
||||
"uu_sha512sum",
|
||||
"uu_shred",
|
||||
"uu_shuf",
|
||||
"uu_sleep",
|
||||
@@ -4036,6 +4037,18 @@ dependencies = [
|
||||
"uucore",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uu_sha512sum"
|
||||
version = "0.6.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"codspeed-divan-compat",
|
||||
"fluent",
|
||||
"tempfile",
|
||||
"uu_checksum_common",
|
||||
"uucore",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uu_shred"
|
||||
version = "0.6.0"
|
||||
|
||||
@@ -92,6 +92,7 @@ feat_common_core = [
|
||||
"sha224sum",
|
||||
"sha256sum",
|
||||
"sha384sum",
|
||||
"sha512sum",
|
||||
"comm",
|
||||
"cp",
|
||||
"csplit",
|
||||
@@ -449,6 +450,7 @@ sha1sum = { optional = true, version = "0.6.0", package = "uu_sha1sum", path = "
|
||||
sha224sum = { optional = true, version = "0.6.0", package = "uu_sha224sum", path = "src/uu/sha224sum" }
|
||||
sha256sum = { optional = true, version = "0.6.0", package = "uu_sha256sum", path = "src/uu/sha256sum" }
|
||||
sha384sum = { optional = true, version = "0.6.0", package = "uu_sha384sum", path = "src/uu/sha384sum" }
|
||||
sha512sum = { optional = true, version = "0.6.0", package = "uu_sha512sum", path = "src/uu/sha512sum" }
|
||||
comm = { optional = true, version = "0.6.0", package = "uu_comm", path = "src/uu/comm" }
|
||||
cp = { optional = true, version = "0.6.0", package = "uu_cp", path = "src/uu/cp" }
|
||||
csplit = { optional = true, version = "0.6.0", package = "uu_csplit", path = "src/uu/csplit" }
|
||||
|
||||
@@ -95,9 +95,6 @@ SELINUX_PROGS := \
|
||||
chcon \
|
||||
runcon
|
||||
|
||||
HASHSUM_PROGS := \
|
||||
sha512sum
|
||||
|
||||
$(info Detected OS = $(OS))
|
||||
|
||||
ifeq (,$(findstring MINGW,$(OS)))
|
||||
|
||||
@@ -89,9 +89,6 @@ pub fn main() {
|
||||
}
|
||||
"hashsum" => {
|
||||
phf_map.entry(krate, format!("({krate}::uumain, {krate}::uu_app_custom)"));
|
||||
|
||||
let map_value = format!("({krate}::uumain, {krate}::uu_app_common)");
|
||||
phf_map.entry("sha512sum", map_value.clone());
|
||||
}
|
||||
_ => {
|
||||
phf_map.entry(krate, map_value.clone());
|
||||
|
||||
@@ -50,9 +50,6 @@ fn get_canonical_util_name(util_name: &str) -> &str {
|
||||
// uu_test aliases - '[' is an alias for test
|
||||
"[" => "test",
|
||||
|
||||
// hashsum aliases - all these hash commands are aliases for hashsum
|
||||
"sha512sum" => "hashsum",
|
||||
|
||||
"dir" => "ls", // dir is an alias for ls
|
||||
|
||||
// Default case - return the util name as is
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
[package]
|
||||
name = "uu_sha512sum"
|
||||
description = "sha512sum ~ (uutils) Print or check the SHA512 checksums"
|
||||
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/sha512sum"
|
||||
version.workspace = true
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
homepage.workspace = true
|
||||
keywords.workspace = true
|
||||
categories.workspace = true
|
||||
edition.workspace = true
|
||||
readme.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
path = "src/sha512sum.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { workspace = true }
|
||||
uu_checksum_common = { workspace = true }
|
||||
uucore = { workspace = true, features = [
|
||||
"checksum",
|
||||
"encoding",
|
||||
"sum",
|
||||
"hardware",
|
||||
] }
|
||||
fluent = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
divan = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
uucore = { workspace = true, features = ["benchmark"] }
|
||||
|
||||
[[bin]]
|
||||
name = "sha512sum"
|
||||
path = "src/main.rs"
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../LICENSE
|
||||
@@ -0,0 +1,2 @@
|
||||
sha512sum-about = Print or check the SHA512 checksums
|
||||
sha512sum-usage = sha512sum [OPTIONS] [FILE]...
|
||||
@@ -0,0 +1,2 @@
|
||||
sha512sum-about = Afficher le SHA512 et la taille de chaque fichier
|
||||
sha512sum-usage = sha512sum [OPTION]... [FICHIER]...
|
||||
@@ -0,0 +1 @@
|
||||
uucore::bin!(uu_sha512sum);
|
||||
@@ -0,0 +1 @@
|
||||
uu_checksum_common::declare_standalone!("sha512sum", uucore::checksum::AlgoKind::Sha512);
|
||||
@@ -172,9 +172,6 @@ pub fn get_canonical_util_name(util_name: &str) -> &str {
|
||||
// uu_test aliases - '[' is an alias for test
|
||||
"[" => "test",
|
||||
|
||||
// hashsum aliases - all these hash commands are aliases for hashsum
|
||||
"sha512sum" => "hashsum",
|
||||
|
||||
"dir" => "ls", // dir is an alias for ls
|
||||
|
||||
// Default case - return the util name as is
|
||||
|
||||
@@ -165,6 +165,7 @@ fn create_bundle(
|
||||
"sha224sum",
|
||||
"sha256sum",
|
||||
"sha384sum",
|
||||
"sha512sum",
|
||||
]
|
||||
.contains(&util_name)
|
||||
{
|
||||
|
||||
@@ -205,7 +205,6 @@ test_digest! {b3sum, b3sum}
|
||||
test_digest! {shake128, shake128}
|
||||
test_digest! {shake256, shake256}
|
||||
|
||||
test_digest_with_len! {sha512, sha512, 512}
|
||||
test_digest_with_len! {sha3_224, sha3, 224}
|
||||
test_digest_with_len! {sha3_256, sha3, 256}
|
||||
test_digest_with_len! {sha3_384, sha3, 384}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
// This file is part of the uutils coreutils package.
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
use uutests::new_ucmd;
|
||||
// spell-checker:ignore checkfile, testf, ntestf
|
||||
macro_rules! get_hash(
|
||||
($str:expr) => (
|
||||
$str.split(' ').collect::<Vec<&str>>()[0]
|
||||
);
|
||||
);
|
||||
|
||||
macro_rules! test_digest {
|
||||
($id:ident) => {
|
||||
mod $id {
|
||||
use uutests::util::*;
|
||||
use uutests::util_name;
|
||||
static EXPECTED_FILE: &'static str = concat!(stringify!($id), ".expected");
|
||||
static CHECK_FILE: &'static str = concat!(stringify!($id), ".checkfile");
|
||||
static INPUT_FILE: &'static str = "input.txt";
|
||||
|
||||
#[test]
|
||||
fn test_single_file() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
assert_eq!(
|
||||
ts.fixtures.read(EXPECTED_FILE),
|
||||
get_hash!(
|
||||
ts.ucmd()
|
||||
.arg(INPUT_FILE)
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_str()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stdin() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
assert_eq!(
|
||||
ts.fixtures.read(EXPECTED_FILE),
|
||||
get_hash!(
|
||||
ts.ucmd()
|
||||
.pipe_in_fixture(INPUT_FILE)
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_str()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
println!("File content='{}'", ts.fixtures.read(INPUT_FILE));
|
||||
println!("Check file='{}'", ts.fixtures.read(CHECK_FILE));
|
||||
|
||||
ts.ucmd()
|
||||
.args(&["--check", CHECK_FILE])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_is("input.txt: OK\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_zero() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
assert_eq!(
|
||||
ts.fixtures.read(EXPECTED_FILE),
|
||||
get_hash!(
|
||||
ts.ucmd()
|
||||
.arg("--zero")
|
||||
.arg(INPUT_FILE)
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_str()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_missing_file() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
|
||||
at.write("a", "file1\n");
|
||||
at.write("c", "file3\n");
|
||||
|
||||
ts.ucmd()
|
||||
.args(&["a", "b", "c"])
|
||||
.fails()
|
||||
.stdout_contains("a\n")
|
||||
.stdout_contains("c\n")
|
||||
.stderr_contains("b: No such file or directory");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
test_digest! {sha512}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_conflicting_arg() {
|
||||
new_ucmd!().arg("--tag").arg("--check").fails_with_code(1);
|
||||
new_ucmd!().arg("--tag").arg("--text").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_help_shows_correct_utility_name() {
|
||||
// Test that help output shows the actual utility name instead of "hashsum"
|
||||
new_ucmd!()
|
||||
.arg("--help")
|
||||
.succeeds()
|
||||
.stdout_contains("Usage: sha512sum")
|
||||
.stdout_does_not_contain("Usage: hashsum");
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
hello, world
|
||||
+1
@@ -0,0 +1 @@
|
||||
8710339dcb6814d0d9d2290ef422285c9322b7163951f9a0ca8f883d3305286f44139aa374848e4174f5aada663027e4548637b6d19894aec4fb6c46a139fbf9 input.txt
|
||||
+1
@@ -0,0 +1 @@
|
||||
8710339dcb6814d0d9d2290ef422285c9322b7163951f9a0ca8f883d3305286f44139aa374848e4174f5aada663027e4548637b6d19894aec4fb6c46a139fbf9
|
||||
@@ -92,6 +92,10 @@ mod test_sha256sum;
|
||||
#[path = "by-util/test_sha384sum.rs"]
|
||||
mod test_sha384sum;
|
||||
|
||||
#[cfg(feature = "sha512sum")]
|
||||
#[path = "by-util/test_sha512sum.rs"]
|
||||
mod test_sha512sum;
|
||||
|
||||
#[cfg(feature = "cp")]
|
||||
#[path = "by-util/test_cp.rs"]
|
||||
mod test_cp;
|
||||
|
||||
Reference in New Issue
Block a user