mirror of
https://github.com/openai/codex.git
synced 2026-11-30 23:40:08 +00:00
Fixed a flaky Windows test that is consistently causing a CI failure (#10987)
Loop wait_for_complete/wait_for_updates_at_least until deadline to prevent Windows CI false timeouts in query-change session tests.
This commit is contained in:
1 parent
10336068db
commit
16e7cf05d2
1 file changed
+35
-10
@@ -681,13 +681,41 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RecordingReporter {
|
impl RecordingReporter {
|
||||||
fn wait_for_complete(&self, timeout: Duration) -> bool {
|
fn wait_until<T, F>(
|
||||||
let completes = self.complete_times.lock().unwrap();
|
&self,
|
||||||
if !completes.is_empty() {
|
mutex: &Mutex<T>,
|
||||||
|
cv: &Condvar,
|
||||||
|
timeout: Duration,
|
||||||
|
mut predicate: F,
|
||||||
|
) -> bool
|
||||||
|
where
|
||||||
|
F: FnMut(&T) -> bool,
|
||||||
|
{
|
||||||
|
let deadline = Instant::now() + timeout;
|
||||||
|
let mut state = mutex.lock().unwrap();
|
||||||
|
loop {
|
||||||
|
if predicate(&state) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let (completes, _) = self.complete_cv.wait_timeout(completes, timeout).unwrap();
|
let remaining = deadline.saturating_duration_since(Instant::now());
|
||||||
!completes.is_empty()
|
if remaining.is_zero() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let (next_state, wait_result) = cv.wait_timeout(state, remaining).unwrap();
|
||||||
|
state = next_state;
|
||||||
|
if wait_result.timed_out() {
|
||||||
|
return predicate(&state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn wait_for_complete(&self, timeout: Duration) -> bool {
|
||||||
|
self.wait_until(
|
||||||
|
&self.complete_times,
|
||||||
|
&self.complete_cv,
|
||||||
|
timeout,
|
||||||
|
|completes| !completes.is_empty(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
self.updates.lock().unwrap().clear();
|
self.updates.lock().unwrap().clear();
|
||||||
@@ -699,12 +727,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn wait_for_updates_at_least(&self, min_len: usize, timeout: Duration) -> bool {
|
fn wait_for_updates_at_least(&self, min_len: usize, timeout: Duration) -> bool {
|
||||||
let updates = self.updates.lock().unwrap();
|
self.wait_until(&self.updates, &self.update_cv, timeout, |updates| {
|
||||||
if updates.len() >= min_len {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
let (updates, _) = self.update_cv.wait_timeout(updates, timeout).unwrap();
|
|
||||||
updates.len() >= min_len
|
updates.len() >= min_len
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot(&self) -> FileSearchSnapshot {
|
fn snapshot(&self) -> FileSearchSnapshot {
|
||||||
|
|||||||
Reference in new issue
Block a user