Skip to content

Commit 47a9544

Browse files
committed
Add test for non-UTF-8 path
1 parent 957748c commit 47a9544

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

crates/cli/src/file_utils.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,23 @@ mod tests {
913913
);
914914
}
915915

916+
#[cfg(target_os = "linux")]
917+
#[test]
918+
fn get_files_non_utf8_path() {
919+
let tmp = TestDir::new();
920+
921+
let valid_path = tmp.base_path().join("valid.js");
922+
fs::File::create(&valid_path).unwrap();
923+
// (0xFF isn't a valid UTF-8 byte)
924+
let invalid_path = tmp
925+
.base_path()
926+
.join(<std::ffi::OsStr as std::os::unix::ffi::OsStrExt>::from_bytes(b"\xFF.js"));
927+
fs::File::create(&invalid_path).unwrap();
928+
929+
let files = get_files(tmp.base_path(), vec![], &PathConfig::default()).unwrap();
930+
assert_eq!(files, vec![valid_path]);
931+
}
932+
916933
#[test]
917934
fn test_get_language_for_file() {
918935
// extension Java

0 commit comments

Comments
 (0)