Skip to content

Commit

Permalink
test: fix windows test
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Sep 2, 2024
1 parent 5a9cdd4 commit c8b8ec1
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions tests/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,31 +552,46 @@ async fn extracting_malicious_tarball() {
// The `tmp` subdirectory should be created and within this
// subdirectory, there should be files named `abs_evil.txt` through
// `abs_evil6.txt`.
assert!(fs::metadata(td.path().join("tmp"))
let tmp_root = td.path().join("tmp");

assert!(fs::metadata(&tmp_root)
.await
.map(|m| m.is_dir())
.unwrap_or(false));
assert!(fs::metadata(td.path().join("tmp/abs_evil.txt"))

let mut entries = fs::read_dir(&tmp_root).await.unwrap();
while let Some(entry) = entries.next().await {
let entry = entry.unwrap();
println!("- {:?}", entry.file_name());
}

assert!(fs::metadata(tmp_root.join("abs_evil.txt"))
.await
.map(|m| m.is_file())
.unwrap_or(false));
assert!(fs::metadata(td.path().join("tmp/abs_evil2.txt"))

// not present due to // being interpreted differently on windows
#[cfg(not(target_os = "windows"))]
assert!(fs::metadata(tmp_root.join("abs_evil2.txt"))
.await
.map(|m| m.is_file())
.unwrap_or(false));
assert!(fs::metadata(td.path().join("tmp/abs_evil3.txt"))
assert!(fs::metadata(tmp_root.join("abs_evil3.txt"))
.await
.map(|m| m.is_file())
.unwrap_or(false));
assert!(fs::metadata(td.path().join("tmp/abs_evil4.txt"))
assert!(fs::metadata(tmp_root.join("abs_evil4.txt"))
.await
.map(|m| m.is_file())
.unwrap_or(false));
assert!(fs::metadata(td.path().join("tmp/abs_evil5.txt"))

// not present due to // being interpreted differently on windows
#[cfg(not(target_os = "windows"))]
assert!(fs::metadata(tmp_root.join("abs_evil5.txt"))
.await
.map(|m| m.is_file())
.unwrap_or(false));
assert!(fs::metadata(td.path().join("tmp/abs_evil6.txt"))
assert!(fs::metadata(tmp_root.join("abs_evil6.txt"))
.await
.map(|m| m.is_file())
.unwrap_or(false));
Expand Down

0 comments on commit c8b8ec1

Please sign in to comment.