File tree 1 file changed +36
-0
lines changed
src/test/ui/stdlib-unit-tests 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ // run-pass
2
+
3
+ use std:: env:: { current_dir, set_current_dir} ;
4
+ use std:: fs:: { create_dir, remove_dir_all, File } ;
5
+ use std:: path:: Path ;
6
+
7
+ pub fn main ( ) {
8
+ let saved_cwd = current_dir ( ) . unwrap ( ) ;
9
+ if !Path :: exists ( Path :: new ( "tmpdir" ) ) {
10
+ create_dir ( "tmpdir" ) . unwrap ( ) ;
11
+ }
12
+ set_current_dir ( "tmpdir" ) . unwrap ( ) ;
13
+ let depth = if cfg ! ( target_os = "linux" ) {
14
+ // Should work on all Linux filesystems.
15
+ 4096
16
+ } else if cfg ! ( target_os = "macos" ) {
17
+ // On Macos increasing depth leads to a superlinear slowdown.
18
+ 1024
19
+ } else if cfg ! ( unix) {
20
+ // Should be no problem on other UNIXes either.
21
+ 1024
22
+ } else {
23
+ // "Safe" fallback for other platforms.
24
+ 64
25
+ } ;
26
+ for _ in 0 ..depth {
27
+ if !Path :: exists ( Path :: new ( "a" ) ) {
28
+ create_dir ( "empty_dir" ) . unwrap ( ) ;
29
+ File :: create ( "empty_file" ) . unwrap ( ) ;
30
+ create_dir ( "a" ) . unwrap ( ) ;
31
+ }
32
+ set_current_dir ( "a" ) . unwrap ( ) ;
33
+ }
34
+ set_current_dir ( saved_cwd) . unwrap ( ) ;
35
+ remove_dir_all ( "tmpdir" ) . unwrap ( ) ;
36
+ }
You can’t perform that action at this time.
0 commit comments