diff --git a/crates/tests/bindgen/tests/panic.rs b/crates/tests/bindgen/tests/panic.rs index 931bc852bd..2dad1b6f49 100644 --- a/crates/tests/bindgen/tests/panic.rs +++ b/crates/tests/bindgen/tests/panic.rs @@ -143,17 +143,22 @@ fn subset_namespace() { #[test] #[should_panic(expected = "failed to create directory")] fn failed_to_create_directory() { - bindgen(&format!( - "--out {}\\invalid\\out.txt --in default --filter POINT", - env!("windir") - )); + let test_path = format!( + "{}\\failed_to_create_directory", + env!("CARGO_TARGET_TMPDIR") + ); + + std::fs::write(&test_path, "test").unwrap(); + let test_path = format!("{}\\out.txt", test_path); + + bindgen(&format!("--out {test_path} --in default --filter POINT",)); } #[test] #[should_panic(expected = "failed to write file")] fn failed_to_write_file() { - bindgen(&format!( - "--out {}\\out.txt --in default --filter POINT", - env!("windir") - )); + let test_path = format!("{}\\failed_to_write_file", env!("CARGO_TARGET_TMPDIR")); + std::fs::create_dir_all(&test_path).unwrap(); + + bindgen(&format!("--out {test_path} --in default --filter POINT",)); }