diff --git a/crates/ide-host/tests/plugins.rs b/crates/ide-host/tests/plugins.rs index a308590de..7a56fa186 100644 --- a/crates/ide-host/tests/plugins.rs +++ b/crates/ide-host/tests/plugins.rs @@ -879,16 +879,15 @@ fn background_tasks_scale_and_renew_cpu_fuel_budget() { // Room for activation (about 3_100 on macOS, more on Windows). A background task gets ten // times it (5 s / 500 ms): enough for each step of `patient` with its CPU work (32_000 to // 80_000), not for the whole run without the refill on each report. - let f = fixture(Limits { + let limits = Limits { fuel: 40_000, timeout: Duration::from_millis(500), background: Duration::from_millis(5_000), ..Limits::default() - }); + }; + let f = fixture(limits); f.install(&misbehave_pkg()); - if f.host.set_capability("misbehave", "process:git", true).is_err() { - return; - } + f.host.set_capability("misbehave", "process:git", true).expect("grant Git capability"); // Warm up activation in its own call so `patient` starts with a fresh budget. assert_eq!(f.run("misbehave", "echo", Some("warm")).unwrap().as_deref(), Some("warm")); @@ -897,6 +896,13 @@ fn background_tasks_scale_and_renew_cpu_fuel_budget() { let err = f.run("misbehave", "spin", None).unwrap_err(); assert!(err.contains("exceeded its CPU budget (40000 fuel per call)"), "{err}"); + + // Beginning a task alone must not renew its scaled budget. + let quiet = fixture(limits); + quiet.install(&misbehave_pkg()); + quiet.host.set_capability("misbehave", "process:git", true).expect("grant Git capability"); + let err = quiet.run("misbehave", "patient", Some("quiet:4000")).unwrap_err(); + assert!(err.contains("exceeded its CPU budget (400000 fuel per call)"), "{err}"); } #[test] diff --git a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm index 4d4d16c8e..bbfe042d7 100644 Binary files a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources index aebb1b3fa..e61e879e1 100644 --- a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources @@ -1 +1 @@ -1056d650117bc2216ac518aa26b27cf898f58db62369ae285b9d8925ada74dff +b24fb8d5161006104698fb07a43432601b4f16fdc4a34cc70058cbef7e973066 diff --git a/crates/ide-plugin/tests/fixtures/misbehave/src/lib.rs b/crates/ide-plugin/tests/fixtures/misbehave/src/lib.rs index 3d08a535c..83799143e 100644 --- a/crates/ide-plugin/tests/fixtures/misbehave/src/lib.rs +++ b/crates/ide-plugin/tests/fixtures/misbehave/src/lib.rs @@ -181,9 +181,13 @@ impl commands::Guest for Misbehave { }; let child = process::start(&cmd, None)?; // CPU work per step (loop iterations), for fuel budget tests. - let work: u64 = arg.as_deref().and_then(|a| a.parse().ok()).unwrap_or(0); + let arg = arg.as_deref().unwrap_or(""); + let report = !arg.starts_with("quiet:"); + let work: u64 = arg.strip_prefix("quiet:").unwrap_or(arg).parse().unwrap_or(0); for step in 0..25 { - task.report(step, Some(25), Some("waiting")); + if report { + task.report(step, Some(25), Some("waiting")); + } let mut x: u64 = 0; for _ in 0..work { x = std::hint::black_box(x.wrapping_add(1)); @@ -195,7 +199,9 @@ impl commands::Guest for Misbehave { // Let it finish on its own: no kill, no slow teardown. child.close_stdin()?; let _ = child.wait(5_000); - task.report(25, Some(25), Some("done")); + if report { + task.report(25, Some(25), Some("done")); + } Ok(Some("still here".into())) } // `editor.write` is not granted: an error, not a trap.