Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Enable linux tests (#12493)
Mikayla Maki10d3ad4e33ed
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 3b66927411b..38ecd4228c4 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -101,7 +101,6 @@ jobs:- name: Build other binaries and featuresrun: cargo build --workspace --bins --all-features; cargo check -p gpui --features "macos-blade"- # todo(linux): Actually run the testslinux_tests:timeout-minutes: 60name: (Linux) Run Clippy and tests@@ -120,6 +119,9 @@ jobs:- name: cargo clippyrun: cargo xtask clippy+ - name: Run tests+ uses: ./.github/actions/run_tests+- name: Build Zedrun: cargo build -p zeddiff --git a/crates/collab/src/auth.rs b/crates/collab/src/auth.rsindex 915563d6b44..14c07742d4e 100644--- a/crates/collab/src/auth.rs+++ b/crates/collab/src/auth.rs@@ -277,7 +277,7 @@ mod test {#[gpui::test]async fn test_verify_access_token(cx: &mut gpui::TestAppContext) {- let test_db = crate::db::TestDb::postgres(cx.executor().clone());+ let test_db = crate::db::TestDb::sqlite(cx.executor().clone());let db = test_db.db();let user = dbdiff --git a/crates/collab/src/db/tests.rs b/crates/collab/src/db/tests.rsindex e3ce8342958..b8460c41e82 100644--- a/crates/collab/src/db/tests.rs+++ b/crates/collab/src/db/tests.rs@@ -2,6 +2,8 @@ mod buffer_tests;mod channel_tests;mod contributor_tests;mod db_tests;+// we only run postgres tests on macos right now+#[cfg(target_os = "macos")]mod embedding_tests;mod extension_tests;mod feature_flag_tests;@@ -108,6 +110,7 @@ impl TestDb {#[macro_export]macro_rules! test_both_dbs {($test_name:ident, $postgres_test_name:ident, $sqlite_test_name:ident) => {+ #[cfg(target_os = "macos")]#[gpui::test]async fn $postgres_test_name(cx: &mut gpui::TestAppContext) {let test_db = $crate::db::TestDb::postgres(cx.executor().clone());diff --git a/crates/collab/src/db/tests/db_tests.rs b/crates/collab/src/db/tests/db_tests.rsindex c78ba9ec917..92baf29837d 100644--- a/crates/collab/src/db/tests/db_tests.rs+++ b/crates/collab/src/db/tests/db_tests.rs@@ -1,9 +1,7 @@use super::*;use crate::test_both_dbs;-use gpui::TestAppContext;use pretty_assertions::{assert_eq, assert_ne};use std::sync::Arc;-use tests::TestDb;test_both_dbs!(test_get_users,@@ -564,9 +562,10 @@ fn test_fuzzy_like_string() {assert_eq!(Database::fuzzy_like_string(" z "), "%z%");}+#[cfg(target = "macos")]#[gpui::test]-async fn test_fuzzy_search_users(cx: &mut TestAppContext) {- let test_db = TestDb::postgres(cx.executor());+async fn test_fuzzy_search_users(cx: &mut gpui::TestAppContext) {+ let test_db = tests::TestDb::postgres(cx.executor());let db = test_db.db();for (i, github_login) in ["California",diff --git a/crates/collab/src/tests/dev_server_tests.rs b/crates/collab/src/tests/dev_server_tests.rsindex c5a13a431dc..932d5a55937 100644--- a/crates/collab/src/tests/dev_server_tests.rs+++ b/crates/collab/src/tests/dev_server_tests.rs@@ -575,7 +575,8 @@ async fn test_save_as_remote(cx1: &mut gpui::TestAppContext, cx2: &mut gpui::Teslet title = remote_workspace.update(&mut cx, |ws, cx| {- ws.active_item(cx).unwrap().tab_description(0, &cx).unwrap()+ let active_item = ws.active_item(cx).unwrap();+ active_item.tab_description(0, &cx).unwrap()}).unwrap();diff --git a/crates/collab/src/tests/test_server.rs b/crates/collab/src/tests/test_server.rsindex 91a0d810660..231dd08e7c4 100644--- a/crates/collab/src/tests/test_server.rs+++ b/crates/collab/src/tests/test_server.rs@@ -277,11 +277,7 @@ impl TestServer {node_runtime: FakeNodeRuntime::new(),});- let os_keymap = if cfg!(target_os = "linux") {- "keymaps/default-linux.json"- } else {- "keymaps/default-macos.json"- };+ let os_keymap = "keymaps/default-macos.json";cx.update(|cx| {theme::init(theme::LoadThemes::JustBase, cx);diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rsindex 5bed94a7ecb..4b7de01b9c0 100644--- a/crates/editor/src/display_map.rs+++ b/crates/editor/src/display_map.rs@@ -1111,14 +1111,11 @@ impl ToDisplayPoint for Anchor {#[cfg(test)]pub mod tests {use super::*;- use crate::{- movement,- test::{editor_test_context::EditorTestContext, marked_display_snapshot},- };+ use crate::{movement, test::marked_display_snapshot};use gpui::{div, font, observe, px, AppContext, BorrowAppContext, Context, Element, Hsla};use language::{language_settings::{AllLanguageSettings, AllLanguageSettingsContent},- Buffer, Language, LanguageConfig, LanguageMatcher, SelectionGoal,+ Buffer, Language, LanguageConfig, LanguageMatcher,};use project::Project;use rand::{prelude::*, Rng};@@ -1393,6 +1390,7 @@ pub mod tests {}}+ #[cfg(target_os = "macos")]#[gpui::test(retries = 5)]async fn test_soft_wraps(cx: &mut gpui::TestAppContext) {cx.background_executor@@ -1401,7 +1399,7 @@ pub mod tests {init_test(cx, |_| {});});- let mut cx = EditorTestContext::new(cx).await;+ let mut cx = crate::test::editor_test_context::EditorTestContext::new(cx).await;let editor = cx.editor.clone();let window = cx.window;@@ -1457,39 +1455,39 @@ pub mod tests {movement::up(&snapshot,DisplayPoint::new(DisplayRow(1), 10),- SelectionGoal::None,+ language::SelectionGoal::None,false,&text_layout_details,),(DisplayPoint::new(DisplayRow(0), 7),- SelectionGoal::HorizontalPosition(x.0)+ language::SelectionGoal::HorizontalPosition(x.0)));assert_eq!(movement::down(&snapshot,DisplayPoint::new(DisplayRow(0), 7),- SelectionGoal::HorizontalPosition(x.0),+ language::SelectionGoal::HorizontalPosition(x.0),false,&text_layout_details),(DisplayPoint::new(DisplayRow(1), 10),- SelectionGoal::HorizontalPosition(x.0)+ language::SelectionGoal::HorizontalPosition(x.0)));assert_eq!(movement::down(&snapshot,DisplayPoint::new(DisplayRow(1), 10),- SelectionGoal::HorizontalPosition(x.0),+ language::SelectionGoal::HorizontalPosition(x.0),false,&text_layout_details),(DisplayPoint::new(DisplayRow(2), 4),- SelectionGoal::HorizontalPosition(x.0)+ language::SelectionGoal::HorizontalPosition(x.0)));@@ -1679,6 +1677,8 @@ pub mod tests {);}+ // todo(linux) fails due to pixel differences in text rendering+ #[cfg(target_os = "macos")]#[gpui::test]async fn test_chunks_with_soft_wrapping(cx: &mut gpui::TestAppContext) {use unindent::Unindent as _;diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rsindex 73b7c4d9484..e17333a195f 100644--- a/crates/editor/src/display_map/block_map.rs+++ b/crates/editor/src/display_map/block_map.rs@@ -1157,7 +1157,7 @@ mod tests {use super::*;use crate::display_map::inlay_map::InlayMap;use crate::display_map::{fold_map::FoldMap, tab_map::TabMap, wrap_map::WrapMap};- use gpui::{div, font, px, Element};+ use gpui::{div, font, px, AssetSource, Element};use multi_buffer::MultiBuffer;use rand::prelude::*;use settings::SettingsStore;@@ -1452,6 +1452,7 @@ mod tests {}}+ #[cfg(target_os = "macos")]#[gpui::test]fn test_blocks_on_wrapped_lines(cx: &mut gpui::TestAppContext) {cx.update(|cx| init_test(cx));@@ -1940,6 +1941,12 @@ mod tests {let settings = SettingsStore::test(cx);cx.set_global(settings);theme::init(theme::LoadThemes::JustBase, cx);+ cx.text_system()+ .add_fonts(vec![assets::Assets+ .load("fonts/zed-mono/zed-mono-extended.ttf")+ .unwrap()+ .unwrap()])+ .unwrap();}impl TransformBlock {diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 19a04446ebf..1583c1e2275 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -2746,7 +2746,9 @@ impl Editor {Some(Selection { start, end, .. }) => start != end,None => false,};- pending_nonempty_selection || self.columnar_selection_tail.is_some()++ pending_nonempty_selection+ || (self.columnar_selection_tail.is_some() && self.selections.disjoint.len() > 1)}pub fn has_pending_selection(&self) -> bool {diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rsindex a767f9eabb1..65c4fadb733 100644--- a/crates/editor/src/editor_tests.rs+++ b/crates/editor/src/editor_tests.rs@@ -936,6 +936,8 @@ fn test_move_cursor(cx: &mut TestAppContext) {});}+// TODO: Re-enable this test+#[cfg(target_os = "macos")]#[gpui::test]fn test_move_cursor_multibyte(cx: &mut TestAppContext) {init_test(cx, |_| {});diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex 7be7564ce18..37efdd87af7 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -586,7 +586,7 @@ impl EditorElement {editor.handle_click_hovered_link(point, event.modifiers, cx);cx.stop_propagation();- } else if end_selection {+ } else if end_selection && pending_nonempty_selections {cx.stop_propagation();} else if cfg!(target_os = "linux") && event.button == MouseButton::Middle {if !text_hitbox.is_hovered(cx) || editor.read_only(cx) {@@ -594,7 +594,7 @@ impl EditorElement {}#[cfg(target_os = "linux")]- if let Some(item) = cx.read_from_clipboard() {+ if let Some(item) = cx.read_from_primary() {let point_for_position =position_map.point_for_position(text_hitbox.bounds, event.position);let position = point_for_position.previous_valid;diff --git a/crates/editor/src/hover_links.rs b/crates/editor/src/hover_links.rsindex 41002abd0cc..ad769b86df6 100644--- a/crates/editor/src/hover_links.rs+++ b/crates/editor/src/hover_links.rs@@ -748,9 +748,13 @@ mod tests {])))});- cx.cx- .cx- .simulate_mouse_move(screen_coord.unwrap(), None, Modifiers::command_shift());+ let modifiers = if cfg!(target_os = "macos") {+ Modifiers::command_shift()+ } else {+ Modifiers::control_shift()+ };++ cx.simulate_mouse_move(screen_coord.unwrap(), None, modifiers);requests.next().await;cx.run_until_parked();@@ -767,9 +771,7 @@ mod tests {let variable = A;"});- cx.cx- .cx- .simulate_click(screen_coord.unwrap(), Modifiers::command_shift());+ cx.simulate_click(screen_coord.unwrap(), modifiers);cx.assert_editor_state(indoc! {"struct «Aˇ»;diff --git a/crates/editor/src/test.rs b/crates/editor/src/test.rsindex 15cd9e0c35a..cf568522b13 100644--- a/crates/editor/src/test.rs+++ b/crates/editor/src/test.rs@@ -25,7 +25,7 @@ pub fn marked_display_snapshot(let (unmarked_text, markers) = marked_text_offsets(text);let font = Font {- family: "Courier".into(),+ family: "Zed Mono".into(),features: FontFeatures::default(),weight: FontWeight::default(),style: FontStyle::default(),diff --git a/crates/extension/src/extension_store_test.rs b/crates/extension/src/extension_store_test.rsindex 6f068fc460c..e55659d22b0 100644--- a/crates/extension/src/extension_store_test.rs+++ b/crates/extension/src/extension_store_test.rs@@ -510,6 +510,14 @@ async fn test_extension_store_with_gleam_extension(cx: &mut TestAppContext) {{"name": format!("gleam-{version}-aarch64-apple-darwin.tar.gz"),"browser_download_url": asset_download_uri+ },+ {+ "name": format!("gleam-{version}-x86_64-unknown-linux-musl.tar.gz"),+ "browser_download_url": asset_download_uri+ },+ {+ "name": format!("gleam-{version}-aarch64-unknown-linux-musl.tar.gz"),+ "browser_download_url": asset_download_uri}]}diff --git a/crates/gpui/src/app/test_context.rs b/crates/gpui/src/app/test_context.rsindex 80ca8edf6ad..944a95501df 100644--- a/crates/gpui/src/app/test_context.rs+++ b/crates/gpui/src/app/test_context.rs@@ -571,7 +571,11 @@ impl<V> View<V> {use postage::prelude::{Sink as _, Stream as _};let (tx, mut rx) = postage::mpsc::channel(1024);- let timeout_duration = Duration::from_millis(100);+ let timeout_duration = if cfg!(target_os = "macos") {+ Duration::from_millis(100)+ } else {+ Duration::from_secs(1)+ };let mut cx = cx.app.borrow_mut();let subscriptions = (diff --git a/crates/gpui/src/platform/keystroke.rs b/crates/gpui/src/platform/keystroke.rsindex 55f8658cd3d..fa408165a66 100644--- a/crates/gpui/src/platform/keystroke.rs+++ b/crates/gpui/src/platform/keystroke.rs@@ -296,6 +296,15 @@ impl Modifiers {}}+ /// helper method for Modifiers with command + shift+ pub fn control_shift() -> Modifiers {+ Modifiers {+ shift: true,+ control: true,+ ..Default::default()+ }+ }+/// Checks if this Modifiers is a subset of another Modifierspub fn is_subset_of(&self, other: &Modifiers) -> bool {(other.control || !self.control)diff --git a/crates/gpui/src/platform/test/platform.rs b/crates/gpui/src/platform/test/platform.rsindex 19b45a801fb..f73ec5216a2 100644--- a/crates/gpui/src/platform/test/platform.rs+++ b/crates/gpui/src/platform/test/platform.rs@@ -27,6 +27,7 @@ pub(crate) struct TestPlatform {current_primary_item: Mutex<Option<ClipboardItem>>,pub(crate) prompts: RefCell<TestPrompts>,pub opened_url: RefCell<Option<String>>,+ pub text_system: Arc<dyn PlatformTextSystem>,weak: Weak<Self>,}@@ -44,6 +45,15 @@ impl TestPlatform {.expect("unable to initialize Windows OLE");}+ #[cfg(target_os = "macos")]+ let text_system = Arc::new(crate::platform::mac::MacTextSystem::new());++ #[cfg(target_os = "linux")]+ let text_system = Arc::new(crate::platform::cosmic_text::CosmicTextSystem::new());++ #[cfg(target_os = "windows")]+ let text_system = Arc::new(crate::platform::windows::DirectWriteTextSystem::new().unwrap());+Rc::new_cyclic(|weak| TestPlatform {background_executor: executor,foreground_executor,@@ -56,6 +66,7 @@ impl TestPlatform {current_primary_item: Mutex::new(None),weak: weak.clone(),opened_url: Default::default(),+ text_system,})}@@ -132,14 +143,7 @@ impl Platform for TestPlatform {}fn text_system(&self) -> Arc<dyn PlatformTextSystem> {- #[cfg(target_os = "macos")]- return Arc::new(crate::platform::mac::MacTextSystem::new());-- #[cfg(target_os = "linux")]- return Arc::new(crate::platform::cosmic_text::CosmicTextSystem::new());-- #[cfg(target_os = "windows")]- return Arc::new(crate::platform::windows::DirectWriteTextSystem::new().unwrap());+ self.text_system.clone()}fn run(&self, _on_finish_launching: Box<dyn FnOnce()>) {diff --git a/crates/gpui/src/text_system.rs b/crates/gpui/src/text_system.rsindex 5cfec6a15eb..8c6dcb50ca4 100644--- a/crates/gpui/src/text_system.rs+++ b/crates/gpui/src/text_system.rs@@ -69,6 +69,7 @@ impl TextSystem {font("Cantarell"), // Gnomefont("Ubuntu"), // Gnome (Ubuntu)font("Noto Sans"), // KDE+ font("DejaVu Sans")],}}diff --git a/crates/gpui/src/text_system/line_wrapper.rs b/crates/gpui/src/text_system/line_wrapper.rsindex a4f407e1fa6..28e450d9b45 100644--- a/crates/gpui/src/text_system/line_wrapper.rs+++ b/crates/gpui/src/text_system/line_wrapper.rs@@ -143,21 +143,28 @@ impl Boundary {#[cfg(test)]mod tests {use super::*;- use crate::{font, TestAppContext, TestDispatcher, TextRun, WindowTextSystem, WrapBoundary};+ use crate::{font, TestAppContext, TestDispatcher};+ #[cfg(target_os = "macos")]+ use crate::{TextRun, WindowTextSystem, WrapBoundary};use rand::prelude::*;#[test]fn test_wrap_line() {let dispatcher = TestDispatcher::new(StdRng::seed_from_u64(0));let cx = TestAppContext::new(dispatcher, None);+ cx.text_system()+ .add_fonts(vec![std::fs::read(+ "../../assets/fonts/zed-mono/zed-mono-extended.ttf",+ )+ .unwrap()+ .into()])+ .unwrap();+ let id = cx.text_system().font_id(&font("Zed Mono")).unwrap();cx.update(|cx| {let text_system = cx.text_system().clone();- let mut wrapper = LineWrapper::new(- text_system.font_id(&font("Courier")).unwrap(),- px(16.),- text_system.platform_text_system.clone(),- );+ let mut wrapper =+ LineWrapper::new(id, px(16.), text_system.platform_text_system.clone());assert_eq!(wrapper.wrap_line("aa bbb cccc ddddd eeee", px(72.))@@ -213,8 +220,11 @@ mod tests {}// For compatibility with the test macro+ #[cfg(target_os = "macos")]use crate as gpui;+ // These seem to vary wildly based on the the text system.+ #[cfg(target_os = "macos")]#[crate::test]fn test_wrap_shaped_line(cx: &mut TestAppContext) {cx.update(|cx| {diff --git a/crates/project/src/project_tests.rs b/crates/project/src/project_tests.rsindex 293a8d58673..29a27faef24 100644--- a/crates/project/src/project_tests.rs+++ b/crates/project/src/project_tests.rs@@ -24,7 +24,7 @@ async fn test_block_via_channel(cx: &mut gpui::TestAppContext) {let (tx, mut rx) = futures::channel::mpsc::unbounded();let _thread = std::thread::spawn(move || {- std::fs::metadata("/Users").unwrap();+ std::fs::metadata("/tmp").unwrap();std::thread::sleep(Duration::from_millis(1000));tx.unbounded_send(1).unwrap();});diff --git a/crates/storybook/build.rs b/crates/storybook/build.rsindex 4975cd33b75..ec0e8944f5a 100644--- a/crates/storybook/build.rs+++ b/crates/storybook/build.rs@@ -1,7 +1,10 @@fn main() {// Find WebRTC.framework as a sibling of the executable when running outside of an application bundle.// TODO: We shouldn't depend on WebRTC in editor- println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path");+ #[cfg(target_os = "macos")]+ {+ println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path");+ }#[cfg(target_os = "windows")]{diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rsindex 590f0fea14e..7a2d6fa5e8d 100644--- a/crates/vim/src/test.rs+++ b/crates/vim/src/test.rs@@ -400,6 +400,7 @@ async fn test_join_lines(cx: &mut gpui::TestAppContext) {"});}+#[cfg(target_os = "macos")]#[gpui::test]async fn test_wrapped_lines(cx: &mut gpui::TestAppContext) {let mut cx = NeovimBackedTestContext::new(cx).await;@@ -706,6 +707,7 @@ async fn test_selection_goal(cx: &mut gpui::TestAppContext) {Lorem Ipsum"});}+#[cfg(target_os = "macos")]#[gpui::test]async fn test_wrapped_motions(cx: &mut gpui::TestAppContext) {let mut cx = NeovimBackedTestContext::new(cx).await;