Skip to content

Commit 33b241a

Browse files
committed
Test
1 parent a70bca8 commit 33b241a

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dirs": ["fs-tests.dir"]
3+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
use std::process;
2+
extern crate wit_bindgen;
3+
4+
wit_bindgen::generate!({
5+
inline: r"
6+
package test:test;
7+
8+
world test {
9+
include wasi:filesystem/imports@0.3.0-rc-2025-09-16;
10+
include wasi:cli/command@0.3.0-rc-2025-09-16;
11+
}
12+
",
13+
additional_derives: [PartialEq, Eq, Hash, Clone],
14+
// Work around https://github.com/bytecodealliance/wasm-tools/issues/2285.
15+
features:["clocks-timezone"],
16+
generate_all
17+
});
18+
19+
use wasi::filesystem::types::{Descriptor, ErrorCode};
20+
21+
async fn test_rmdir_symlink(dir: &Descriptor) {
22+
dir.symlink_at(".".to_string(), "dot".to_string()).await.unwrap();
23+
assert_eq!(
24+
dir.remove_directory_at("dot".to_string()).await,
25+
Err(ErrorCode::NotDirectory)
26+
);
27+
assert_eq!(
28+
dir.remove_directory_at("parent".to_string()).await,
29+
Err(ErrorCode::NotDirectory)
30+
);
31+
}
32+
33+
struct Component;
34+
export!(Component);
35+
impl exports::wasi::cli::run::Guest for Component {
36+
async fn run() -> Result<(), ()> {
37+
match &wasi::filesystem::preopens::get_directories()[..] {
38+
[(dir, dirname)] if dirname == "fs-tests.dir" => {
39+
test_rmdir_symlink(dir).await;
40+
}
41+
[..] => {
42+
eprintln!("usage: run with one open dir named 'fs-tests.dir'");
43+
process::exit(1)
44+
}
45+
};
46+
Ok(())
47+
}
48+
}
49+
50+
fn main() {
51+
unreachable!("main is a stub");
52+
}

0 commit comments

Comments
 (0)