mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
sha1sum: fix the -c usage (Closes: #3815)
This commit is contained in:
parent
2870fb091b
commit
00f5d91886
2 changed files with 31 additions and 3 deletions
|
@ -296,7 +296,11 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
|
||||||
};
|
};
|
||||||
let check = matches.contains_id("check");
|
let check = matches.contains_id("check");
|
||||||
let tag = matches.contains_id("tag");
|
let tag = matches.contains_id("tag");
|
||||||
let nonames = matches.contains_id("no-names");
|
let nonames = if binary_name == "b3sum" {
|
||||||
|
matches.contains_id("no-names")
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
};
|
||||||
let status = matches.contains_id("status");
|
let status = matches.contains_id("status");
|
||||||
let quiet = matches.contains_id("quiet") || status;
|
let quiet = matches.contains_id("quiet") || status;
|
||||||
let strict = matches.contains_id("strict");
|
let strict = matches.contains_id("strict");
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// spell-checker:ignore checkfile, nonames
|
use crate::common::util::*;
|
||||||
|
// spell-checker:ignore checkfile, nonames, testf
|
||||||
macro_rules! get_hash(
|
macro_rules! get_hash(
|
||||||
($str:expr) => (
|
($str:expr) => (
|
||||||
$str.split(' ').collect::<Vec<&str>>()[0]
|
$str.split(' ').collect::<Vec<&str>>()[0]
|
||||||
|
@ -33,10 +34,13 @@ 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
|
||||||
assert_eq!(format!("{0}\n{0}\n", ts.fixtures.read(EXPECTED_FILE)),
|
if DIGEST_ARG == "b3sum" {
|
||||||
|
// Option only available on b3sum
|
||||||
|
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")
|
||||||
.succeeds().no_stderr().stdout_str()
|
.succeeds().no_stderr().stdout_str()
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -92,3 +96,23 @@ test_digest! {
|
||||||
b2sum b2sum 512
|
b2sum b2sum 512
|
||||||
b3sum b3sum 256
|
b3sum b3sum 256
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_check_sha1() {
|
||||||
|
// To make sure that #3815 doesn't happen again
|
||||||
|
let scene = TestScenario::new(util_name!());
|
||||||
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
|
at.write("testf", "foobar\n");
|
||||||
|
at.write(
|
||||||
|
"testf.sha1",
|
||||||
|
"988881adc9fc3655077dc2d4d757d480b5ea0e11 testf\n",
|
||||||
|
);
|
||||||
|
scene
|
||||||
|
.ccmd("sha1sum")
|
||||||
|
.arg("-c")
|
||||||
|
.arg(at.subdir.join("testf.sha1"))
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("testf: OK\n")
|
||||||
|
.stderr_is("");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue