This test was not meaningfully executing, because wasi-common never provides rights containing RIGHTS_PATH_FILESTAT_SET_SIZE - this flag is not even defined in wasi-common/srd/dir.rs as one of the DirCaps flags. Even when you get rid of that guard that skips the meat of the test, path_open was being called with OFLAGS_TRUNC but without RIGHTS_FD_WRITE, which boils down to an `open(2)` with OFLAGS_TRUNC set and none of the access modes set, so it will always fail with EINVAL. So, it doesn't look like this test ever would have meaningfully passed, even in pre-wiggle-rewrite version of wasi-common it landed in back in late 2019. Late 2019! before the pandemic! our eyes were so full of stars and dreams of the future! The behavior we really care about for truncation are taken care of by the fd_filestat_set test, which shows fd_filestat_set_size works correctly, and the file_truncation test, which shows that opening with OFLAGS_TRUNC will truncate the file.
This is the test-programs crate, which builds and runs whole programs
compiled to wasm32-wasi.
To actually run these tests, the test-programs feature must be enabled, e.g.:
cargo test --features test-programs/test_programs --package test-programs