|
1 | 1 | use std::{env, process}; |
2 | | -use test_programs::preview1::{assert_errno, create_file, open_scratch_directory}; |
| 2 | +use test_programs::preview1::{assert_errno, create_file, open_scratch_directory, TestConfig}; |
3 | 3 |
|
4 | 4 | unsafe fn test_path_rename(dir_fd: wasip1::Fd) { |
5 | 5 | // First, try renaming a dir to nonexistent path |
@@ -62,13 +62,18 @@ unsafe fn test_path_rename(dir_fd: wasip1::Fd) { |
62 | 62 | ); |
63 | 63 |
|
64 | 64 | // Try renaming dir to a file |
65 | | - assert_errno!( |
66 | | - wasip1::path_rename(dir_fd, "source", dir_fd, "target/file") |
67 | | - .expect_err("renaming a directory to a file"), |
68 | | - wasip1::ERRNO_NOTDIR |
69 | | - ); |
70 | | - wasip1::path_unlink_file(dir_fd, "target/file").expect("removing a file"); |
71 | | - wasip1::path_remove_directory(dir_fd, "source").expect("removing a directory"); |
| 65 | + if TestConfig::from_env().support_rename_dir_onto_file() { |
| 66 | + wasip1::path_rename(dir_fd, "source", dir_fd, "target/file").unwrap(); |
| 67 | + wasip1::path_remove_directory(dir_fd, "target/file").expect("removing a directory"); |
| 68 | + } else { |
| 69 | + assert_errno!( |
| 70 | + wasip1::path_rename(dir_fd, "source", dir_fd, "target/file") |
| 71 | + .expect_err("renaming a directory to a file"), |
| 72 | + wasip1::ERRNO_NOTDIR |
| 73 | + ); |
| 74 | + wasip1::path_unlink_file(dir_fd, "target/file").expect("removing a file"); |
| 75 | + wasip1::path_remove_directory(dir_fd, "source").expect("removing a directory"); |
| 76 | + } |
72 | 77 | wasip1::path_remove_directory(dir_fd, "target").expect("removing a directory"); |
73 | 78 |
|
74 | 79 | // Now, try renaming a file to a nonexistent path |
|
0 commit comments