Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/rust/wasm32-wasip3/src/bin/test-rmdir-symlink.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dirs": ["fs-tests.dir"]
}
54 changes: 54 additions & 0 deletions tests/rust/wasm32-wasip3/src/bin/test-rmdir-symlink.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use std::process;
extern crate wit_bindgen;

wit_bindgen::generate!({
inline: r"
package test:test;

world test {
include wasi:filesystem/imports@0.3.0-rc-2025-09-16;
include wasi:cli/command@0.3.0-rc-2025-09-16;
}
",
additional_derives: [PartialEq, Eq, Hash, Clone],
// Work around https://github.com/bytecodealliance/wasm-tools/issues/2285.
features:["clocks-timezone"],
generate_all
});

use wasi::filesystem::types::{Descriptor, ErrorCode};

async fn test_rmdir_symlink(dir: &Descriptor) {
dir.symlink_at(".".to_string(), "dot".to_string())
.await
.unwrap();
assert_eq!(
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this succeeds on windows

dir.remove_directory_at("dot".to_string()).await,
Err(ErrorCode::NotDirectory)
);
assert_eq!(
dir.remove_directory_at("parent".to_string()).await,
Err(ErrorCode::NotDirectory)
);
}

struct Component;
export!(Component);
impl exports::wasi::cli::run::Guest for Component {
async fn run() -> Result<(), ()> {
match &wasi::filesystem::preopens::get_directories()[..] {
[(dir, dirname)] if dirname == "fs-tests.dir" => {
test_rmdir_symlink(dir).await;
}
[..] => {
eprintln!("usage: run with one open dir named 'fs-tests.dir'");
process::exit(1)
}
};
Ok(())
}
}

fn main() {
unreachable!("main is a stub");
}
Loading