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:
parent
066cdc2297
commit
10d3ad4e33
22 changed files with 107 additions and 52 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
@ -101,7 +101,6 @@ jobs:
|
|||
- name: Build other binaries and features
|
||||
run: cargo build --workspace --bins --all-features; cargo check -p gpui --features "macos-blade"
|
||||
|
||||
# todo(linux): Actually run the tests
|
||||
linux_tests:
|
||||
timeout-minutes: 60
|
||||
name: (Linux) Run Clippy and tests
|
||||
|
@ -120,6 +119,9 @@ jobs:
|
|||
- name: cargo clippy
|
||||
run: cargo xtask clippy
|
||||
|
||||
- name: Run tests
|
||||
uses: ./.github/actions/run_tests
|
||||
|
||||
- name: Build Zed
|
||||
run: cargo build -p zed
|
||||
|
||||
|
|
|
@ -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 = db
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -575,7 +575,8 @@ async fn test_save_as_remote(cx1: &mut gpui::TestAppContext, cx2: &mut gpui::Tes
|
|||
|
||||
let 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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 _;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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, |_| {});
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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ˇ»;
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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 = (
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()>) {
|
||||
|
|
|
@ -69,6 +69,7 @@ impl TextSystem {
|
|||
font("Cantarell"), // Gnome
|
||||
font("Ubuntu"), // Gnome (Ubuntu)
|
||||
font("Noto Sans"), // KDE
|
||||
font("DejaVu Sans")
|
||||
],
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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| {
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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")]
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue