# Extract a scheduler crate from GPUI to enable unified integration testing of client and server code \(\#37326\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/1ae326432e7bda2e89fd63e59a56c082277106b4)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 1ae326432e7bda2e89fd63e59a56c082277106b4

Requested commit: 1ae326432e7bda2e89fd63e59a56c082277106b4

Commit: 1ae326432e7bda2e89fd63e59a56c082277106b4

Tree: 60a311fde242b04d3c827441521a368e66014608

Author: Nathan Sobo

Committer: GitHub

## Message

```
Extract a scheduler crate from GPUI to enable unified integration testing of client and server code (#37326)

Extracts and cleans up GPUI's scheduler code into a new `scheduler`
crate, making it pluggable by external runtimes. This will enable
deterministic integration testing with cloud components by providing a
unified test scheduler across Zed and backend code. In Zed, it will
replace the existing GPUI scheduler for consistent async task management
across platforms.

## Changes

- **Core Implementation**: `TestScheduler` with seed-based
randomization, session tracking (`SessionId`), and foreground/background
task separation for reproducible testing.
- **Executors**: `ForegroundExecutor` (!Send, thread-local) and
`BackgroundExecutor` (Send, with blocking/timeout support) as
GPUI-compatible wrappers.
- **Clock and Timer**: Controllable `TestClock` and future-based `Timer`
for time-sensitive tests.
- **Testing APIs**: `once()`, `with_seed()`, and `many()` methods for
configurable test runs.
- **Dependencies**: Added `async-task`, `chrono`, `futures`, etc., with
updates to `Cargo.toml` and lock file.

## Benefits

- **Integration Testing**: Facilitates reliable async tests involving
cloud sessions, reducing flakiness via deterministic execution.
- **Pluggability**: Trait-based design (`Scheduler`) allows easy
integration into non-GPUI runtimes while maintaining GPUI compatibility.
- **Cleanup**: Refactors GPUI scheduler logic for clarity, correctness
(no `unwrap()`, proper error handling), and extensibility.

Follows Rust guidelines; run `./script/clippy` for verification.

- [x] Define and test a core scheduler that we think can power our cloud
code and GPUI
- [ ] Replace GPUI's scheduler


Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
```

## Parents

- [a05f86f97bd69569d256229007bc51daacf1be22](https://git.cafe/gitcafe/zed/commit/a05f86f97bd69569d256229007bc51daacf1be22?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/1ae326432e7bda2e89fd63e59a56c082277106b4?format=markdown)
