Skip to content

Commit 3b6f0ec

Browse files
committed
Enable remove-dir-all-race test on Windows
1 parent bb9d5c4 commit 3b6f0ec

File tree

1 file changed

+11
-13
lines changed
  • tests/run-make/remove-dir-all-race

1 file changed

+11
-13
lines changed

tests/run-make/remove-dir-all-race/rmake.rs

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
//@ ignore-windows
2-
31
// This test attempts to make sure that running `remove_dir_all`
42
// doesn't result in a NotFound error one of the files it
53
// is deleting is deleted concurrently.
6-
//
7-
// The windows implementation for `remove_dir_all` is significantly
8-
// more complicated, and has not yet been brought up to par with
9-
// the implementation on other platforms, so this test is marked as
10-
// `ignore-windows` until someone more expirenced with windows can
11-
// sort that out.
124

135
use std::fs::remove_dir_all;
146
use std::path::Path;
15-
use std::thread;
167
use std::time::Duration;
8+
use std::{io, thread};
179

1810
use run_make_support::rfs::{create_dir, write};
1911
use run_make_support::run_in_tmpdir;
@@ -29,15 +21,21 @@ fn main() {
2921
thread::scope(|scope| {
3022
let t1 = scope.spawn(|| {
3123
thread::sleep(Duration::from_nanos(i));
32-
remove_dir_all("outer").unwrap();
24+
if let Err(e) = remove_dir_all("outer") {
25+
if e.kind() == io::ErrorKind::NotFound {
26+
panic!("file not found");
27+
}
28+
}
3329
});
3430

3531
let race_happened_ref = &race_happened;
3632
let t2 = scope.spawn(|| {
3733
let r1 = remove_dir_all("outer/inner");
3834
let r2 = remove_dir_all("outer/inner.txt");
39-
if r1.is_ok() && r2.is_err() {
40-
race_happened = true;
35+
if let Err(e) = r2 {
36+
if r1.is_ok() && e.kind() == io::ErrorKind::NotFound {
37+
race_happened = true;
38+
}
4139
}
4240
});
4341
});
@@ -49,7 +47,7 @@ fn main() {
4947
let Err(err) = remove_dir_all("outer") else {
5048
panic!("removing nonexistant dir did not result in an error");
5149
};
52-
assert_eq!(err.kind(), std::io::ErrorKind::NotFound);
50+
assert_eq!(err.kind(), io::ErrorKind::NotFound);
5351
}
5452
});
5553
if !race_happened {

0 commit comments

Comments
 (0)