1
1
use config:: Config ;
2
2
use crates:: Crate ;
3
+ use dirs;
3
4
use experiments:: Experiment ;
4
5
use failure:: AsFail ;
5
6
use prelude:: * ;
@@ -12,6 +13,7 @@ use utils;
12
13
13
14
pub ( super ) enum TaskStep {
14
15
Prepare ,
16
+ Cleanup ,
15
17
BuildAndTest { tc : Toolchain , quiet : bool } ,
16
18
BuildOnly { tc : Toolchain , quiet : bool } ,
17
19
CheckOnly { tc : Toolchain , quiet : bool } ,
@@ -23,6 +25,7 @@ impl fmt::Debug for TaskStep {
23
25
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
24
26
match * self {
25
27
TaskStep :: Prepare => write ! ( f, "prepare" ) ?,
28
+ TaskStep :: Cleanup => write ! ( f, "cleanup" ) ?,
26
29
TaskStep :: BuildAndTest { ref tc, quiet } => {
27
30
write ! ( f, "build and test {}" , tc. to_string( ) ) ?;
28
31
if quiet {
@@ -71,6 +74,7 @@ impl Task {
71
74
// If an error happens while checking if the task should be executed, the error is ignored
72
75
// and the function returns true.
73
76
match self . step {
77
+ TaskStep :: Cleanup => true ,
74
78
// The prepare step should always be executed.
75
79
// It will not be executed if all the dependent tasks are already executed, since the
76
80
// runner will not reach the prepare task in that case.
@@ -94,7 +98,7 @@ impl Task {
94
98
result : TestResult ,
95
99
) -> Fallible < ( ) > {
96
100
match self . step {
97
- TaskStep :: Prepare => { }
101
+ TaskStep :: Prepare | TaskStep :: Cleanup => { }
98
102
TaskStep :: BuildAndTest { ref tc, .. }
99
103
| TaskStep :: BuildOnly { ref tc, .. }
100
104
| TaskStep :: CheckOnly { ref tc, .. }
@@ -118,6 +122,13 @@ impl Task {
118
122
db : & DB ,
119
123
) -> Fallible < ( ) > {
120
124
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
+ }
121
132
TaskStep :: Prepare => {
122
133
let prepare = PrepareCrate :: new ( ex, & self . krate , config, db) ;
123
134
prepare. prepare ( )
0 commit comments