From 75a80811b3bc43ef77b09487d3907514c857f592 Mon Sep 17 00:00:00 2001 From: Mikayla Date: Mon, 6 Nov 2023 11:18:56 -0800 Subject: [PATCH] WIP --- crates/collab/src/tests/test_server.rs | 1 + crates/collab2/collab/src/tests/integration_tests.rs | 10 ++++++++-- crates/collab2/src/tests/test_server.rs | 1 + crates/gpui2/src/app.rs | 2 ++ crates/settings2/src/settings_store.rs | 3 +++ 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/collab/src/tests/test_server.rs b/crates/collab/src/tests/test_server.rs index d6ebe1e84e..245f34ebac 100644 --- a/crates/collab/src/tests/test_server.rs +++ b/crates/collab/src/tests/test_server.rs @@ -124,6 +124,7 @@ impl TestServer { if cx.has_global::() { panic!("Same cx used to create two test clients") } + cx.set_global(SettingsStore::test(cx)); }); diff --git a/crates/collab2/collab/src/tests/integration_tests.rs b/crates/collab2/collab/src/tests/integration_tests.rs index b9cd79453a..7dde04ee57 100644 --- a/crates/collab2/collab/src/tests/integration_tests.rs +++ b/crates/collab2/collab/src/tests/integration_tests.rs @@ -3223,12 +3223,16 @@ async fn test_local_settings( cx_b: &mut TestAppContext, ) { deterministic.forbid_parking(); + dbg!("HERE111"); let mut server = TestServer::start(&deterministic).await; + dbg!("HERE"); let client_a = server.create_client(cx_a, "user_a").await; + dbg!("HERE2"); let client_b = server.create_client(cx_b, "user_b").await; server .create_room(&mut [(&client_a, cx_a), (&client_b, cx_b)]) .await; + dbg!("HERE4"); let active_call_a = cx_a.read(ActiveCall::global); // As client A, open a project that contains some local settings files @@ -3259,6 +3263,7 @@ async fn test_local_settings( .await .unwrap(); + dbg!("HERE6"); // As client B, join that project and observe the local settings. let project_b = client_b.build_remote_project(project_id, cx_b).await; let worktree_b = project_b.read_with(cx_b, |project, cx| project.worktrees(cx).next().unwrap()); @@ -3317,11 +3322,11 @@ async fn test_local_settings( ] ) }); - + dbg!("GOT TO THE DISCONNECT"); // As client B, disconnect. server.forbid_connections(); server.disconnect_client(client_b.peer_id().unwrap()); - + dbg!("GOT PAST DISCONNECT"); // As client A, change and remove settings files while client B is disconnected. client_a .fs() @@ -3344,6 +3349,7 @@ async fn test_local_settings( &[(Path::new("a").into(), r#"{"hard_tabs":true}"#.to_string()),] ) }); + dbg!("GOT TO THE END"); } #[gpui::test(iterations = 10)] diff --git a/crates/collab2/src/tests/test_server.rs b/crates/collab2/src/tests/test_server.rs index 76a587ffde..ddbfd4a495 100644 --- a/crates/collab2/src/tests/test_server.rs +++ b/crates/collab2/src/tests/test_server.rs @@ -122,6 +122,7 @@ impl TestServer { pub async fn create_client(&mut self, cx: &mut TestAppContext, name: &str) -> TestClient { cx.update(|cx| { + println!("PLS SHOW UP"); if cx.has_global::() { panic!("Same cx used to create two test clients") } diff --git a/crates/gpui2/src/app.rs b/crates/gpui2/src/app.rs index 1b5af755b3..05ab7b2932 100644 --- a/crates/gpui2/src/app.rs +++ b/crates/gpui2/src/app.rs @@ -706,6 +706,7 @@ impl AppContext { } /// Access the global of the given type. Panics if a global for that type has not been assigned. + #[track_caller] pub fn global(&self) -> &G { self.globals_by_type .get(&TypeId::of::()) @@ -722,6 +723,7 @@ impl AppContext { } /// Access the global of the given type mutably. Panics if a global for that type has not been assigned. + #[track_caller] pub fn global_mut(&mut self) -> &mut G { let global_type = TypeId::of::(); self.push_effect(Effect::NotifyGlobalObservers { global_type }); diff --git a/crates/settings2/src/settings_store.rs b/crates/settings2/src/settings_store.rs index 3317a50f52..5bf10a518d 100644 --- a/crates/settings2/src/settings_store.rs +++ b/crates/settings2/src/settings_store.rs @@ -86,6 +86,7 @@ pub trait Settings: 'static + Send + Sync { }); } + #[track_caller] fn get<'a>(path: Option<(usize, &Path)>, cx: &'a AppContext) -> &'a Self where Self: Sized, @@ -93,6 +94,7 @@ pub trait Settings: 'static + Send + Sync { cx.global::().get(path) } + #[track_caller] fn get_global<'a>(cx: &'a AppContext) -> &'a Self where Self: Sized, @@ -100,6 +102,7 @@ pub trait Settings: 'static + Send + Sync { cx.global::().get(None) } + #[track_caller] fn override_global<'a>(settings: Self, cx: &'a mut AppContext) where Self: Sized,