Skip to content

Commit 6e6b545

Browse files
committed
checksum: fix binary flag on windows, ignore test
1 parent a9cdb1c commit 6e6b545

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/uu/cksum/src/cksum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
186186
digest: algo.create_digest(),
187187
output_format,
188188
line_ending,
189+
binary: false,
189190
no_names: false,
190191
};
191192

src/uu/hashsum/src/hashsum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
230230
/* base64: */ false,
231231
),
232232
line_ending,
233+
binary,
233234
no_names,
234235
};
235236

src/uucore/src/lib/features/checksum/compute.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ pub struct ChecksumComputeOptions {
3434
/// Whether to finish lines with '\n' or '\0'.
3535
pub line_ending: LineEnding,
3636

37+
/// On windows, open files as binary instead of text
38+
pub binary: bool,
39+
3740
/// (non-GNU option) Do not print file names
3841
pub no_names: bool,
3942
}
@@ -290,7 +293,7 @@ where
290293
let (sum_hex, sz) = digest_reader(
291294
&mut options.digest,
292295
&mut file,
293-
false,
296+
options.binary,
294297
options.algo_kind.bitlen(),
295298
)
296299
.map_err_context(|| translate!("cksum-error-failed-to-read-input"))?;

tests/by-util/test_hashsum.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,12 @@ macro_rules! test_digest {
107107
at.write("a", "file1\n");
108108
at.write("c", "file3\n");
109109

110-
#[cfg(unix)]
111-
let file_not_found_str = "No such file or directory";
112-
#[cfg(not(unix))]
113-
let file_not_found_str = "The system cannot find the file specified";
114-
115110
ts.ucmd()
116111
.args(&[DIGEST_ARG, BITS_ARG, "a", "b", "c"])
117112
.fails()
118113
.stdout_contains("a\n")
119114
.stdout_contains("c\n")
120-
.stderr_contains(format!("b: {file_not_found_str}"));
115+
.stderr_contains("b: No such file or directory");
121116
}
122117
}
123118
)*)
@@ -1097,11 +1092,11 @@ fn test_sha256_stdin_binary() {
10971092
);
10981093
}
10991094

1095+
// This test is currently disabled on windows
11001096
#[test]
1097+
#[cfg_attr(windows, ignore = "Discussion is in #9168")]
11011098
fn test_check_sha256_binary() {
1102-
let ts = TestScenario::new(util_name!());
1103-
1104-
ts.ucmd()
1099+
new_ucmd!()
11051100
.args(&[
11061101
"--sha256",
11071102
"--bits=256",

0 commit comments

Comments
 (0)