mod common; use ide_core::{CancellationToken, Diagnostic, Pos, Range, Severity}; use ide_host::plugins::{HostWorkspace, PluginWorkspace}; use ide_host::{Host, HostConfig}; use ide_plugin::TextQuery; use std::path::PathBuf; use std::sync::Arc; struct Harness { host: Arc, root: PathBuf, _tmp: tempfile::TempDir, } impl Harness { fn new() -> Self { let tmp = tempfile::tempdir().unwrap(); let root = dunce::canonicalize(tmp.path()).unwrap().join("project"); std::fs::create_dir_all(&root).unwrap(); let host = Arc::new(Host::new(HostConfig { local_data_dir: tmp.path().join("local"), ..common::host_config(tmp.path()) })); host.open_project("main", &root).unwrap(); host.open_project("second", &root).unwrap(); Self { host, root, _tmp: tmp } } fn workspace(&self) -> HostWorkspace { HostWorkspace(Arc::downgrade(&self.host)) } } #[tokio::test(flavor = "multi_thread")] async fn window_editor_reports_use_document_language_dirty_state_and_focus() { let f = Harness::new(); let path = f.root.join("main.rs"); std::fs::write(&path, "fn main() {}\n").unwrap(); let p = f.host.project("main").unwrap(); let doc = p.documents.open(&path).unwrap(); p.documents .apply_edits(doc.id, &[ide_core::TextEdit { range: Range::default(), new_text: "// unsaved\n".into() }]) .unwrap(); f.host.mcp_reports.set_open_editors("main", vec![path.clone()]); f.host.mcp_reports.set_focused_editor( "main", Some(ide_host::mcp::FocusedEditor { path: path.clone().into(), selection: Range::default(), selected_text: String::new(), }), true, ); let workspace = f.workspace(); let editors = workspace.open_editors("main").unwrap(); assert_eq!(editors.len(), 1); assert!(editors[0].dirty && editors[0].active); assert_eq!(editors[0].language, "rust"); assert!(workspace.open_editors("second").unwrap().is_empty()); let second = f.host.project("second").unwrap(); second.documents.open(&path).unwrap(); f.host.mcp_reports.set_open_editors("second", vec![path.clone()]); assert!(!workspace.open_editors("second").unwrap()[0].dirty); assert!(workspace.open_editors("main").unwrap()[0].dirty); assert!(workspace.buffer_text_in(Some("main"), &path).unwrap().contains("unsaved")); assert!(!workspace.buffer_text_in(Some("second"), &path).unwrap().contains("unsaved")); assert_ne!(workspace.document_in("main", &path), workspace.document_in("second", &path)); f.host.mcp_reports.forget_window("main"); assert!(workspace.open_editors("main").unwrap().is_empty()); } #[tokio::test(flavor = "multi_thread")] async fn text_search_uses_overlay_excludes_utf16_and_limits() { let f = Harness::new(); let path = f.root.join("a.txt"); std::fs::write(&path, "disk\n").unwrap(); std::fs::create_dir(f.root.join("target")).unwrap(); std::fs::write(f.root.join("target/ignored.txt"), "needle").unwrap(); let p = f.host.project("main").unwrap(); p.settings .set(ide_workspace::settings::SettingsScope::Project, "files.ignoredNames", serde_json::json!(["target"])) .unwrap(); let doc = p.documents.open(&path).unwrap(); p.documents .apply_edits(doc.id, &[ide_core::TextEdit { range: Range::default(), new_text: "😀needle\nneedle\n".into() }]) .unwrap(); f.host.project("second").unwrap().documents.open(&path).unwrap(); let workspace = f.workspace(); let query = TextQuery { pattern: "needle".into(), case_sensitive: true, ..Default::default() }; let found = workspace.search_text(Some("main"), &f.root, query.clone(), 10, &CancellationToken::new()).unwrap(); assert_eq!(found.matches.len(), 2, "{found:?}; text={:?}", workspace.buffer_text(&path)); assert_eq!(found.matches[0].location.range, Range::new(Pos::new(0, 2), Pos::new(0, 8))); assert!(found.matches.iter().all(|m| m.location.path == path)); let only_file = TextQuery { include: vec!["a.txt".into()], ..query.clone() }; assert!( workspace .search_text(Some("second"), &f.root, only_file, 10, &CancellationToken::new()) .unwrap() .matches .is_empty() ); let capped = workspace.search_text(Some("main"), &f.root, query.clone(), 1, &CancellationToken::new()).unwrap(); assert_eq!(capped.matches.len(), 1); assert!(capped.limit_hit); let excluded = TextQuery { exclude: vec!["*.txt".into()], ..query.clone() }; assert!( workspace .search_text(Some("main"), &f.root, excluded, 10, &CancellationToken::new()) .unwrap() .matches .is_empty() ); for query in [ TextQuery { pattern: "NEEDLE".into(), case_sensitive: true, ..Default::default() }, TextQuery { pattern: "need".into(), whole_word: true, ..Default::default() }, TextQuery { include: vec!["*.rs".into()], ..query.clone() }, ] { assert!( workspace .search_text(Some("main"), &f.root, query, 10, &CancellationToken::new()) .unwrap() .matches .is_empty() ); } let multiline = TextQuery { pattern: "needle\nneedle".into(), regex: true, ..Default::default() }; let found = workspace.search_text(Some("main"), &f.root, multiline, 10, &CancellationToken::new()).unwrap(); assert_eq!(found.matches[0].location.range, Range::new(Pos::new(0, 2), Pos::new(1, 6))); let cancelled = CancellationToken::new(); cancelled.cancel(); assert!(matches!( workspace.search_text(Some("main"), &f.root, query, 10, &cancelled), Err(ide_plugin::HostError::Cancelled) )); } #[tokio::test(flavor = "multi_thread")] async fn problems_come_from_the_host_snapshot_whatever_window_published_them() { let f = Harness::new(); let path = f.root.join("a.txt"); std::fs::write(&path, "text").unwrap(); let diagnostic = |source: &str| Diagnostic { range: Range::default(), severity: Severity::Warning, message: source.into(), source: Some(source.into()), code: None, unnecessary: false, deprecated: false, server: None, }; // Producers publish per (file, producer) through the event sink, like the // language servers and the spelling check do. let publish = |host: &Host, source: &str, items: Vec| { host.project("main").unwrap().sink.emit(ide_core::IdeEvent::Diagnostics { path: path.clone().into(), source: source.into(), items, }); }; publish(&f.host, "rust-analyzer", vec![diagnostic("lsp")]); publish(&f.host, "build", vec![diagnostic("plugin")]); // A file outside the window's project is visible too: annotations follow the file. let outside = f.host.diagnostics.problems().len(); let workspace = f.workspace(); let files = workspace.problems("main", Some(&path)).unwrap(); assert_eq!(files.len(), 2); assert!(files.iter().all(|f| f.diagnostics.len() == 1)); assert!(workspace.problems("main", Some(&f.root.join("other.txt"))).unwrap().is_empty()); assert_eq!(outside, 2); // A full replacement per producer clears only that producer. publish(&f.host, "rust-analyzer", vec![]); let files = workspace.problems("main", None).unwrap(); assert_eq!(files.len(), 1); assert_eq!(files[0].source, "build"); } #[tokio::test(flavor = "multi_thread")] async fn search_decodes_closed_documents_the_same_way_as_the_editor() { let f = Harness::new(); let path = f.root.join("utf16.txt"); let mut bytes = vec![0xff, 0xfe]; for unit in "😀needle\r\n".encode_utf16() { bytes.extend_from_slice(&unit.to_le_bytes()); } std::fs::write(&path, bytes).unwrap(); let query = TextQuery { pattern: "needle".into(), ..Default::default() }; let result = f.workspace().search_text(Some("main"), &f.root, query, 10, &CancellationToken::new()).unwrap(); assert_eq!(result.matches.len(), 1); assert_eq!(result.matches[0].location.range, Range::new(Pos::new(0, 2), Pos::new(0, 8))); assert_eq!(result.matches[0].line, "😀needle"); } #[cfg(unix)] #[tokio::test(flavor = "multi_thread")] async fn plugin_debug_uses_the_source_language_and_revalidates_its_owned_program() { use ide_host::plugins::{Consent, PluginEvent, PluginHost, WindowRequest}; use ide_plugin::{Invocation, Limits}; let f = Harness::new(); f.host.set_project_trust(&f.root, true, false).await.unwrap(); std::fs::write(f.root.join("execution.marker"), "").unwrap(); std::fs::write(f.root.join("entry.py"), "print('test')\n").unwrap(); let events = Arc::new(parking_lot::Mutex::new(Vec::new())); let captured = events.clone(); let plugins = Arc::new( PluginHost::new( f._tmp.path().join("plugins"), Arc::new(move |client: Option<&str>, event: PluginEvent| { captured.lock().push((client.map(str::to_owned), event)) }), Limits::default(), ) .unwrap(), ); plugins.set_workspace(Some(Arc::new(f.workspace()))); f.host.set_plugin_host(&plugins); let package = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../ide-plugin/tests/fixtures/execution"); plugins.install_from_dir(&package, &Consent::all()).unwrap(); plugins .choose_program("execution", "process:execution-tool", Some(&f.root), Some(std::path::Path::new("/bin/cat"))) .unwrap(); let mut config = plugins.run_detection().detect(&f.root).into_iter().find(|c| c.id == "plugin:execution:detected").unwrap(); config.args = vec!["entry.py".into()]; ide_run::save_user_configs(&f.root, &[config]).unwrap(); let config = f.workspace().run_configuration("main", "execution", "detected").unwrap(); assert_eq!(config.debug_adapter.as_deref(), Some("debugpy")); let pinned = plugins.program_for_project("execution", "execution-tool", Some(&f.root)).unwrap(); assert_eq!(plugins.prepare_debug_run("main", config.clone()).unwrap().command, pinned.to_string_lossy()); let invocation = Invocation { client: Some("main".into()), workspace_root: Some(f.root.clone()), ..Default::default() }; assert!(plugins.run_command("execution", "debug", None, invocation).unwrap().is_some()); assert!(events.lock().iter().any(|(client, event)| client.as_deref() == Some("main") && matches!(event, PluginEvent::WindowRequest { request: WindowRequest::Run { config, debug: true, .. }, .. } if config.command == pinned.to_string_lossy()))); plugins.set_capability("execution", "process:execution-tool", false).unwrap(); assert!(plugins.prepare_debug_run("main", config).is_err()); } #[cfg(unix)] #[tokio::test(flavor = "multi_thread")] async fn plugin_run_targets_register_prompt_route_revalidate_and_withdraw() { use ide_host::plugins::{Consent, PluginEvent, PluginHost, run_targets}; use ide_plugin::{Invocation, Limits}; use std::os::unix::fs::PermissionsExt; let f = Harness::new(); f.host.set_project_trust(&f.root, true, false).await.unwrap(); let plugins = Arc::new( PluginHost::new( f._tmp.path().join("plugins"), Arc::new(|_: Option<&str>, _: PluginEvent| {}), Limits { idle_timeout: Some(std::time::Duration::from_millis(10)), ..Default::default() }, ) .unwrap(), ); plugins.set_workspace(Some(Arc::new(f.workspace()))); f.host.set_plugin_host(&plugins); let package = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../ide-plugin/tests/fixtures/execution"); plugins.install_from_dir(&package, &Consent::all()).unwrap(); let tool = f.root.with_file_name("wrapper"); std::fs::write(&tool, "#!/bin/sh\nprintf 'cwd=%s\\n' \"$PWD\"\nprintf '<%s>\\n' \"$@\"\n").unwrap(); std::fs::set_permissions(&tool, std::fs::Permissions::from_mode(0o755)).unwrap(); let invocation = || Invocation { client: Some("main".into()), workspace_root: Some(f.root.clone()), ..Default::default() }; assert!(plugins.run_command("execution", "target", None, invocation()).is_err()); plugins.choose_program("execution", "process:execution-tool", Some(&f.root), Some(&tool)).unwrap(); plugins.run_command("execution", "target", None, invocation()).unwrap(); tokio::time::sleep(std::time::Duration::from_millis(30)).await; plugins.tick_at(std::time::Instant::now()); assert_eq!(plugins.info_of("execution").unwrap().status, ide_host::plugins::PluginStatus::Inactive); let targets = run_targets::list(&f.host, &plugins, "main").unwrap(); assert_eq!(targets.len(), 1); assert!(targets[0].prompt); assert!(f.host.project("main").unwrap().settings.effective().run.default_target.is_empty()); let id = &targets[0].id; let settings = run_targets::answer(&f.host, &plugins, "main", id, false).unwrap(); assert!(settings.run.default_target.is_empty()); // A stale prompt in a second window cannot change an answered selection. assert!(run_targets::answer(&f.host, &plugins, "second", id, true).unwrap().run.default_target.is_empty()); plugins.run_command("execution", "untarget", None, invocation()).unwrap(); assert!(plugins.run_targets(&f.root).is_empty()); plugins.run_command("execution", "target", None, invocation()).unwrap(); assert!(!plugins.run_targets(&f.root)[0].prompt); plugins.run_command("execution", "target", Some("preferred"), invocation()).unwrap(); let preferred = plugins.run_targets(&f.root).into_iter().find(|t| t.target.id == "preferred").unwrap(); let settings = run_targets::answer(&f.host, &plugins, "main", &preferred.id, true).unwrap(); assert_eq!(settings.run.default_target, preferred.id); assert_eq!(settings.languages.php.run_target, preferred.id); assert_eq!(settings.languages.node.run_target, preferred.id); assert_eq!(f.host.project("second").unwrap().settings.effective().run.default_target, preferred.id); std::fs::write(f.root.join("execution.marker"), "").unwrap(); std::fs::write(f.root.join("entry.py"), "print('test')\n").unwrap(); let mut detected = plugins.run_detection().detect(&f.root).into_iter().find(|c| c.id == "plugin:execution:detected").unwrap(); detected.args = vec!["entry.py".into()]; ide_run::save_user_configs(&f.root, &[detected]).unwrap(); let mut debug = f.workspace().run_configuration("main", "execution", "detected").unwrap(); debug.extras.target = None; let error = plugins.prepare_debug_run("main", debug).unwrap_err(); assert_eq!(error.kind, ide_core::error::ErrorKind::InvalidInput); assert!(error.to_string().contains("target")); assert!(plugins.run_command("execution", "debug", None, invocation()).unwrap_err().to_string().contains("target")); let output = Arc::new(parking_lot::Mutex::new(String::new())); let captured = output.clone(); let config = ide_run::RunConfig { id: "php-target".into(), name: "PHP target".into(), kind: "php".into(), command: "php".into(), args: vec!["x.php".into(), "a b; $(touch forbidden)".into()], cwd: None, env: Default::default(), detected: false, is_test: false, debug_adapter: None, allow_parallel: false, extras: Default::default(), }; let run = ide_host::ops::run::run_start( &f.host, "main", config.clone(), ide_host::ops::Channel::new(move |chunk| { if let ide_run::OutputChunk::Stdout { text } = chunk { captured.lock().push_str(&text); } }), None, ) .await .unwrap(); for _ in 0..100 { if f.host.processes.list().iter().any(|r| r.id == run.id && !r.running) { break; } tokio::time::sleep(std::time::Duration::from_millis(20)).await; } let text = output.lock().clone(); assert!(text.contains("\n<--cwd=/container>\n\n\n"), "{text}"); assert!(text.contains(&format!("cwd={}", f.root.display())), "{text}"); assert!(!f.root.join("forbidden").exists()); // Pin checks are repeated at launch, not only at registration. std::fs::write(&tool, "#!/bin/sh\nexit 99\n").unwrap(); assert!( ide_host::ops::run::run_start(&f.host, "main", config.clone(), ide_host::ops::Channel::new(|_| {}), None) .await .is_err() ); plugins.set_capability("execution", "process:execution-tool", false).unwrap(); assert!(plugins.run_targets(&f.root).is_empty()); assert!( ide_host::ops::run::run_start(&f.host, "main", config, ide_host::ops::Channel::new(|_| {}), None) .await .is_err() ); plugins.choose_program("execution", "process:execution-tool", Some(&f.root), Some(&tool)).unwrap(); plugins.run_command("execution", "target", None, invocation()).unwrap(); f.host.set_project_trust(&f.root, false, false).await.unwrap(); assert!(plugins.run_targets(&f.root).is_empty()); assert!( plugins.run_command("execution", "target", None, invocation()).unwrap_err().to_string().contains("trusted") ); f.host.set_project_trust(&f.root, true, false).await.unwrap(); plugins.run_command("execution", "target", None, invocation()).unwrap(); f.host.close_project_detached("main"); assert_eq!(plugins.run_targets(&f.root).len(), 1); f.host.close_project_detached("second"); assert!(plugins.run_targets(&f.root).is_empty()); plugins.shutdown(); } #[tokio::test(flavor = "multi_thread")] async fn plugin_run_output_mode_precedence_and_disallowed_combinations() { use ide_host::plugins::{Consent, PluginEvent, PluginHost, WindowRequest}; use ide_plugin::{Invocation, Limits}; let f = Harness::new(); f.host.set_project_trust(&f.root, true, false).await.unwrap(); std::fs::write(f.root.join("execution-output.marker"), "").unwrap(); let events = Arc::new(parking_lot::Mutex::new(Vec::new())); let captured = events.clone(); let plugins = Arc::new( PluginHost::new( f._tmp.path().join("plugins"), Arc::new(move |client: Option<&str>, event: PluginEvent| { captured.lock().push((client.map(str::to_owned), event)) }), Limits::default(), ) .unwrap(), ); plugins.set_workspace(Some(Arc::new(f.workspace()))); f.host.set_plugin_host(&plugins); let package = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../ide-plugin/tests/fixtures/execution-output"); plugins.install_from_dir(&package, &Consent::all()).unwrap(); let exe = std::env::current_exe().unwrap(); plugins.choose_program("test.execution-output", "process:execution-tool", Some(&f.root), Some(&exe)).unwrap(); plugins.refresh_run_configurations(&f.root); let detected = plugins.run_detection().detect(&f.root); let by_id = |id: &str| detected.iter().find(|c| c.id == format!("plugin:test.execution-output:{id}")).unwrap().clone(); assert!(by_id("detector-pty").extras.emulate_terminal); assert!(!by_id("detector-pipes").extras.emulate_terminal); assert!(by_id("pty-default").extras.emulate_terminal); assert!(!by_id("pipes-default").extras.emulate_terminal); assert!(!by_id("test-pipes").extras.emulate_terminal); let invoke = |cmd: &str, arg: &str| { events.lock().clear(); let inv = Invocation { client: Some("main".into()), workspace_root: Some(f.root.clone()), ..Default::default() }; let res = plugins.run_command("test.execution-output", cmd, Some(arg), inv); let req = events.lock().iter().find_map(|(client, event)| match event { PluginEvent::WindowRequest { request: WindowRequest::Run { config, debug, .. }, .. } => { assert_eq!(client.as_deref(), Some("main")); Some((config.as_ref().clone(), *debug)) } _ => None, }); (res, req) }; // 1. Plugin default applies when invocation passes None (including legacy `run.start`). let (res, req) = invoke("start", "pty-default|default|run"); assert!(res.is_ok()); assert!(req.unwrap().0.extras.emulate_terminal); let (res, req) = invoke("start-legacy", "pty-default"); assert!(res.is_ok()); assert!(req.unwrap().0.extras.emulate_terminal); let (res, req) = invoke("start", "pipes-default|default|run"); assert!(res.is_ok()); assert!(!req.unwrap().0.extras.emulate_terminal); // 2. Per-invocation override wins over plugin default. let (res, req) = invoke("start", "pty-default|pipes|run"); assert!(res.is_ok()); assert!(!req.unwrap().0.extras.emulate_terminal); let (res, req) = invoke("start", "pipes-default|pty|run"); assert!(res.is_ok()); assert!(req.unwrap().0.extras.emulate_terminal); // 3. Disallowed combinations: debug + pty, test + pty, stdin_file + pty, remote target + pty. let (res, req) = invoke("start", "pty-default|pty|debug"); assert!(res.unwrap_err().message.contains("debugging")); assert!(req.is_none()); // Debug without explicit Pty keeps debugging working with pipes. let (res, req) = invoke("start", "pty-default|default|debug"); assert!(res.is_ok()); let (cfg, debug) = req.unwrap(); assert!(debug && !cfg.extras.emulate_terminal); let (res, req) = invoke("start", "test-pipes|pty|run"); assert!(res.unwrap_err().message.contains("test")); assert!(req.is_none()); // Redirected stdin rejects PTY, whereas a user-saved Pipes override with stdin_file runs cleanly. let mut stdin_pty = by_id("pty-default"); stdin_pty.extras.stdin_file = Some("input.txt".into()); ide_run::save_user_configs(&f.root, &[stdin_pty]).unwrap(); let (res, req) = invoke("start", "pty-default|default|run"); assert!(res.unwrap_err().message.contains("redirected")); assert!(req.is_none()); let mut stdin_pipes = by_id("pipes-default"); stdin_pipes.extras.stdin_file = Some("input.txt".into()); ide_run::save_user_configs(&f.root, &[stdin_pipes]).unwrap(); let (res, req) = invoke("start", "pipes-default|pty|run"); assert!(res.is_ok()); assert!(!req.unwrap().0.extras.emulate_terminal); // Remote run target rejects PTY. let mut remote_pty = by_id("pty-default"); remote_pty.extras.target = Some("ssh:prod".into()); ide_run::save_user_configs(&f.root, &[remote_pty]).unwrap(); let (res, req) = invoke("start", "pty-default|default|run"); assert!(res.unwrap_err().message.contains("target")); assert!(req.is_none()); // 4. User-saved output-mode override wins over both invocation and plugin default. let mut user_pipes = by_id("pty-default"); user_pipes.extras.emulate_terminal = false; let mut user_pty = by_id("pipes-default"); user_pty.extras.emulate_terminal = true; ide_run::save_user_configs(&f.root, &[user_pipes, user_pty]).unwrap(); let (res, req) = invoke("start", "pty-default|pty|run"); assert!(res.is_ok()); assert!(!req.unwrap().0.extras.emulate_terminal); let (res, req) = invoke("start", "pipes-default|pipes|run"); assert!(res.is_ok()); assert!(req.unwrap().0.extras.emulate_terminal); // 5. Removing user overrides restores plugin default behavior; untrusted projects refuse launches. ide_run::save_user_configs(&f.root, &[]).unwrap(); let (res, req) = invoke("start", "pty-default|default|run"); assert!(res.is_ok()); assert!(req.unwrap().0.extras.emulate_terminal); f.host.set_project_trust(&f.root, false, false).await.unwrap(); assert!(invoke("start", "pty-default|default|run").0.is_err()); plugins.shutdown(); } #[cfg(unix)] #[tokio::test(flavor = "multi_thread")] async fn plugin_run_output_mode_executes_pty_and_pipes_with_input_exit_and_stop() { use ide_host::plugins::{Consent, PluginEvent, PluginHost, WindowRequest}; use ide_plugin::{Invocation, Limits}; use std::os::unix::fs::PermissionsExt; use std::time::Duration; let f = Harness::new(); f.host.set_project_trust(&f.root, true, false).await.unwrap(); std::fs::write(f.root.join("execution-output.marker"), "").unwrap(); let tool = f.root.with_file_name("exec-output-tool"); std::fs::write( &tool, "#!/bin/sh\n\ if [ \"$1\" = \"wait\" ]; then\n\ read line\n\ printf 'out:%s\\n' \"$line\"\n\ printf 'err:%s\\n' \"$line\" >&2\n\ exit 7\n\ fi\n\ if [ \"$1\" = \"hang\" ]; then\n\ trap 'exit 0' INT TERM\n\ printf 'ready\\n'\n\ while true; do sleep 0.1; done\n\ fi\n\ printf 'out-line\\n'\n\ printf 'err-line\\n' >&2\n\ exit 0\n", ) .unwrap(); std::fs::set_permissions(&tool, std::fs::Permissions::from_mode(0o755)).unwrap(); let events = Arc::new(parking_lot::Mutex::new(Vec::new())); let captured = events.clone(); let plugins = Arc::new( PluginHost::new( f._tmp.path().join("plugins"), Arc::new(move |client: Option<&str>, event: PluginEvent| { captured.lock().push((client.map(str::to_owned), event)) }), Limits::default(), ) .unwrap(), ); plugins.set_workspace(Some(Arc::new(f.workspace()))); f.host.set_plugin_host(&plugins); let package = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../ide-plugin/tests/fixtures/execution-output"); plugins.install_from_dir(&package, &Consent::all()).unwrap(); plugins.choose_program("test.execution-output", "process:execution-tool", Some(&f.root), Some(&tool)).unwrap(); plugins.refresh_run_configurations(&f.root); let launch_and_collect = |arg: &str, stdin: Option<&str>, stop_after_ready: bool| { let host = f.host.clone(); let plugins = plugins.clone(); let events = events.clone(); let root = f.root.clone(); let arg = arg.to_owned(); let stdin = stdin.map(str::to_owned); async move { events.lock().clear(); let inv = Invocation { client: Some("main".into()), workspace_root: Some(root), ..Default::default() }; let op_id = plugins.run_command("test.execution-output", "start", Some(&arg), inv).unwrap().unwrap(); let config = events .lock() .iter() .find_map(|(_, event)| match event { PluginEvent::WindowRequest { request: WindowRequest::Run { config, .. }, .. } => { Some(config.as_ref().clone()) } _ => None, }) .unwrap(); let chunks = Arc::new(parking_lot::Mutex::new(Vec::::new())); let out_chunks = chunks.clone(); let info = ide_host::ops::run::run_start( &host, "main", config, ide_host::ops::Channel::new(move |c| out_chunks.lock().push(c)), None, ) .await .unwrap(); if let Some(data) = stdin { ide_host::ops::run::run_stdin(&host, info.id, data).unwrap(); } if stop_after_ready { for _ in 0..100 { if chunks .lock() .iter() .any(|c| matches!(c, ide_run::OutputChunk::Stdout { text } if text.contains("ready"))) { break; } tokio::time::sleep(Duration::from_millis(20)).await; } ide_host::ops::run::run_stop(&host, "main", info.id).unwrap(); } for _ in 0..150 { if host.processes.list().iter().any(|r| r.id == info.id && !r.running) { break; } tokio::time::sleep(Duration::from_millis(20)).await; } let exit = host.processes.exit_code(info.id).unwrap(); let collected = chunks.lock().clone(); (op_id, info, exit, collected) } }; // PTY run: combined stdout/stderr on stdout stream, stdin works, exit status 7 delivered. // Default PTY run (`args: ["pty", "extra"]`): stdout and stderr arrive combined as Stdout chunks. let (_op, info, exit, chunks) = launch_and_collect("pty-default|default|run", None, false).await; assert!(info.pty); assert_eq!(exit, Some(Some(0))); let pty_stdout: String = chunks .iter() .filter_map(|c| match c { ide_run::OutputChunk::Stdout { text } => Some(text.as_str()), _ => None, }) .collect(); let pty_stderr: String = chunks .iter() .filter_map(|c| match c { ide_run::OutputChunk::Stderr { text } => Some(text.as_str()), _ => None, }) .collect(); assert!(pty_stdout.contains("out-line") && pty_stdout.contains("err-line"), "{pty_stdout:?}"); assert!(pty_stderr.is_empty(), "ordinary PTYs combine stdout and stderr: {pty_stderr:?}"); // Piped run (`args: ["pipes", "extra"]`): stdout and stderr stay separate. let (_op, info, exit, chunks) = launch_and_collect("pipes-default|default|run", None, false).await; assert!(!info.pty); assert_eq!(exit, Some(Some(0))); let pipe_stdout: String = chunks .iter() .filter_map(|c| match c { ide_run::OutputChunk::Stdout { text } => Some(text.as_str()), _ => None, }) .collect(); let pipe_stderr: String = chunks .iter() .filter_map(|c| match c { ide_run::OutputChunk::Stderr { text } => Some(text.as_str()), _ => None, }) .collect(); assert!(pipe_stdout.contains("out-line"), "{pipe_stdout:?}"); assert!(pipe_stderr.contains("err-line"), "{pipe_stderr:?}"); // Interactive PTY run with input + non-zero exit code + run-exited event. let mut wait_cfg = plugins .run_detection() .detect(&f.root) .into_iter() .find(|c| c.id == "plugin:test.execution-output:pty-default") .unwrap(); wait_cfg.args = vec!["wait".into()]; ide_run::save_user_configs(&f.root, &[wait_cfg]).unwrap(); let (op_wait, info, exit, chunks) = launch_and_collect("pty-default|default|run", Some("hi\n"), false).await; assert!(info.pty); assert_eq!(exit, Some(Some(7))); let combined: String = chunks .iter() .filter_map(|c| match c { ide_run::OutputChunk::Stdout { text } => Some(text.as_str()), _ => None, }) .collect(); assert!(combined.contains("out:hi") && combined.contains("err:hi"), "{combined:?}"); // Cancellation / stop on PTY run. let mut hang_cfg = plugins .run_detection() .detect(&f.root) .into_iter() .find(|c| c.id == "plugin:test.execution-output:pty-default") .unwrap(); hang_cfg.args = vec!["hang".into()]; ide_run::save_user_configs(&f.root, &[hang_cfg]).unwrap(); let (op_stop, info, _exit, _chunks) = launch_and_collect("pty-default|default|run", None, true).await; assert!(info.pty); plugins.flush_events_at(std::time::Instant::now() + Duration::from_secs(3)); for _ in 0..50 { if plugins.wait_events(Duration::from_millis(50)) { break; } } let recorded = plugins .run_command( "test.execution-output", "events", None, Invocation { client: Some("main".into()), workspace_root: Some(f.root.clone()), ..Default::default() }, ) .unwrap() .unwrap(); let recorded: serde_json::Value = serde_json::from_str(&recorded).unwrap(); let arr = recorded.as_array().unwrap(); assert!(arr.iter().any(|e| { e["kind"] == "run-exited" && serde_json::from_str::(e["data"].as_str().unwrap()) .is_ok_and(|d| d["id"] == op_wait && d["status"] == 7 && d["killed"] == false) })); assert!(arr.iter().any(|e| { e["kind"] == "run-exited" && serde_json::from_str::(e["data"].as_str().unwrap()) .is_ok_and(|d| d["id"] == op_stop && d["killed"] == true) })); plugins.shutdown(); } #[cfg(unix)] #[tokio::test(flavor = "multi_thread")] async fn run_target_api15_overrides_and_frozen_api14_registration() { use ide_host::plugins::{Consent, PluginHost}; use ide_plugin::{Invocation, Limits, PluginEngine}; use std::os::unix::fs::PermissionsExt; let f = Harness::new(); f.host.set_project_trust(&f.root, true, false).await.unwrap(); let plugins = Arc::new( PluginHost::new(f._tmp.path().join("plugins"), Arc::new(|_: Option<&str>, _| {}), Limits::default()).unwrap(), ); plugins.set_workspace(Some(Arc::new(f.workspace()))); f.host.set_plugin_host(&plugins); let fixtures = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../ide-plugin/tests/fixtures"); let engine = PluginEngine::new().unwrap(); let legacy = engine.compile(&fixtures.join("run-target-api14/dist/plugin.wasm")).unwrap(); assert_eq!(engine.check_component(&legacy).unwrap().unwrap().to_string(), "1.4.0"); let tool = f.root.with_file_name("wrapper"); std::fs::write(&tool, "#!/bin/sh\nexit 0\n").unwrap(); std::fs::set_permissions(&tool, std::fs::Permissions::from_mode(0o755)).unwrap(); let invocation = || Invocation { client: Some("main".into()), workspace_root: Some(f.root.clone()), ..Default::default() }; let config: ide_run::RunConfig = serde_json::from_value(serde_json::json!({ "id":"composer", "name":"Composer", "kind":"shell", "command":"composer", "args":["install"], "env":{}, "detected":false, "isTest":false, })) .unwrap(); for (plugin, command) in [("run-target-api14", "target"), ("execution", "target-overrides")] { plugins.install_from_dir(&fixtures.join(plugin), &Consent::all()).unwrap(); assert!(plugins.run_command(plugin, command, Some("empty"), invocation()).is_err()); plugins.choose_program(plugin, "process:execution-tool", Some(&f.root), Some(&tool)).unwrap(); let cases = if plugin == "execution" { vec![ ("empty", vec!["composer", "install"]), ("own", vec!["composer", "--working-dir=/container", "install"]), ("inherit", vec!["composer", "--cwd=/container", "install"]), ] } else { vec![("inherit", vec!["composer", "--cwd=/container", "install"])] }; for (arg, expected) in cases { plugins.run_command(plugin, command, Some(arg), invocation()).unwrap(); let target = plugins.run_targets(&f.root).into_iter().find(|t| t.plugin_id == plugin).unwrap(); let wrapped = plugins .prepare_run_target_launch( &f.root, &target.id, &config, ide_plugin::RunTargetOperation::Run, &Default::default(), ) .unwrap(); assert_eq!(wrapped.args, expected); assert_eq!(PathBuf::from(wrapped.command), tool); assert_eq!(wrapped.cwd.unwrap(), f.root); let php = ide_run::RunConfig { command: "php".into(), args: vec!["x.php".into()], ..config.clone() }; assert_eq!( plugins .prepare_run_target_launch( &f.root, &target.id, &php, ide_plugin::RunTargetOperation::Run, &Default::default() ) .unwrap() .args, ["wrapped", "--cwd=/container", "php", "x.php"] ); } if plugin == "execution" { assert!(plugins.run_command(plugin, command, Some("invalid"), invocation()).is_err()); // A failed replacement retains the previous valid registration. assert_eq!(plugins.run_targets(&f.root).iter().filter(|t| t.plugin_id == plugin).count(), 1); } plugins.set_capability(plugin, "process:execution-tool", false).unwrap(); assert!(plugins.run_targets(&f.root).iter().all(|t| t.plugin_id != plugin)); assert!(plugins.run_command(plugin, command, None, invocation()).is_err()); plugins.choose_program(plugin, "process:execution-tool", Some(&f.root), Some(&tool)).unwrap(); f.host.set_project_trust(&f.root, false, false).await.unwrap(); assert!(plugins.run_command(plugin, command, None, invocation()).unwrap_err().to_string().contains("trusted")); f.host.set_project_trust(&f.root, true, false).await.unwrap(); } plugins.shutdown(); } #[cfg(unix)] #[tokio::test(flavor = "multi_thread")] async fn run_target_validation_gates_launches_and_preserves_selection() { use ide_host::plugins::{Consent, PluginHost}; use ide_plugin::{Invocation, Limits, RunTargetOperation}; use std::os::unix::fs::PermissionsExt; use std::time::Duration; let f = Harness::new(); f.host.set_project_trust(&f.root, true, false).await.unwrap(); let plugins = Arc::new( PluginHost::new( f._tmp.path().join("plugins"), Arc::new(|_: Option<&str>, _| {}), Limits { // Room for a reclaimed instance to start again on a slow runner. timeout: Duration::from_millis(750), idle_timeout: Some(Duration::from_millis(20)), restart_backoff: Duration::ZERO, ..Default::default() }, ) .unwrap(), ); plugins.set_workspace(Some(Arc::new(f.workspace()))); f.host.set_plugin_host(&plugins); let fixture = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../ide-plugin/tests/fixtures/execution"); plugins.install_from_dir(&fixture, &Consent::all()).unwrap(); let tool = f.root.with_file_name("wrapper"); std::fs::write(&tool, "#!/bin/sh\ntouch spawned\n").unwrap(); std::fs::set_permissions(&tool, std::fs::Permissions::from_mode(0o755)).unwrap(); plugins.choose_program("execution", "process:execution-tool", Some(&f.root), Some(&tool)).unwrap(); let invocation = || Invocation { client: Some("main".into()), workspace_root: Some(f.root.clone()), ..Default::default() }; let config: ide_run::RunConfig = serde_json::from_value(serde_json::json!({ "id":"composer", "name":"Composer", "kind":"shell", "command":"/tools/composer", "args":["install"], "env":{"SECRET":"not sent"}, "detected":false, "isTest":false, })) .unwrap(); for id in ["allow", "refuse", "long-refusal", "timeout", "trap"] { plugins.run_command("execution", "target", Some(id), invocation()).unwrap(); } let targets = plugins.run_targets(&f.root); let id = |name: &str| targets.iter().find(|t| t.target.id == name).unwrap().id.clone(); for operation in [RunTargetOperation::Run, RunTargetOperation::Test] { plugins.prepare_run_target_launch(&f.root, &id("allow"), &config, operation, &Default::default()).unwrap(); let snapshot = plugins.run_command("execution", "validation", None, invocation()).unwrap().unwrap(); assert_eq!(snapshot, format!("{}|allow|{operation:?}|composer|{}", f.root.display(), f.root.display())); } tokio::time::sleep(Duration::from_millis(30)).await; plugins.tick(); assert_eq!(plugins.info_of("execution").unwrap().status, ide_host::plugins::PluginStatus::Inactive); plugins .prepare_run_target_launch(&f.root, &id("allow"), &config, RunTargetOperation::Run, &Default::default()) .unwrap(); assert!(plugins.info_of("execution").unwrap().stats.reclaims > 0); let selected = id("refuse"); ide_host::plugins::run_targets::answer(&f.host, &plugins, "main", &selected, true).unwrap(); for is_test in [false, true] { let mut config = config.clone(); config.is_test = is_test; config.extras.target = Some(selected.clone()); let error = ide_host::ops::run::run_start(&f.host, "main", config, ide_host::ops::Channel::new(|_| {}), None) .await .unwrap_err(); assert!(error.message.contains("Plugin execution tests: Project runtime is stopped"), "{error}"); assert!(f.host.processes.list().is_empty()); assert!(!f.root.join("spawned").exists()); assert_eq!(f.host.project("main").unwrap().settings.effective().run.default_target, selected); assert_eq!(plugins.run_targets(&f.root).len(), targets.len()); } let error = plugins .prepare_run_target_launch(&f.root, &id("long-refusal"), &config, RunTargetOperation::Run, &Default::default()) .unwrap_err(); assert!(error.message.len() < 4200); let request = ide_core::RequestId(2408); let mut cfg = config.clone(); cfg.extras.target = Some(id("timeout")); let worker = f.host.clone(); let pending = tokio::spawn(async move { ide_host::ops::run::run_start(&worker, "main", cfg, ide_host::ops::Channel::new(|_| {}), Some(request)).await }); tokio::time::sleep(Duration::from_millis(30)).await; f.host.cancel_request(request); assert_eq!(pending.await.unwrap().unwrap_err().kind, ide_core::error::ErrorKind::Cancelled); for name in ["timeout", "trap"] { let started = std::time::Instant::now(); let error = plugins .prepare_run_target_launch(&f.root, &id(name), &config, RunTargetOperation::Run, &Default::default()) .unwrap_err(); assert!(error.message.contains("Plugin execution tests"), "{error}"); if name == "timeout" { assert!(error.message.contains("timed out"), "{error}"); assert!(started.elapsed() < Duration::from_secs(2), "background tasks must not extend validation"); } assert!(f.host.processes.list().is_empty()); } // A cancelled launch never enters the wrapper. let cancel = ide_core::CancellationToken::new(); cancel.cancel(); assert_eq!( plugins .prepare_run_target_launch(&f.root, &id("allow"), &config, RunTargetOperation::Run, &cancel) .unwrap_err() .kind, ide_core::error::ErrorKind::Cancelled ); plugins.shutdown(); } #[cfg(unix)] #[tokio::test(flavor = "multi_thread")] async fn plugin_run_config_types_enforce_process_grants_for_run_debug_and_stop() { use ide_host::plugins::{Consent, PluginEvent, PluginHost}; use ide_plugin::Limits; use std::os::unix::fs::PermissionsExt; let f = Harness::new(); f.host.set_project_trust(&f.root, true, false).await.unwrap(); let plugins = Arc::new( PluginHost::new( f._tmp.path().join("plugins"), Arc::new(|_: Option<&str>, _: PluginEvent| {}), Limits::default(), ) .unwrap(), ); plugins.set_workspace(Some(Arc::new(f.workspace()))); f.host.set_plugin_host(&plugins); let pkg = f._tmp.path().join("custom-run-plugin"); std::fs::create_dir_all(pkg.join("web")).unwrap(); std::fs::write(pkg.join("web/form.html"), "
").unwrap(); std::fs::write( pkg.join("plugin.toml"), r#"id = "run-form-test" name = "Run Form Test" version = "0.1.0" engines.openidea = "^1.20" [capabilities] optional = ["process:custom-tool", "process:custom-stop"] [[contributes.runConfigTypes]] id = "custom" label = "Custom Tool" web = "web/form.html" debugAdapter = "debugpy" "#, ) .unwrap(); plugins.install_from_dir(&pkg, &Consent::default()).unwrap(); let tool = f._tmp.path().join("custom-tool-bin"); std::fs::write( &tool, "#!/bin/sh\nif [ \"$1\" = \"--sleep\" ]; then\n echo \"sleeping\"\n sleep 30\n exit 0\nfi\necho \"pinned-custom-tool:$1\"\n", ) .unwrap(); std::fs::set_permissions(&tool, std::fs::Permissions::from_mode(0o755)).unwrap(); let stop_tool = f._tmp.path().join("custom-stop-bin"); std::fs::write(&stop_tool, "#!/bin/sh\nprintf 'stopped' > \"$1\"\n").unwrap(); std::fs::set_permissions(&stop_tool, std::fs::Permissions::from_mode(0o755)).unwrap(); let make_config = |command: &str, stop_command: Option<&str>| ide_run::RunConfig { id: "user:custom-1".into(), name: "Custom Tool".into(), kind: "plugin:run-form-test:custom".into(), command: command.into(), args: vec!["--hello".into()], cwd: None, env: Default::default(), detected: false, is_test: false, debug_adapter: Some("debugpy".into()), allow_parallel: false, extras: ide_run::RunExtras { stop_command: stop_command.map(str::to_owned), ..Default::default() }, }; // 1. Without `process:custom-tool` granted: Run, Debug, and saved overrides are all refused. let ungranted = make_config("custom-tool", None); let err = ide_host::ops::run::run_start(&f.host, "main", ungranted.clone(), ide_host::ops::Channel::new(|_| {}), None) .await .unwrap_err(); assert_eq!(err.kind, ide_core::error::ErrorKind::PermissionDenied, "{err}"); let shell_err = ide_host::ops::run::run_start( &f.host, "main", make_config("/bin/sh", None), ide_host::ops::Channel::new(|_| {}), None, ) .await .unwrap_err(); assert_eq!(shell_err.kind, ide_core::error::ErrorKind::PermissionDenied, "{shell_err}"); let dbg_err = plugins.prepare_debug_run("main", ungranted.clone()).unwrap_err(); assert_eq!(dbg_err.kind, ide_core::error::ErrorKind::PermissionDenied, "{dbg_err}"); let debug_launch = |program: &std::path::Path| ide_dap::LaunchConfig { name: ungranted.name.clone(), adapter: "debugpy".into(), request: "launch".into(), program: None, args: vec![], cwd: Some(f.root.clone().into()), env: Default::default(), extra_json: Some( serde_json::json!({ "__openideaPluginRun": { "config": ungranted, "program": program } }).to_string(), ), }; let malformed = ide_run::RunConfig { kind: "plugin:run-form-test".into(), ..ungranted.clone() }; assert!( ide_host::ops::run::run_start(&f.host, "main", malformed.clone(), ide_host::ops::Channel::new(|_| {}), None) .await .is_err() ); assert!(plugins.prepare_debug_run("main", malformed).is_err()); let unknown_type = ide_run::RunConfig { kind: "plugin:run-form-test:missing".into(), ..ungranted.clone() }; assert!( ide_host::ops::run::run_start(&f.host, "main", unknown_type.clone(), ide_host::ops::Channel::new(|_| {}), None) .await .is_err() ); assert!(plugins.prepare_debug_run("main", unknown_type).is_err()); let saved_detected = ide_run::RunConfig { id: "plugin:run-form-test:saved".into(), kind: "plugin".into(), detected: false, ..ungranted.clone() }; let saved_err = ide_host::ops::run::run_start(&f.host, "main", saved_detected, ide_host::ops::Channel::new(|_| {}), None) .await .unwrap_err(); assert_eq!(saved_err.kind, ide_core::error::ErrorKind::PermissionDenied, "{saved_err}"); // 2. Grant & pin `process:custom-tool`: Run and Debug resolve the pinned executable, // while env/cwd escapes are still rejected. plugins.choose_program("run-form-test", "process:custom-tool", Some(&f.root), Some(&tool)).unwrap(); let canonical_tool = dunce::canonicalize(&tool).unwrap(); let output = Arc::new(parking_lot::Mutex::new(String::new())); let captured = output.clone(); let run = ide_host::ops::run::run_start( &f.host, "main", ungranted.clone(), ide_host::ops::Channel::new(move |chunk| { if let ide_run::OutputChunk::Stdout { text } = chunk { captured.lock().push_str(&text); } }), None, ) .await .unwrap(); for _ in 0..100 { if f.host.processes.list().iter().any(|r| r.id == run.id && !r.running) { break; } tokio::time::sleep(std::time::Duration::from_millis(20)).await; } assert!(output.lock().contains("pinned-custom-tool:--hello"), "{}", output.lock()); let prepared_dbg = plugins.prepare_debug_run("main", ungranted.clone()).unwrap(); assert_eq!(std::path::Path::new(&prepared_dbg.command), canonical_tool); assert_eq!(prepared_dbg.debug_adapter.as_deref(), Some("debugpy")); let mut bad_env = ungranted.clone(); bad_env.env.insert("LD_PRELOAD".into(), "/tmp/evil.so".into()); assert!( ide_host::ops::run::run_start(&f.host, "main", bad_env.clone(), ide_host::ops::Channel::new(|_| {}), None) .await .is_err() ); assert!(plugins.prepare_debug_run("main", bad_env).is_err()); let outside_dir = f._tmp.path().join("outside"); std::fs::create_dir_all(&outside_dir).unwrap(); let mut bad_cwd = ungranted.clone(); bad_cwd.cwd = Some(outside_dir.into()); assert!( ide_host::ops::run::run_start(&f.host, "main", bad_cwd.clone(), ide_host::ops::Channel::new(|_| {}), None) .await .is_err() ); assert!(plugins.prepare_debug_run("main", bad_cwd).is_err()); // 3. Stop command enforcement: requires grant, rejects shell syntax, and re-checks grant at Stop time. let ungranted_stop = make_config("custom-tool", Some("custom-stop marker.txt")); let stop_err = ide_host::ops::run::run_start(&f.host, "main", ungranted_stop, ide_host::ops::Channel::new(|_| {}), None) .await .unwrap_err(); assert_eq!(stop_err.kind, ide_core::error::ErrorKind::PermissionDenied, "{stop_err}"); let shell_stop = make_config("custom-tool", Some("custom-tool; touch evil")); let shell_stop_err = ide_host::ops::run::run_start(&f.host, "main", shell_stop, ide_host::ops::Channel::new(|_| {}), None) .await .unwrap_err(); assert_eq!(shell_stop_err.kind, ide_core::error::ErrorKind::InvalidInput, "{shell_stop_err}"); plugins.choose_program("run-form-test", "process:custom-stop", Some(&f.root), Some(&stop_tool)).unwrap(); let mut sleep_cfg = make_config("custom-tool", Some("custom-stop stopped.txt")); sleep_cfg.args = vec!["--sleep".into()]; let sleep_run = ide_host::ops::run::run_start(&f.host, "main", sleep_cfg, ide_host::ops::Channel::new(|_| {}), None) .await .unwrap(); ide_host::ops::run::run_stop(&f.host, "main", sleep_run.id).unwrap(); for _ in 0..100 { if f.host.processes.list().iter().any(|r| r.id == sleep_run.id && !r.running) { break; } tokio::time::sleep(std::time::Duration::from_millis(50)).await; } assert!(f.host.processes.list().iter().any(|r| r.id == sleep_run.id && !r.running)); assert_eq!(std::fs::read_to_string(f.root.join("stopped.txt")).unwrap(), "stopped"); // Revoking `process:custom-stop` after Start prevents the stop command from running on Stop. let mut revoked_stop_cfg = make_config("custom-tool", Some("custom-stop revoked.txt")); revoked_stop_cfg.args = vec!["--sleep".into()]; let revoked_run = ide_host::ops::run::run_start(&f.host, "main", revoked_stop_cfg, ide_host::ops::Channel::new(|_| {}), None) .await .unwrap(); plugins.set_capability("run-form-test", "process:custom-stop", false).unwrap(); ide_host::ops::run::run_stop(&f.host, "main", revoked_run.id).unwrap(); for _ in 0..100 { if f.host.processes.list().iter().any(|r| r.id == revoked_run.id && !r.running) { break; } tokio::time::sleep(std::time::Duration::from_millis(50)).await; } assert!(f.host.processes.list().iter().any(|r| r.id == revoked_run.id && !r.running)); assert!(!f.root.join("revoked.txt").exists()); // 4. Revoking `process:custom-tool` immediately blocks subsequent Run and Debug launches. plugins.set_capability("run-form-test", "process:custom-tool", false).unwrap(); let debug_err = ide_host::ops::debug::debug_start(&f.host, "main", debug_launch(&canonical_tool)).await.unwrap_err(); assert_eq!(debug_err.kind, ide_core::error::ErrorKind::PermissionDenied, "{debug_err}"); assert_eq!( ide_host::ops::run::run_start(&f.host, "main", ungranted.clone(), ide_host::ops::Channel::new(|_| {}), None) .await .unwrap_err() .kind, ide_core::error::ErrorKind::PermissionDenied ); assert_eq!( plugins.prepare_debug_run("main", ungranted).unwrap_err().kind, ide_core::error::ErrorKind::PermissionDenied ); plugins.shutdown(); }