Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test test_hashsum::b3sum::test_nonames for real #3818

Closed
sylvestre opened this issue Aug 15, 2022 · 3 comments · Fixed by #4027
Closed

Test test_hashsum::b3sum::test_nonames for real #3818

sylvestre opened this issue Aug 15, 2022 · 3 comments · Fixed by #4027
Labels

Comments

@sylvestre
Copy link
Contributor

Improved in #3816 but not enough as it isn't testing it. This patch runs it:

diff --git a/tests/by-util/test_hashsum.rs b/tests/by-util/test_hashsum.rs
index 06d039d59..7a87125c8 100644
--- a/tests/by-util/test_hashsum.rs
+++ b/tests/by-util/test_hashsum.rs
@@ -34,7 +34,7 @@ macro_rules! test_digest {
         fn test_nonames() {
             let ts = TestScenario::new("hashsum");
             // EXPECTED_FILE has no newline character at the end
-            if DIGEST_ARG == "b3sum" {
+            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")

But fails with:


---- test_hashsum::b3sum::test_nonames stdout ----
current_directory_resolved: 
open: /tmp/.tmpc8CYCJ/b3sum.expected
open: /tmp/.tmpc8CYCJ/input.txt
run: /home/sylvestre/dev/debian/coreutils/target/debug/coreutils hashsum --b3sum --bits=256 --no-names input.txt -
thread 'test_hashsum::b3sum::test_nonames' panicked at 'assertion failed: `(left == right)`
  left: `"a1a55887535397bf461902491c8779188a5dd1f8c3951b3d9cf6ecba194e87b0\na1a55887535397bf461902491c8779188a5dd1f8c3951b3d9cf6ecba194e87b0\n"`,
 right: `"a1a55887535397bf461902491c8779188a5dd1f8c3951b3d9cf6ecba194e87b0  input.txt\na1a55887535397bf461902491c8779188a5dd1f8c3951b3d9cf6ecba194e87b0  -\n"`', /home/sylvestre/dev/debian/coreutils/tests/by-util/test_hashsum.rs:83:1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To run it:

cargo test test_hashsum::b3sum::test_nonames      
@huijeong-kim
Copy link
Contributor

Hi. I want to try this issue but need some help. Is "noname" option only valid for binary_name "b3sum" or binary_name hashmap with "--b3sum" argument?

Can I change like this?

let nonames = if binary_name == "b3sum" || matches.try_contains_id("b3sum").is_ok() {
    matches.contains_id("no-names")
} else {
    false
};

@tertsdiepraam
Copy link
Member

I think --no-names should be accepted in both cases, so your solution seems on the right track.

@huijeong-kim
Copy link
Contributor

Thanks a lot! Then I'll submit PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants