Skip to content

Commit 476b19a

Browse files
committed
Test
1 parent a70bca8 commit 476b19a

2 files changed

Lines changed: 57 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: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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())
23+
.await
24+
.unwrap();
25+
assert_eq!(
26+
dir.remove_directory_at("dot".to_string()).await,
27+
Err(ErrorCode::NotDirectory)
28+
);
29+
assert_eq!(
30+
dir.remove_directory_at("parent".to_string()).await,
31+
Err(ErrorCode::NotDirectory)
32+
);
33+
}
34+
35+
struct Component;
36+
export!(Component);
37+
impl exports::wasi::cli::run::Guest for Component {
38+
async fn run() -> Result<(), ()> {
39+
match &wasi::filesystem::preopens::get_directories()[..] {
40+
[(dir, dirname)] if dirname == "fs-tests.dir" => {
41+
test_rmdir_symlink(dir).await;
42+
}
43+
[..] => {
44+
eprintln!("usage: run with one open dir named 'fs-tests.dir'");
45+
process::exit(1)
46+
}
47+
};
48+
Ok(())
49+
}
50+
}
51+
52+
fn main() {
53+
unreachable!("main is a stub");
54+
}

0 commit comments

Comments
 (0)