Skip to content

Commit af78ce0

Browse files
Move retry loop into run_task itself
1 parent b0abe1c commit af78ce0

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

src/runner/worker.rs

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,51 @@ impl<'a, DB: WriteResults + Sync> Worker<'a, DB> {
6565
fn run_task(&self, task: &Task) -> Result<(), (failure::Error, TestResult)> {
6666
info!("running task: {:?}", task);
6767

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();
7073

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+
}
79113
if let Err(e) = res {
80114
error!("task {:?} failed", task);
81115
utils::report_failure(&e);
@@ -173,40 +207,7 @@ impl<'a, DB: WriteResults + Sync> Worker<'a, DB> {
173207
let mut result = Ok(());
174208
for task in tasks {
175209
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);
210211
}
211212
if let Err((err, test_result)) = &result {
212213
if let Err(e) = task.mark_as_failed(

0 commit comments

Comments
 (0)