Skip to content

Commit cdfaf69

Browse files
authored
Rollup merge of rust-lang#111561 - dtolnay:compiletestdirexists, r=Mark-Simulacrum
Include better context for "already exists" error in compiletest I encountered the following error from `x.py test tests/ui` today. ```console ---- [ui] tests/ui/impl-trait/multiple-lifetimes/multiple-lifetimes.rs stdout ---- thread '[ui] tests/ui/impl-trait/multiple-lifetimes/multiple-lifetimes.rs' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 17, kind: AlreadyExists, message: "File exists" }', src/tools/compiletest/src/runtest.rs:134:43 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` I found it impossible to unblock myself without knowing which directory it was stuck on. Error message after this PR: ```console ---- [ui] tests/ui/impl-trait/multiple-lifetimes/multiple-lifetimes.rs stdout ---- thread '[ui] tests/ui/impl-trait/multiple-lifetimes/multiple-lifetimes.rs' panicked at 'called `Result::unwrap()` on an `Err` value: failed to create output base directory /git/rust/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/multiple-lifetimes/multiple-lifetimes Caused by: File exists (os error 17)', src/tools/compiletest/src/runtest.rs:139:10 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` Now I was able to run `rm build/x86_64-unknown-linux-gnu/test/ui/impl-trait/multiple-lifetimes/multiple-lifetimes` and unblock myself. Seems to be related to rust-lang#109509 moving *tests/ui/impl-trait/multiple-lifetimes.rs* to *tests/ui/impl-trait/multiple-lifetimes/multiple-lifetimes.rs*.
2 parents f9bbd23 + 6b7b775 commit cdfaf69

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ dependencies = [
723723
name = "compiletest"
724724
version = "0.0.0"
725725
dependencies = [
726+
"anyhow",
726727
"build_helper",
727728
"colored",
728729
"diff",

src/tools/compiletest/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ once_cell = "1.16.0"
2020
walkdir = "2"
2121
glob = "0.3.0"
2222
lazycell = "1.3.0"
23+
anyhow = "1"
2324

2425
[target.'cfg(unix)'.dependencies]
2526
libc = "0.2"

src/tools/compiletest/src/runtest.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use std::process::{Child, Command, ExitStatus, Output, Stdio};
3232
use std::str;
3333
use std::sync::Arc;
3434

35+
use anyhow::Context;
3536
use glob::glob;
3637
use once_cell::sync::Lazy;
3738
use tracing::*;
@@ -131,7 +132,11 @@ pub fn run(config: Arc<Config>, testpaths: &TestPaths, revision: Option<&str>) {
131132
}
132133

133134
let cx = TestCx { config: &config, props: &props, testpaths, revision };
134-
create_dir_all(&cx.output_base_dir()).unwrap();
135+
create_dir_all(&cx.output_base_dir())
136+
.with_context(|| {
137+
format!("failed to create output base directory {}", cx.output_base_dir().display())
138+
})
139+
.unwrap();
135140
if props.incremental {
136141
cx.init_incremental_test();
137142
}

0 commit comments

Comments
 (0)