1
- //@ ignore-windows
2
-
3
1
// This test attempts to make sure that running `remove_dir_all`
4
2
// doesn't result in a NotFound error one of the files it
5
3
// 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.
12
4
13
5
use std:: fs:: remove_dir_all;
14
6
use std:: path:: Path ;
15
- use std:: thread;
16
7
use std:: time:: Duration ;
8
+ use std:: { io, thread} ;
17
9
18
10
use run_make_support:: rfs:: { create_dir, write} ;
19
11
use run_make_support:: run_in_tmpdir;
@@ -29,15 +21,21 @@ fn main() {
29
21
thread:: scope ( |scope| {
30
22
let t1 = scope. spawn ( || {
31
23
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
+ }
33
29
} ) ;
34
30
35
31
let race_happened_ref = & race_happened;
36
32
let t2 = scope. spawn ( || {
37
33
let r1 = remove_dir_all ( "outer/inner" ) ;
38
34
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
+ }
41
39
}
42
40
} ) ;
43
41
} ) ;
@@ -49,7 +47,7 @@ fn main() {
49
47
let Err ( err) = remove_dir_all ( "outer" ) else {
50
48
panic ! ( "removing nonexistant dir did not result in an error" ) ;
51
49
} ;
52
- assert_eq ! ( err. kind( ) , std :: io:: ErrorKind :: NotFound ) ;
50
+ assert_eq ! ( err. kind( ) , io:: ErrorKind :: NotFound ) ;
53
51
}
54
52
} ) ;
55
53
if !race_happened {
0 commit comments