diff --git a/turbopack/crates/turbo-tasks-testing/src/lib.rs b/turbopack/crates/turbo-tasks-testing/src/lib.rs index 842e33e95f2c22..a27adfd2612c40 100644 --- a/turbopack/crates/turbo-tasks-testing/src/lib.rs +++ b/turbopack/crates/turbo-tasks-testing/src/lib.rs @@ -297,6 +297,10 @@ impl TurboTasksApi for VcStorage { ) -> std::pin::Pin> + Send + 'static>> { unimplemented!() } + + fn stop_and_wait(&self) -> std::pin::Pin + Send + 'static>> { + Box::pin(async {}) + } } impl VcStorage { diff --git a/turbopack/crates/turbo-tasks-testing/src/run.rs b/turbopack/crates/turbo-tasks-testing/src/run.rs index c01c52b2b4f3ae..cf7f8e8e785e8f 100644 --- a/turbopack/crates/turbo-tasks-testing/src/run.rs +++ b/turbopack/crates/turbo-tasks-testing/src/run.rs @@ -97,11 +97,13 @@ where println!("Run #1 (without cache)"); let first = run_once(tt.clone(), fut()).await?; println!("Run #2 (with memory cache, same TurboTasks instance)"); - let second = run_once(tt, fut()).await?; + let second = run_once(tt.clone(), fut()).await?; assert_eq!(first, second); + tt.stop_and_wait().await; let tt = registration.create_turbo_tasks(&name, false); println!("Run #3 (with persistent cache if available, new TurboTasks instance)"); let third = run_once(tt.clone(), fut()).await?; + tt.stop_and_wait().await; assert_eq!(first, third); Ok(()) } diff --git a/turbopack/crates/turbo-tasks/src/manager.rs b/turbopack/crates/turbo-tasks/src/manager.rs index 15de2eaa84b521..1bbd5087efa8c3 100644 --- a/turbopack/crates/turbo-tasks/src/manager.rs +++ b/turbopack/crates/turbo-tasks/src/manager.rs @@ -171,6 +171,8 @@ pub trait TurboTasksApi: TurboTasksCallApi + Sync + Send { &self, f: Pin> + Send + 'static>>, ) -> Pin> + Send + 'static>>; + + fn stop_and_wait(&self) -> Pin + Send>>; } /// A wrapper around a value that is unused. @@ -1335,6 +1337,13 @@ impl TurboTasksApi for TurboTasks { ), )) } + + fn stop_and_wait(&self) -> Pin + Send + 'static>> { + let this = self.pin(); + Box::pin(async move { + this.stop_and_wait().await; + }) + } } impl TurboTasksBackendApi for TurboTasks { @@ -1351,6 +1360,7 @@ impl TurboTasksBackendApi for TurboTasks { this.backend.run_backend_job(id, &*this).await; }) } + #[track_caller] fn schedule_backend_foreground_job(&self, id: BackendJobId) { self.schedule_foreground_job(move |this| async move {