tests: macos-specific behavior
This commit is contained in:
@@ -37,10 +37,16 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any
|
|||||||
.env("NO_RENAME_DIR_TO_EMPTY_DIR", "1")?
|
.env("NO_RENAME_DIR_TO_EMPTY_DIR", "1")?
|
||||||
.env("NO_DANGLING_DIRECTORY", "1")?;
|
.env("NO_DANGLING_DIRECTORY", "1")?;
|
||||||
}
|
}
|
||||||
#[cfg(unix)]
|
#[cfg(all(unix, not(target_os = "macos")))]
|
||||||
{
|
{
|
||||||
builder = builder.env("ERRNO_MODE_UNIX", "1")?;
|
builder = builder.env("ERRNO_MODE_UNIX", "1")?;
|
||||||
}
|
}
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
builder = builder
|
||||||
|
.env("ERRNO_MODE_MACOS", "1")?
|
||||||
|
.env("NO_FD_ALLOCATE", "1")?;
|
||||||
|
}
|
||||||
|
|
||||||
// cap-std-sync does not yet support the sync family of fdflags
|
// cap-std-sync does not yet support the sync family of fdflags
|
||||||
builder = builder.env("NO_FDFLAGS_SYNC_SUPPORT", "1")?;
|
builder = builder.env("NO_FDFLAGS_SYNC_SUPPORT", "1")?;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ unsafe fn test_unlink_file_trailing_slashes(dir_fd: wasi::Fd) {
|
|||||||
wasi::path_unlink_file(dir_fd, "dir")
|
wasi::path_unlink_file(dir_fd, "dir")
|
||||||
.expect_err("unlink_file on a directory should fail")
|
.expect_err("unlink_file on a directory should fail")
|
||||||
.raw_error(),
|
.raw_error(),
|
||||||
|
macos => wasi::ERRNO_PERM,
|
||||||
unix => wasi::ERRNO_ISDIR,
|
unix => wasi::ERRNO_ISDIR,
|
||||||
windows => wasi::ERRNO_ACCES
|
windows => wasi::ERRNO_ACCES
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ pub struct TestConfig {
|
|||||||
|
|
||||||
enum ErrnoMode {
|
enum ErrnoMode {
|
||||||
Unix,
|
Unix,
|
||||||
|
MacOS,
|
||||||
Windows,
|
Windows,
|
||||||
Permissive,
|
Permissive,
|
||||||
}
|
}
|
||||||
@@ -17,6 +18,8 @@ impl TestConfig {
|
|||||||
pub fn from_env() -> Self {
|
pub fn from_env() -> Self {
|
||||||
let errno_mode = if std::env::var("ERRNO_MODE_UNIX").is_ok() {
|
let errno_mode = if std::env::var("ERRNO_MODE_UNIX").is_ok() {
|
||||||
ErrnoMode::Unix
|
ErrnoMode::Unix
|
||||||
|
} else if std::env::var("ERRNO_MODE_MACOS").is_ok() {
|
||||||
|
ErrnoMode::MacOS
|
||||||
} else if std::env::var("ERRNO_MODE_WINDOWS").is_ok() {
|
} else if std::env::var("ERRNO_MODE_WINDOWS").is_ok() {
|
||||||
ErrnoMode::Windows
|
ErrnoMode::Windows
|
||||||
} else {
|
} else {
|
||||||
@@ -38,7 +41,13 @@ impl TestConfig {
|
|||||||
}
|
}
|
||||||
pub fn errno_expect_unix(&self) -> bool {
|
pub fn errno_expect_unix(&self) -> bool {
|
||||||
match self.errno_mode {
|
match self.errno_mode {
|
||||||
ErrnoMode::Unix => true,
|
ErrnoMode::Unix | ErrnoMode::MacOS => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn errno_expect_macos(&self) -> bool {
|
||||||
|
match self.errno_mode {
|
||||||
|
ErrnoMode::MacOS => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,14 @@ macro_rules! assert_errno {
|
|||||||
assert_errno!(e, $($rest)+, $i);
|
assert_errno!(e, $($rest)+, $i);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
($s:expr, macos => $i:expr, $( $rest:tt )+) => {
|
||||||
|
let e = $s;
|
||||||
|
if $crate::TESTCONFIG.errno_expect_macos() {
|
||||||
|
assert_errno!(e, $i);
|
||||||
|
} else {
|
||||||
|
assert_errno!(e, $($rest)+, $i);
|
||||||
|
}
|
||||||
|
};
|
||||||
($s:expr, unix => $i:expr, $( $rest:tt )+) => {
|
($s:expr, unix => $i:expr, $( $rest:tt )+) => {
|
||||||
let e = $s;
|
let e = $s;
|
||||||
if $crate::TESTCONFIG.errno_expect_unix() {
|
if $crate::TESTCONFIG.errno_expect_unix() {
|
||||||
|
|||||||
Reference in New Issue
Block a user