diff --git a/crates/wasi-common/cap-std-sync/src/dir.rs b/crates/wasi-common/cap-std-sync/src/dir.rs index 87b9f6e4c4..1b3d68e780 100644 --- a/crates/wasi-common/cap-std-sync/src/dir.rs +++ b/crates/wasi-common/cap-std-sync/src/dir.rs @@ -334,55 +334,4 @@ mod test { FileType::RegularFile ); } - - #[test] - fn std_rename_dir_to_existing_file() { - let tempdir = tempfile::Builder::new() - .prefix("cap-std-sync") - .tempdir() - .expect("create temporary dir"); - let target_path = tempdir.path().join("target"); - let source_path = tempdir.path().join("source"); - - let file = std::fs::File::create(&target_path).expect("create target file"); - drop(file); - std::fs::create_dir(&source_path).expect("create source dir"); - - std::fs::rename(&source_path, &target_path) - .expect_err("it should be impossible to rename a directory to an existing file"); - } - - #[test] - fn rename_dir_to_existing_file() { - let tempdir = tempfile::Builder::new() - .prefix("cap-std-sync") - .tempdir() - .expect("create temporary dir"); - - let preopen_dir = unsafe { cap_std::fs::Dir::open_ambient_dir(tempdir.path()) } - .expect("open ambient temporary dir"); - let preopen_dir = Dir::from_cap_std(preopen_dir); - let wasi_dir: &dyn WasiDir = &preopen_dir; - - let file = wasi_dir - .open_file( - false, - "target", - OFlags::CREATE, - true, - false, - FdFlags::empty(), - ) - .expect("create target"); - // Close the file: - drop(file); - - wasi_dir - .create_dir("source") - .expect("create source directory"); - - wasi_dir - .rename("source", wasi_dir, "target") - .expect_err("it should be impossible to rename a directory to an existing file"); - } }