Enable linux tests (#12493)

Note:
- We have disabled all tests that rely on Postgres in the Linux CI. We
only really need to test these once, and as macOS is our team's primary
platform, we'll only enable them on macOS for local reproduction.
- We have disabled all tests that rely on the font metrics. We
standardized on Zed Mono in many fonts, but our CoreText Text System and
Cosmic Text System proved to be very different in effect. We should
revisit if we decide to standardize our text system across platforms
(e.g. using Harfbuzz everywhere)
- Extended the condition timeout significantly. Our CI machines are slow
enough that this is causing spurious errors in random tests.

Release Notes:

- N/A

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Mikayla Maki
2024-06-13 16:38:53 -07:00
committed by GitHub
co-authored by Conrad Irwin
parent 066cdc2297
commit 10d3ad4e33
22 changed files with 107 additions and 52 deletions
+5 -1
View File
@@ -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 = (
+9
View File
@@ -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 Modifiers
pub fn is_subset_of(&self, other: &Modifiers) -> bool {
(other.control || !self.control)
+12 -8
View File
@@ -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()>) {
+1
View File
@@ -69,6 +69,7 @@ impl TextSystem {
font("Cantarell"), // Gnome
font("Ubuntu"), // Gnome (Ubuntu)
font("Noto Sans"), // KDE
font("DejaVu Sans")
],
}
}
+16 -6
View File
@@ -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| {