fix(plugins): give test selection the command budget (#2258)

* fix(plugins): give test selection the command budget

* test(plugins): bound test selection timeouts by the command budget
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-09 12:21:32 +08:00
1 джерело d17f6755f3
коміт f8e15a7980
3 files changed
+9 -6

No files matched your search

+4 -3
Переглянути файл
@@ -301,7 +301,7 @@ impl PluginHost {
Ok(Some((root, owner.to_owned(), id.to_owned())))
}
/// Derives replacement argv under the parser's soft/hard call budgets.
/// Derives replacement argv for a user action, under the command budget.
pub fn select_tests(&self, client: &str, config: &str, tests: Vec<Vec<String>>) -> IdeResult<Option<Vec<String>>> {
if tests.is_empty()
|| tests.len() > 10000
@@ -317,9 +317,10 @@ impl PluginHost {
self.changed();
}
let invocation = ide_plugin::Invocation { workspace_root: Some(root), ..Default::default() };
let hard = self.limits.edit_hard;
// A user action, not the edit path: allow the command budget (a cold instance may be compiling).
let timeout = self.limits.timeout;
let started = Instant::now();
let result = actor.call(Some(self.limits.edit_soft), move |rt| rt.select_tests(id, tests, invocation, hard));
let result = actor.call(Some(timeout), move |rt| rt.select_tests(id, tests, invocation, timeout));
let args = self.finish_provider_call(&plugin, &actor, started, result).flatten();
Ok(args.filter(|args| args.len() <= 10000 && args.iter().map(String::len).sum::<usize>() <= 4 << 20))
}
+2 -1
Переглянути файл
@@ -6058,7 +6058,8 @@ fn api14_test_selection_traps_and_timeouts_are_unsupported() {
f.host.refresh_run_configurations(&f.project);
let started = Instant::now();
assert_eq!(f.host.select_tests("main", "plugin:execution:dynamic", vec![vec![failure.into()]]).unwrap(), None);
assert!(started.elapsed() < Duration::from_secs(5));
// Selection is a user action: bounded by the command budget, not the edit path.
assert!(started.elapsed() < Limits::default().timeout + Duration::from_secs(2));
}
}
+3 -2
Переглянути файл
@@ -2389,8 +2389,9 @@ A plugin using `framework = "plugin"` can implement `TestResults::select_tests`
configuration id as `parse` and a list of test-tree paths: the names from the
plugin's `test-start` events, from parent suite to test, exactly as shown in the
tree. Return the **full replacement argument list**, including any required base
arguments, to run only those tests. `None` (the Rust SDK default), errors and
call timeouts leave test selection unsupported. An empty argument list is a
arguments, to run only those tests. The call uses the 5-second command budget.
`None` (the Rust SDK default), errors and call timeouts leave test selection
unsupported. An empty argument list is a
supported selection. The IDE preserves the configuration's command, environment,
working directory and run target.