Browse Source
* rename preview1_remove_directory_trailing_slashes to preview1_remove_directory and get rid its testing of the inconsistient behavior of removing a directory using a trailing slash. Then, unmark it as should_panic everywhere, so we have test coverage of the behaviors that are consistient prtest:full * delete preview1_path_rename_file_trailing_slashes this only tests behavior which is not consistient across platforms. the rest of the behavior of path_rename is covered well by the path_rename test and path_rename_dir_trailing_slashes * debugging: see what CI tells me the preview1_interesting_paths chokes on in windows * more debugging information * interesting paths: windows allows a trailing nul apparently * preview1_remove_directory: every os says notdir, apparently! * no more should_panic tests!pull/7555/head
Pat Hickey
12 months ago
committed by
GitHub
8 changed files with 26 additions and 132 deletions
@ -1,53 +0,0 @@ |
|||
use std::{env, process}; |
|||
use test_programs::preview1::{assert_errno, create_file, open_scratch_directory}; |
|||
|
|||
unsafe fn test_path_rename_trailing_slashes(dir_fd: wasi::Fd) { |
|||
// Test renaming a file with a trailing slash in the name.
|
|||
create_file(dir_fd, "source"); |
|||
|
|||
wasi::path_rename(dir_fd, "source", dir_fd, "target") |
|||
.expect("no trailing slashes rename works"); |
|||
wasi::path_rename(dir_fd, "target", dir_fd, "source").expect("rename it back to source"); |
|||
|
|||
assert_errno!( |
|||
wasi::path_rename(dir_fd, "source/", dir_fd, "target") |
|||
.expect_err("renaming a file with a trailing slash in the source name should fail"), |
|||
wasi::ERRNO_NOTDIR |
|||
); |
|||
assert_errno!( |
|||
wasi::path_rename(dir_fd, "source", dir_fd, "target/").expect_err( |
|||
"renaming a file with a trailing slash in the destination name should fail" |
|||
), |
|||
wasi::ERRNO_NOTDIR |
|||
); |
|||
assert_errno!( |
|||
wasi::path_rename(dir_fd, "source/", dir_fd, "target/").expect_err( |
|||
"renaming a file with a trailing slash in the source and destination names should fail" |
|||
), |
|||
wasi::ERRNO_NOTDIR |
|||
); |
|||
wasi::path_unlink_file(dir_fd, "source").expect("removing a file"); |
|||
} |
|||
|
|||
fn main() { |
|||
let mut args = env::args(); |
|||
let prog = args.next().unwrap(); |
|||
let arg = if let Some(arg) = args.next() { |
|||
arg |
|||
} else { |
|||
eprintln!("usage: {} <scratch directory>", prog); |
|||
process::exit(1); |
|||
}; |
|||
|
|||
// Open scratch directory
|
|||
let dir_fd = match open_scratch_directory(&arg) { |
|||
Ok(dir_fd) => dir_fd, |
|||
Err(err) => { |
|||
eprintln!("{}", err); |
|||
process::exit(1) |
|||
} |
|||
}; |
|||
|
|||
// Run the tests.
|
|||
unsafe { test_path_rename_trailing_slashes(dir_fd) } |
|||
} |
Loading…
Reference in new issue