@@ -65,17 +65,51 @@ impl<'a, DB: WriteResults + Sync> Worker<'a, DB> {
65
65
fn run_task ( & self , task : & Task ) -> Result < ( ) , ( failure:: Error , TestResult ) > {
66
66
info ! ( "running task: {:?}" , task) ;
67
67
68
- // If we're running a task, we call ourselves healthy.
69
- crate :: agent:: set_healthy ( ) ;
68
+ let mut res = Ok ( ( ) ) ;
69
+ let max_attempts = 5 ;
70
+ for run in 1 ..=max_attempts {
71
+ // If we're running a task, we call ourselves healthy.
72
+ crate :: agent:: set_healthy ( ) ;
70
73
71
- let res = task. run (
72
- self . config ,
73
- self . workspace ,
74
- & self . build_dir ,
75
- self . ex ,
76
- self . db ,
77
- self . state ,
78
- ) ;
74
+ res = task. run (
75
+ self . config ,
76
+ self . workspace ,
77
+ & self . build_dir ,
78
+ self . ex ,
79
+ self . db ,
80
+ self . state ,
81
+ ) ;
82
+
83
+ // We retry task failing on the second toolchain (i.e., regressions). In
84
+ // the future we might expand this list further but for now this helps
85
+ // prevent spurious test failures and such.
86
+ //
87
+ // For now we make no distinction between build failures and test failures
88
+ // here, but that may change if this proves too slow.
89
+ let mut should_retry = false ;
90
+ if res. is_err ( ) && self . ex . toolchains . len ( ) == 2 {
91
+ let toolchain = match & task. step {
92
+ TaskStep :: Prepare | TaskStep :: Cleanup => None ,
93
+ TaskStep :: Skip { tc }
94
+ | TaskStep :: BuildAndTest { tc, .. }
95
+ | TaskStep :: BuildOnly { tc, .. }
96
+ | TaskStep :: CheckOnly { tc, .. }
97
+ | TaskStep :: Clippy { tc, .. }
98
+ | TaskStep :: Rustdoc { tc, .. }
99
+ | TaskStep :: UnstableFeatures { tc } => Some ( tc) ,
100
+ } ;
101
+ if let Some ( toolchain) = toolchain {
102
+ if toolchain == self . ex . toolchains . last ( ) . unwrap ( ) {
103
+ should_retry = true ;
104
+ }
105
+ }
106
+ }
107
+ if !should_retry {
108
+ break ;
109
+ }
110
+
111
+ log:: info!( "Retrying task {:?} [{run}/{max_attempts}]" , task) ;
112
+ }
79
113
if let Err ( e) = res {
80
114
error ! ( "task {:?} failed" , task) ;
81
115
utils:: report_failure ( & e) ;
@@ -173,40 +207,7 @@ impl<'a, DB: WriteResults + Sync> Worker<'a, DB> {
173
207
let mut result = Ok ( ( ) ) ;
174
208
for task in tasks {
175
209
if result. is_ok ( ) {
176
- let max_attempts = 5 ;
177
- for run in 1 ..=max_attempts {
178
- result = self . run_task ( & task) ;
179
-
180
- // We retry task failing on the second toolchain (i.e., regressions). In
181
- // the future we might expand this list further but for now this helps
182
- // prevent spurious test failures and such.
183
- //
184
- // For now we make no distinction between build failures and test failures
185
- // here, but that may change if this proves too slow.
186
- let mut should_retry = false ;
187
- if result. is_err ( ) && self . ex . toolchains . len ( ) == 2 {
188
- let toolchain = match & task. step {
189
- TaskStep :: Prepare | TaskStep :: Cleanup => None ,
190
- TaskStep :: Skip { tc }
191
- | TaskStep :: BuildAndTest { tc, .. }
192
- | TaskStep :: BuildOnly { tc, .. }
193
- | TaskStep :: CheckOnly { tc, .. }
194
- | TaskStep :: Clippy { tc, .. }
195
- | TaskStep :: Rustdoc { tc, .. }
196
- | TaskStep :: UnstableFeatures { tc } => Some ( tc) ,
197
- } ;
198
- if let Some ( toolchain) = toolchain {
199
- if toolchain == self . ex . toolchains . last ( ) . unwrap ( ) {
200
- should_retry = true ;
201
- }
202
- }
203
- }
204
- if !should_retry {
205
- break ;
206
- }
207
-
208
- log:: info!( "Retrying task {:?} [{run}/{max_attempts}]" , task) ;
209
- }
210
+ result = self . run_task ( & task) ;
210
211
}
211
212
if let Err ( ( err, test_result) ) = & result {
212
213
if let Err ( e) = task. mark_as_failed (
0 commit comments