will this work for platform-specific errnos? WIP

This commit is contained in:
Pat Hickey
2021-01-27 18:18:12 -08:00
parent 2ae1dee642
commit be108c7a93
2 changed files with 18 additions and 1 deletions

View File

@@ -22,7 +22,8 @@ unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) {
wasi::path_symlink("source", dir_fd, "target/") wasi::path_symlink("source", dir_fd, "target/")
.expect_err("link destination already exists") .expect_err("link destination already exists")
.raw_error(), .raw_error(),
wasi::ERRNO_EXIST, windows => wasi::ERRNO_NOENT,
wasi::ERRNO_EXIST
); );
wasi::path_remove_directory(dir_fd, "target").expect("removing a directory"); wasi::path_remove_directory(dir_fd, "target").expect("removing a directory");

View File

@@ -67,6 +67,22 @@ macro_rules! assert_errno {
($s:expr, $( $i:expr ),+,) => { ($s:expr, $( $i:expr ),+,) => {
assert_errno!($s, $( $i ),+) assert_errno!($s, $( $i ),+)
}; };
($s:expr, windows => $i:expr, $( $rest:expr ),+) => {
let e = $s;
if std::env::var("ERRNO_EXPECT_WINDOWS").is_ok() {
assert_errno!(e, $i);
} else {
assert_errno!(e, $($rest),+, $i);
}
};
($s:expr, linux => $i:expr, $( $rest:expr ),+) => {
let e = $s;
if std::env::var("ERRNO_EXPECT_LINUX").is_ok() {
assert_errno!(e, $i);
} else {
assert_errno!(e, $($rest),+, $i);
}
};
($s:expr, $( $i:expr ),+) => { ($s:expr, $( $i:expr ),+) => {
let e = $s; let e = $s;
{ {