This commit is contained in:
Mikayla 2023-11-06 11:18:56 -08:00
parent d66ed4310f
commit 75a80811b3
No known key found for this signature in database
5 changed files with 15 additions and 2 deletions

View file

@ -124,6 +124,7 @@ impl TestServer {
if cx.has_global::<SettingsStore>() {
panic!("Same cx used to create two test clients")
}
cx.set_global(SettingsStore::test(cx));
});

View file

@ -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)]

View file

@ -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::<SettingsStore>() {
panic!("Same cx used to create two test clients")
}

View file

@ -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<G: 'static>(&self) -> &G {
self.globals_by_type
.get(&TypeId::of::<G>())
@ -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<G: 'static>(&mut self) -> &mut G {
let global_type = TypeId::of::<G>();
self.push_effect(Effect::NotifyGlobalObservers { global_type });

View file

@ -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::<SettingsStore>().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::<SettingsStore>().get(None)
}
#[track_caller]
fn override_global<'a>(settings: Self, cx: &'a mut AppContext)
where
Self: Sized,