Skip to content

Commit 0d95c08

Browse files
committed
Fix flaky test_on_exit_called_on_eof race condition in CI
1 parent 288fbd5 commit 0d95c08

File tree

1 file changed

+5
-1
lines changed
  • crates/codirigent-session/src

1 file changed

+5
-1
lines changed

crates/codirigent-session/src/pty.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,13 +1033,17 @@ mod tests {
10331033
.expect("timeout")
10341034
.expect("channel closed");
10351035
assert_eq!(&received, data);
1036-
assert!(chunk_called.load(Ordering::SeqCst), "on_chunk should fire");
10371036

10381037
// Wait for channel to close (reader thread hit EOF and exited)
10391038
while rx.recv().await.is_some() {}
10401039

10411040
// Give the thread a moment to run on_exit after the loop
10421041
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
1042+
1043+
// Check both flags after the thread has fully exited, since on_chunk
1044+
// is called *after* the channel send and may not have run yet when
1045+
// rx.recv() returns.
1046+
assert!(chunk_called.load(Ordering::SeqCst), "on_chunk should fire");
10431047
assert!(
10441048
exit_called.load(Ordering::SeqCst),
10451049
"on_exit should fire on EOF"

0 commit comments

Comments
 (0)