Skip to content

Commit e9f2466

Browse files
committed
add unit test
1 parent 9dc0098 commit e9f2466

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
}

0 commit comments

Comments
 (0)