From 48e23c012f67624255c2bdbd083643add8aec85b Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Wed, 4 Nov 2026 17:26:25 +0800 Subject: [PATCH] test(plugins): time only the restart wait in the crash backoff test The waits included the restart that ended them, and instantiating the plugin can take a few hundred milliseconds on CI, so a slow second restart made the third wait look no longer. Measure until the call that is let through and require the third wait to exceed the second by half the base backoff. --- crates/ide-host/tests/plugins.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/ide-host/tests/plugins.rs b/crates/ide-host/tests/plugins.rs index f4d361f9..4cd91559 100644 --- a/crates/ide-host/tests/plugins.rs +++ b/crates/ide-host/tests/plugins.rs @@ -399,19 +399,24 @@ fn crashes_restart_with_backoff_until_the_circuit_opens() { // Three in a row: stopped for the session, with growing waits between. f.take_events(); + // How long each crash kept the next call waiting, without the restart itself, whose + // instantiation time varies a lot on CI. let mut waits = Vec::new(); for _ in 0..3 { let started = Instant::now(); let err = loop { + let attempt = Instant::now(); match f.run("misbehave", "panic", None) { Err(e) if e.contains("restarts in") => std::thread::sleep(Duration::from_millis(20)), - other => break other.unwrap_err(), + other => { + waits.push(attempt - started); + break other.unwrap_err(); + } } }; assert!(err.contains("crashed"), "{err}"); - waits.push(started.elapsed()); } - assert!(waits[2] >= backoff * 2 && waits[2] > waits[1], "{waits:?}"); + assert!(waits[1] >= backoff / 2 && waits[2] > waits[1] + backoff / 2, "the wait doubles: {waits:?}"); let info = f.host.info_of("misbehave").unwrap(); assert_eq!(info.status, PluginStatus::Failed); assert!(info.error.as_deref().is_some_and(|e| e.contains("3 times in a row")), "{:?}", info.error);