Skip to content

Commit a04b4b6

Browse files
committed
create the required directories while gathering tests rather than during
parallel execution
1 parent 588d5d1 commit a04b4b6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/compiletest/compiletest.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,15 @@ fn collect_tests_from_dir(config: &Config,
299299
let file_path = file.path();
300300
debug!("inspecting file {:?}", file_path.display());
301301
if is_test(config, &file_path) {
302+
// If we find a test foo/bar.rs, we have to build the
303+
// output directory `$build/foo` so we can write
304+
// `$build/foo/bar` into it. We do this *now* in this
305+
// sequential loop because otherwise, if we do it in the
306+
// tests themselves, they race for the privilege of
307+
// creating the directories and sometimes fail randomly.
308+
let build_dir = config.build_base.join(&relative_dir_path);
309+
fs::create_dir_all(&build_dir).unwrap();
310+
302311
let paths = TestPaths {
303312
file: file_path,
304313
base: base.to_path_buf(),

0 commit comments

Comments
 (0)