Add SystemClock (#8239)

This PR adds a `SystemClock` trait for abstracting away the system
clock.

This allows us to swap out the real system clock with a
`FakeSystemClock` in the tests, thus allowing the fake passage of time.

We're using this in `Telemetry` to better mock the clock for testing
purposes.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-02-22 22:28:08 -05:00 committed by GitHub
parent cc8e3c2286
commit 0de8672044
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 213 additions and 55 deletions

View file

@ -34,6 +34,7 @@ channel.workspace = true
chrono = "0.4"
cli.workspace = true
client.workspace = true
clock.workspace = true
collab_ui.workspace = true
collections.workspace = true
command_palette.workspace = true

View file

@ -140,9 +140,10 @@ fn main() {
handle_keymap_file_changes(user_keymap_file_rx, cx);
client::init_settings(cx);
let clock = Arc::new(clock::RealSystemClock);
let http = http::zed_client(&client::ClientSettings::get_global(cx).server_url);
let client = client::Client::new(http.clone(), cx);
let client = client::Client::new(clock, http.clone(), cx);
let mut languages = LanguageRegistry::new(login_shell_env_loaded);
let copilot_language_server_id = languages.next_language_server_id();
languages.set_executor(cx.background_executor().clone());