Skip to content

Commit 5af60ca

Browse files
authored
test(wasi): run a few tests that shouldn't have been disabled (#370)
1 parent 6c0c561 commit 5af60ca

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
RUSTDOCFLAGS: "-D warnings"
1414
NDK_VERSION: "r26d"
1515
ANDROID_VERSION: "12.0.0"
16+
WASMTIME_BACKTRACE_DETAILS: 1
1617

1718
name: CI
1819
jobs:
@@ -125,7 +126,7 @@ jobs:
125126
- name: Build
126127
run: cargo build --target ${{ matrix.platform.target }} ${{ matrix.rust-version == 'nightly' && '--features nightly' || '' }}
127128
- name: Test
128-
run: cargo test --target ${{ matrix.platform.target }} ${{ matrix.rust-version == 'nightly' && '--features nightly' || '' }} ${{ matrix.test-flags }}
129+
run: cargo test --target ${{ matrix.platform.target }} ${{ matrix.rust-version == 'nightly' && '--features nightly' || '' }} ${{ matrix.test-flags }} -- --nocapture
129130
- name: Stop the redroid container
130131
if: ${{ contains(matrix.platform.target, 'android') }}
131132
run: |

tests/namedtempfile.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,23 +321,31 @@ fn test_write_after_close() {
321321
}
322322

323323
#[test]
324-
#[cfg_attr(target_os = "wasi", ignore = "env::temp_dir is not supported")]
325324
fn test_change_dir() {
326-
std::env::set_current_dir(env::temp_dir()).unwrap();
325+
configure_wasi_temp_dir();
326+
327+
let dir_a = tempdir().unwrap();
328+
let dir_b = tempdir().unwrap();
329+
330+
std::env::set_current_dir(&dir_a).expect("failed to change to directory ~");
327331
let tmpfile = NamedTempFile::new_in(".").unwrap();
328332
let path = std::env::current_dir().unwrap().join(tmpfile.path());
329-
std::env::set_current_dir("/").unwrap();
333+
std::env::set_current_dir(&dir_b).expect("failed to change to directory B");
330334
drop(tmpfile);
331335
assert!(!exists(path))
332336
}
333337

334338
#[test]
335-
#[cfg_attr(target_os = "wasi", ignore = "env::temp_dir is not supported")]
336339
fn test_change_dir_make() {
337-
std::env::set_current_dir(env::temp_dir()).unwrap();
340+
configure_wasi_temp_dir();
341+
342+
let dir_a = tempdir().unwrap();
343+
let dir_b = tempdir().unwrap();
344+
345+
std::env::set_current_dir(&dir_a).expect("failed to change to directory A");
338346
let tmpfile = Builder::new().make_in(".", |p| File::create(p)).unwrap();
339347
let path = std::env::current_dir().unwrap().join(tmpfile.path());
340-
std::env::set_current_dir("/").unwrap();
348+
std::env::set_current_dir(&dir_b).expect("failed to change to directory B");
341349
drop(tmpfile);
342350
assert!(!exists(path))
343351
}

0 commit comments

Comments
 (0)