From d0a23b17043a617698c729a3ba6885babfe7af32 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Wed, 4 Nov 2026 20:34:19 +0800 Subject: [PATCH] test(plugins): repeat the cancel until the call is running in the cancel test running_calls_can_be_cancelled cancelled once, 100 ms after starting the call. On a slow runner (Windows CI) the instance was still starting, so the cancel found nothing running and the call ran into its 30 s timeout. The test now repeats the cancel until the call ends, within 5 s. --- crates/ide-host/tests/plugins.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/ide-host/tests/plugins.rs b/crates/ide-host/tests/plugins.rs index fb592967..324add15 100644 --- a/crates/ide-host/tests/plugins.rs +++ b/crates/ide-host/tests/plugins.rs @@ -493,12 +493,15 @@ fn running_calls_can_be_cancelled() { let f = f.clone(); std::thread::spawn(move || f.run("misbehave", "spin", None)) }; - std::thread::sleep(Duration::from_millis(100)); - let started = Instant::now(); - f.host.cancel("misbehave"); + // A cancel before the call runs (the instance may still be starting) does nothing: repeat it. + let until = Instant::now() + Duration::from_secs(5); + while !spinning.is_finished() { + assert!(Instant::now() < until, "the running call wasn't interrupted"); + f.host.cancel("misbehave"); + std::thread::sleep(Duration::from_millis(20)); + } let err = spinning.join().unwrap().unwrap_err(); assert!(err.contains("was cancelled"), "{err}"); - assert!(started.elapsed() < Duration::from_secs(1)); assert_eq!(f.run("misbehave", "echo", Some("x")).unwrap().as_deref(), Some("x"), "no backoff"); let stats = f.host.info_of("misbehave").unwrap().stats; assert_eq!((stats.crashes, stats.activations), (0, 2));