mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
hashsum: support --check for algorithms with variable output length (#2583)
* hashsum: support --check for var. length outputs Add the ability for `hashsum --check` to work with algorithms with variable output length. Previously, the program would terminate with an error due to constructing an invalid regular expression. * fixup! hashsum: support --check for var. length outputs
This commit is contained in:
parent
b828e922e5
commit
bdc0f4b7c3
15 changed files with 40 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
|||
// spell-checker:ignore checkfile
|
||||
macro_rules! get_hash(
|
||||
($str:expr) => (
|
||||
$str.split(' ').collect::<Vec<&str>>()[0]
|
||||
|
@ -12,6 +13,7 @@ macro_rules! test_digest {
|
|||
static DIGEST_ARG: &'static str = concat!("--", stringify!($t));
|
||||
static BITS_ARG: &'static str = concat!("--bits=", stringify!($size));
|
||||
static EXPECTED_FILE: &'static str = concat!(stringify!($id), ".expected");
|
||||
static CHECK_FILE: &'static str = concat!(stringify!($id), ".checkfile");
|
||||
|
||||
#[test]
|
||||
fn test_single_file() {
|
||||
|
@ -26,6 +28,16 @@ macro_rules! test_digest {
|
|||
assert_eq!(ts.fixtures.read(EXPECTED_FILE),
|
||||
get_hash!(ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).pipe_in_fixture("input.txt").succeeds().no_stderr().stdout_str()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check() {
|
||||
let ts = TestScenario::new("hashsum");
|
||||
ts.ucmd()
|
||||
.args(&[DIGEST_ARG, BITS_ARG, "--check", CHECK_FILE])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_is("input.txt: OK\n");
|
||||
}
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue