diff --git a/crates/librqbit/src/tests/e2e.rs b/crates/librqbit/src/tests/e2e.rs index 6c43556..ad7f844 100644 --- a/crates/librqbit/src/tests/e2e.rs +++ b/crates/librqbit/src/tests/e2e.rs @@ -23,7 +23,7 @@ use crate::{ #[tokio::test(flavor = "multi_thread", worker_threads = 64)] async fn test_e2e_download() { - wait_until_i_am_the_last_task().await.unwrap(); + let dbg_srv = spawn_debug_server(); let timeout = std::env::var("E2E_TIMEOUT") .ok() @@ -39,6 +39,8 @@ async fn test_e2e_download() { .context("test_e2e_download timed out") .unwrap(); + dbg_srv.abort(); + // Wait to ensure everything is dropped. wait_until_i_am_the_last_task().await.unwrap(); @@ -52,8 +54,6 @@ async fn _test_e2e_download(drop_checks: &DropChecks) { Err(e) => error!(error=?e, "error increasing ulimit"), }; - spawn_debug_server(); - // 1. Create a torrent // Ideally (for a more complicated test) with N files, and at least N pieces that span 2 files. diff --git a/crates/librqbit/src/tests/test_util.rs b/crates/librqbit/src/tests/test_util.rs index f454ccd..c576432 100644 --- a/crates/librqbit/src/tests/test_util.rs +++ b/crates/librqbit/src/tests/test_util.rs @@ -134,8 +134,8 @@ async fn debug_server() -> anyhow::Result<()> { Ok(()) } -pub fn spawn_debug_server() { - tokio::spawn(debug_server()); +pub fn spawn_debug_server() -> tokio::task::JoinHandle> { + tokio::spawn(debug_server()) } pub trait DropPlaceholder: Send + Sync {}