Skip to content

Commit

Permalink
Add test for mkdir -> rename -> mkdir
Browse files Browse the repository at this point in the history
  • Loading branch information
Arshia001 committed Nov 8, 2024
1 parent 7762dad commit b65ec18
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/integration/cli/tests/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,3 +1359,12 @@ fn test_snapshot_worker_panicking() {
));
assert_json_snapshot!(snapshot);
}

#[cfg_attr(any(target_env = "musl", target_os = "windows"), ignore)]
#[test]
fn test_snapshot_mkdir_rename() {
let snapshot = TestBuilder::new()
.with_name(function!())
.run_wasm(include_bytes!("./wasm/mkdir-rename.wasm"));
assert_json_snapshot!(snapshot);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
source: tests/integration/cli/tests/snapshot.rs
assertion_line: 1369
expression: snapshot
---
{
"spec": {
"name": "snapshot::test_snapshot_mkdir_rename",
"use_packages": [],
"include_webcs": [],
"cli_args": [],
"enable_threads": true,
"enable_network": false
},
"result": {
"Success": {
"stdout": "",
"stderr": "",
"exit_code": 0
}
}
}
Binary file not shown.
12 changes: 12 additions & 0 deletions tests/rust-wasi-tests/src/bin/mkdir-rename.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fn main() {
std::fs::create_dir("/a").unwrap();
assert!(std::fs::metadata("/a").unwrap().is_dir());

std::fs::rename("/a", "/b").unwrap();
assert!(matches!(std::fs::metadata("/a"), Err(e) if e.kind() == std::io::ErrorKind::NotFound));
assert!(std::fs::metadata("/b").unwrap().is_dir());

std::fs::create_dir("/a").unwrap();
assert!(std::fs::metadata("/a").unwrap().is_dir());
assert!(std::fs::metadata("/b").unwrap().is_dir());
}

0 comments on commit b65ec18

Please sign in to comment.