Skip to content

Commit 3c29590

Browse files
committed
runner: cleanup source directories after a crate finishes being tested
1 parent 7ff839c commit 3c29590

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/runner/graph.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,15 @@ pub(super) fn build_graph(ex: &Experiment, config: &Config) -> TasksGraph {
270270
builds.push(build_id);
271271
}
272272

273-
graph.add_crate(&builds);
273+
let cleanup_id = graph.add_task(
274+
Task {
275+
krate: krate.clone(),
276+
step: TaskStep::Cleanup,
277+
},
278+
&builds,
279+
);
280+
281+
graph.add_crate(&[cleanup_id]);
274282
}
275283

276284
graph

src/runner/tasks.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use config::Config;
22
use crates::Crate;
3+
use dirs;
34
use experiments::Experiment;
45
use failure::AsFail;
56
use prelude::*;
@@ -12,6 +13,7 @@ use utils;
1213

1314
pub(super) enum TaskStep {
1415
Prepare,
16+
Cleanup,
1517
BuildAndTest { tc: Toolchain, quiet: bool },
1618
BuildOnly { tc: Toolchain, quiet: bool },
1719
CheckOnly { tc: Toolchain, quiet: bool },
@@ -23,6 +25,7 @@ impl fmt::Debug for TaskStep {
2325
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2426
match *self {
2527
TaskStep::Prepare => write!(f, "prepare")?,
28+
TaskStep::Cleanup => write!(f, "cleanup")?,
2629
TaskStep::BuildAndTest { ref tc, quiet } => {
2730
write!(f, "build and test {}", tc.to_string())?;
2831
if quiet {
@@ -71,6 +74,7 @@ impl Task {
7174
// If an error happens while checking if the task should be executed, the error is ignored
7275
// and the function returns true.
7376
match self.step {
77+
TaskStep::Cleanup => true,
7478
// The prepare step should always be executed.
7579
// It will not be executed if all the dependent tasks are already executed, since the
7680
// runner will not reach the prepare task in that case.
@@ -94,7 +98,7 @@ impl Task {
9498
result: TestResult,
9599
) -> Fallible<()> {
96100
match self.step {
97-
TaskStep::Prepare => {}
101+
TaskStep::Prepare | TaskStep::Cleanup => {}
98102
TaskStep::BuildAndTest { ref tc, .. }
99103
| TaskStep::BuildOnly { ref tc, .. }
100104
| TaskStep::CheckOnly { ref tc, .. }
@@ -118,6 +122,13 @@ impl Task {
118122
db: &DB,
119123
) -> Fallible<()> {
120124
match self.step {
125+
TaskStep::Cleanup => {
126+
// Ensure source directories are cleaned up
127+
for tc in &ex.toolchains {
128+
let _ = utils::fs::remove_dir_all(&dirs::crate_source_dir(ex, tc, &self.krate));
129+
}
130+
Ok(())
131+
}
121132
TaskStep::Prepare => {
122133
let prepare = PrepareCrate::new(ex, &self.krate, config, db);
123134
prepare.prepare()

0 commit comments

Comments
 (0)