Skip to content

Commit cbeedc7

Browse files
committed
Remove the temporary directory when a check ends
1 parent 4c6caaa commit cbeedc7

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/bootstrap/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default-run = "bootstrap"
77

88
[features]
99
build-metrics = ["sysinfo"]
10-
tracing = ["dep:tracing", "dep:tracing-chrome", "dep:tracing-subscriber", "dep:chrono", "dep:tempfile"]
10+
tracing = ["dep:tracing", "dep:tracing-chrome", "dep:tracing-subscriber", "dep:chrono"]
1111

1212
[lib]
1313
path = "src/lib.rs"
@@ -64,7 +64,7 @@ chrono = { version = "0.4", default-features = false, optional = true, features
6464
tracing = { version = "0.1", optional = true, features = ["attributes"] }
6565
tracing-chrome = { version = "0.7", optional = true }
6666
tracing-subscriber = { version = "0.3", optional = true, features = ["env-filter", "fmt", "registry", "std"] }
67-
tempfile = { version = "3.15.0", optional = true }
67+
tempfile = { version = "3.15.0" }
6868

6969
[target.'cfg(windows)'.dependencies.junction]
7070
version = "1.3.0"
@@ -83,7 +83,6 @@ features = [
8383

8484
[dev-dependencies]
8585
pretty_assertions = "1.4"
86-
tempfile = "3.15.0"
8786
insta = "1.43"
8887

8988
# We care a lot about bootstrap's compile times, so don't include debuginfo for

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::path::{Path, PathBuf};
1010
use std::{env, fs, iter};
1111

1212
use build_helper::exit;
13+
use tempfile::TempDir;
1314

1415
use crate::core::build_steps::compile::{Std, run_cargo};
1516
use crate::core::build_steps::doc::{DocumentationFormat, prepare_doc_compiler};
@@ -3224,17 +3225,21 @@ impl Step for Distcheck {
32243225
fn run(self, builder: &Builder<'_>) {
32253226
// Use a temporary directory completely outside the current checkout, to avoid reusing any
32263227
// local source code, built artifacts or configuration by accident
3227-
let root_dir = std::env::temp_dir().join("distcheck");
3228+
let root_dir = TempDir::with_prefix("distcheck-").unwrap();
32283229

3229-
distcheck_plain_source_tarball(builder, &root_dir.join("distcheck-rustc-src"));
3230-
distcheck_rust_src(builder, &root_dir.join("distcheck-rust-src"));
3231-
distcheck_rustc_dev(builder, &root_dir.join("distcheck-rustc-dev"));
3230+
distcheck_plain_source_tarball(
3231+
builder,
3232+
TempDir::with_prefix_in("rustc-src-", &root_dir).unwrap(),
3233+
);
3234+
distcheck_rust_src(builder, TempDir::with_prefix_in("rust-src-", &root_dir).unwrap());
3235+
distcheck_rustc_dev(builder, TempDir::with_prefix_in("rustc-dev-", &root_dir).unwrap());
32323236
}
32333237
}
32343238

32353239
/// Check that we can build some basic things from the plain source tarball
3236-
fn distcheck_plain_source_tarball(builder: &Builder<'_>, plain_src_dir: &Path) {
3240+
fn distcheck_plain_source_tarball(builder: &Builder<'_>, plain_src_dir: TempDir) {
32373241
builder.info("Distcheck plain source tarball");
3242+
let plain_src_dir = plain_src_dir.path();
32383243
let plain_src_tarball = builder.ensure(dist::PlainSourceTarball);
32393244
builder.clear_dir(plain_src_dir);
32403245

@@ -3265,8 +3270,9 @@ fn distcheck_plain_source_tarball(builder: &Builder<'_>, plain_src_dir: &Path) {
32653270
}
32663271

32673272
/// Check that rust-src has all of libstd's dependencies
3268-
fn distcheck_rust_src(builder: &Builder<'_>, src_dir: &Path) {
3273+
fn distcheck_rust_src(builder: &Builder<'_>, src_dir: TempDir) {
32693274
builder.info("Distcheck rust-src");
3275+
let src_dir = src_dir.path();
32703276
let src_tarball = builder.ensure(dist::Src);
32713277
builder.clear_dir(src_dir);
32723278

@@ -3290,8 +3296,9 @@ fn distcheck_rust_src(builder: &Builder<'_>, src_dir: &Path) {
32903296
}
32913297

32923298
/// Check that rustc-dev's compiler crate source code can be loaded with `cargo metadata`
3293-
fn distcheck_rustc_dev(builder: &Builder<'_>, dir: &Path) {
3299+
fn distcheck_rustc_dev(builder: &Builder<'_>, dir: TempDir) {
32943300
builder.info("Distcheck rustc-dev");
3301+
let dir = dir.path();
32953302
let tarball = builder.ensure(dist::RustcDev::new(builder, builder.host_target)).unwrap();
32963303
builder.clear_dir(dir);
32973304

0 commit comments

Comments
 (0)