Skip to content

Commit

Permalink
Blocking mpsc channel for background tasks in e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Oct 8, 2024
1 parent 7906be7 commit be9f0fa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/tests/src/e2e/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::{Path, PathBuf};
use std::process::Command;
use std::str::FromStr;
use std::sync::Once;
use std::time::{SystemTime, UNIX_EPOCH};
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use std::{env, fs, thread, time};

use assert_cmd::assert::OutputAssertExt;
Expand Down Expand Up @@ -909,17 +909,18 @@ impl NamadaCmd {
let join_handle = std::thread::spawn(move || {
let mut cmd = self;
loop {
match abort_recv.try_recv() {
match abort_recv.recv_timeout(Duration::from_secs(60)) {
Ok(ControlCode::EndOfText) => {
// Terminate the background task by dropping the
// corresponding NamadaCmd
return None;
}
Ok(ControlCode::Enquiry)
| Err(std::sync::mpsc::TryRecvError::Disconnected) => {
| Err(std::sync::mpsc::RecvTimeoutError::Disconnected) => {
return Some(cmd);
}
Ok(_) | Err(std::sync::mpsc::TryRecvError::Empty) => {}
Ok(_) | Err(std::sync::mpsc::RecvTimeoutError::Timeout) => {
}
}
cmd.session.is_matched(Eof).unwrap();
}
Expand Down

0 comments on commit be9f0fa

Please sign in to comment.