|
2 | 2 | //
|
3 | 3 | // For the full copyright and license information, please view the LICENSE
|
4 | 4 | // file that was distributed with this source code.
|
5 |
| -// spell-checker:ignore (words) asdf algo algos asha mgmt xffname |
| 5 | +// spell-checker:ignore (words) asdf algo algos asha mgmt xffname funkyname |
6 | 6 |
|
7 | 7 | use crate::common::util::TestScenario;
|
8 | 8 |
|
@@ -1277,3 +1277,50 @@ fn test_non_utf8_filename() {
|
1277 | 1277 | .stdout_is_bytes(b"SHA256 (funky\xffname) = e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n")
|
1278 | 1278 | .no_stderr();
|
1279 | 1279 | }
|
| 1280 | + |
| 1281 | +#[cfg(target_os = "linux")] |
| 1282 | +#[test] |
| 1283 | +fn test_check_non_utf8_comment() { |
| 1284 | + let hashes = |
| 1285 | + b"MD5 (empty) = 1B2M2Y8AsgTpgAmY7PhCfg==\n\ |
| 1286 | + # Comment with a non utf8 char: >>\xff<<\n\ |
| 1287 | + SHA256 (empty) = 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=\n\ |
| 1288 | + BLAKE2b (empty) = eGoC90IBWQPGxv2FJVLScpEvR0DhWEdhiobiF/cfVBnSXhAxr+5YUxOJZESTTrBLkDpoWxRIt1XVb3Aa/pvizg==\n" |
| 1289 | + ; |
| 1290 | + |
| 1291 | + let scene = TestScenario::new(util_name!()); |
| 1292 | + let at = &scene.fixtures; |
| 1293 | + |
| 1294 | + at.touch("empty"); |
| 1295 | + at.write_bytes("check", hashes); |
| 1296 | + |
| 1297 | + scene |
| 1298 | + .ucmd() |
| 1299 | + .arg("--check") |
| 1300 | + .arg(at.subdir.join("check")) |
| 1301 | + .succeeds() |
| 1302 | + .stdout_is("empty: OK\nempty: OK\nempty: OK\n") |
| 1303 | + .no_stderr(); |
| 1304 | +} |
| 1305 | + |
| 1306 | +#[cfg(target_os = "linux")] |
| 1307 | +#[test] |
| 1308 | +fn test_check_non_utf8_filename() { |
| 1309 | + use std::ffi::OsString; |
| 1310 | + use std::os::unix::ffi::OsStringExt; |
| 1311 | + |
| 1312 | + let scene = TestScenario::new(util_name!()); |
| 1313 | + let at = &scene.fixtures; |
| 1314 | + let filename: OsString = OsStringExt::from_vec(b"funky\xffname".to_vec()); |
| 1315 | + |
| 1316 | + at.touch(&filename); |
| 1317 | + at.write_bytes("check", b"SHA256 (funky\xffname) = e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n"); |
| 1318 | + |
| 1319 | + scene |
| 1320 | + .ucmd() |
| 1321 | + .arg("--check") |
| 1322 | + .arg(at.subdir.join("check")) |
| 1323 | + .succeeds() |
| 1324 | + .stdout_is("funkyname: OK\n") |
| 1325 | + .no_stderr(); |
| 1326 | +} |
0 commit comments