1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-03-29 07:09:54 +01:00

put the file name in b3sum error output

This was previously there, but got dropped in
c5c07bb337.
This commit is contained in:
Jack O'Connor 2020-06-24 17:51:41 -04:00
parent 4c41a893a0
commit e0f193ddc9
2 changed files with 32 additions and 1 deletions

View File

@ -612,7 +612,7 @@ fn main() -> Result<()> {
let result = hash_one_input(path, &args);
if let Err(e) = result {
some_file_failed = true;
eprintln!("{}: {}", NAME, e);
eprintln!("{}: {}: {}", NAME, path.to_string_lossy(), e);
}
}
}

View File

@ -55,6 +55,37 @@ fn test_hash_many() {
assert_eq!(expected_no_names, output_no_names);
}
#[test]
fn test_missing_files() {
let dir = tempfile::tempdir().unwrap();
let file1 = dir.path().join("file1");
fs::write(&file1, b"foo").unwrap();
let file2 = dir.path().join("file2");
fs::write(&file2, b"bar").unwrap();
let output = cmd!(b3sum_exe(), "file1", "missing_file", "file2")
.dir(dir.path())
.stdout_capture()
.stderr_capture()
.unchecked()
.run()
.unwrap();
assert!(!output.status.success());
let foo_hash = blake3::hash(b"foo");
let bar_hash = blake3::hash(b"bar");
let expected_stdout = format!(
"{} file1\n{} file2\n",
foo_hash.to_hex(),
bar_hash.to_hex(),
);
assert_eq!(expected_stdout.as_bytes(), &output.stdout[..]);
let bing_error = fs::File::open(dir.path().join("missing_file")).unwrap_err();
let expected_stderr = format!("b3sum: missing_file: {}\n", bing_error.to_string());
assert_eq!(expected_stderr.as_bytes(), &output.stderr[..]);
}
#[test]
fn test_hash_length() {
let mut buf = [0; 100];