Skip to content

Visual Studio Code, rebuilt in Rust

Rust

test(workbench): fix three tests that fail on Linux (#86)

Artur Rok8524962ea3b0
diff --git a/native/crates/app/src/workbench/debug_task_runner.rs b/native/crates/app/src/workbench/debug_task_runner.rs
index 11e942a94f3..2cae91c0c58 100644
--- a/native/crates/app/src/workbench/debug_task_runner.rs
+++ b/native/crates/app/src/workbench/debug_task_runner.rs
@@ -293,7 +293,10 @@ mod tests {
let themes = exthost::scan::scan_extension(&app_root.join("extensions/theme-defaults"), true).unwrap();
let theme = crate::theme::load_theme(&[themes], "Dark Modern").unwrap();
let (sender, receiver) = std::sync::mpsc::channel();
- let (workbench, cx) = cx.add_window_view(|_, cx| Workbench::new(theme, app_root.clone(), None, crate::languages::Languages::new(&[]), crate::default_settings(), crate::host_sync::HostSync::new(sender), cx));
+ // A writable User folder: `debug.onTaskErrors` must reach the settings, or the start prompts.
+ let user = std::env::temp_dir().join(format!("vsrustium-{}-{}/User", crate::test_name(), std::process::id()));
+ let settings = std::sync::Arc::new(std::sync::Mutex::new(config::service::Settings::load(config::registry::Registry::with_extensions(&[]), user, None)));
+ let (workbench, cx) = cx.add_window_view(|_, cx| Workbench::new(theme, app_root.clone(), None, crate::languages::Languages::new(&[]), settings, crate::host_sync::HostSync::new(sender), cx));
workbench.update_in(cx, |workbench, window, cx| {
workbench.tasks.matchers = crate::tasks::problem_matcher::Registry::new(&[]);
workbench.tasks.providers.push((1, "gulp".into()));
diff --git a/native/crates/app/src/workbench/opener.rs b/native/crates/app/src/workbench/opener.rs
index fbd7f11d76a..9a11f874255 100644
--- a/native/crates/app/src/workbench/opener.rs
+++ b/native/crates/app/src/workbench/opener.rs
@@ -616,6 +616,7 @@ mod tests {
assert_eq!(open("command:noop", true, Some(2)), json!(false), "refused trust");
assert_eq!(open("command:noop", true, Some(0)), json!(true), "granted trust");
assert_eq!(open("https://example.com", true, None), json!(true), "trusted workspace link");
- assert_eq!(open("https://example.com", false, None), json!(false), "the domain prompt refuses in tests");
+ // Linux tests have no X window (webview::supported needs the main thread), so the prompt is the custom dialog: Cancel.
+ assert_eq!(open("https://example.com", false, Some(3)), json!(false), "the domain prompt refuses in tests");
}
}
diff --git a/native/crates/app/src/workbench/unattended_restart.rs b/native/crates/app/src/workbench/unattended_restart.rs
index e9af9765373..0353bd44874 100644
--- a/native/crates/app/src/workbench/unattended_restart.rs
+++ b/native/crates/app/src/workbench/unattended_restart.rs
@@ -526,6 +526,7 @@ mod tests {
/// The host feeds the lock to the scheduler and runs its first evaluation, which keeps the machine awake while
/// every window could be restored and no native dialog shows; the unlock lets it sleep again.
#[gpui::test]
+ #[cfg(target_os = "macos")]
fn a_locked_screen_keeps_the_machine_awake_until_it_is_unlocked(cx: &mut gpui::TestAppContext) {
let (workbench, cx) = workbench(cx);
let update = crate::update::Update { version: "bbbb".into(), product_version: "1.148.0".into(), timestamp: 2, url: "https://example.com/a.zip".into(), sha256hash: "ab".repeat(32) };