-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
cksum: fix error handling #6801
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1344,3 +1344,42 @@ fn test_check_comment_leading_space() { | |||||||||
.stdout_contains("foo: OK") | ||||||||||
.stderr_contains("WARNING: 1 line is improperly formatted"); | ||||||||||
} | ||||||||||
|
||||||||||
/// This test checks alignment with GNU's error handling. | ||||||||||
/// Windows has a different logic and is guarded by [`test_check_directory_error`]. | ||||||||||
#[cfg(not(windows))] | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not windows? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/uutils/coreutils/actions/runs/11424022765/job/31783927716#step:7:3602 coreutils/tests/by-util/test_cksum.rs Lines 1195 to 1198 in 9a6f552
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you please document this into the test ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||||||||||
#[test] | ||||||||||
fn test_check_failed_to_read() { | ||||||||||
// check `cksum`'s behavior when encountering directories or non existing files | ||||||||||
|
||||||||||
let scene = TestScenario::new(util_name!()); | ||||||||||
let at = &scene.fixtures; | ||||||||||
|
||||||||||
at.write( | ||||||||||
"CHECKSUM", | ||||||||||
"SHA1 (dir) = ffffffffffffffffffffffffffffffffffffffff\n\ | ||||||||||
SHA1 (not-file) = ffffffffffffffffffffffffffffffffffffffff\n", | ||||||||||
); | ||||||||||
at.mkdir("dir"); | ||||||||||
|
||||||||||
scene | ||||||||||
.ucmd() | ||||||||||
.arg("--check") | ||||||||||
.arg("CHECKSUM") | ||||||||||
.fails() | ||||||||||
.stdout_is( | ||||||||||
"dir: FAILED open or read\n\ | ||||||||||
not-file: FAILED open or read\n", | ||||||||||
) | ||||||||||
.stderr_contains("cksum: WARNING: 2 listed files could not be read"); | ||||||||||
|
||||||||||
// check with `--ignore-missing` | ||||||||||
scene | ||||||||||
.ucmd() | ||||||||||
.arg("--check") | ||||||||||
.arg("CHECKSUM") | ||||||||||
.arg("--ignore-missing") | ||||||||||
.fails() | ||||||||||
.stdout_is("dir: FAILED open or read\n") | ||||||||||
.stderr_contains("cksum: WARNING: 1 listed file could not be read"); | ||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason for moving this up ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As shown in the code snippet in #6796 :
warnings in
cksum_output
show up first, andCHECKSUM: no file was verified
shows up later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, indeed 👍