zed/crates/gpui_platform
Anthony Eid d17ba5c75f gpui_platform: Stop bench feature from pulling in test-support
This mirrors the prior gpui-level fix (#63039, "gpui: Stop bench
feature from pulling in test-support") one layer down, in the platform
split crates that back gpui on macOS.

`crates/benchmarks` previously requested `gpui_platform`'s
`test-support` feature just to reach `current_headless_renderer()`, the
real Metal-backed headless renderer used by `#[gpui::bench]` consumers
to render scenes without a window. That feature also enables
`gpui_platform`'s and `gpui_macos`'s and `gpui_apple`'s interactive
test-double code, none of which a benchmark should compile alongside
its production code.

Each platform crate now exposes a narrower `bench` feature alongside
its existing `test-support` feature:

- `gpui_apple`: `bench = ["gpui/bench"]` gates the same headless Metal
  renderer APIs (`MetalHeadlessRenderer`, `render_scene`,
  `render_scene_to_image`, and their supporting state) under
  `cfg(any(test, feature = "test-support", feature = "bench"))` instead
  of only `cfg(any(test, feature = "test-support"))`.
- `gpui_macos`: `bench = ["gpui/bench", "gpui_apple/bench"]` re-exports
  `MetalHeadlessRenderer` under the same widened cfg.
- `gpui_platform`: `bench = ["gpui/bench", "gpui_macos/bench"]` gates
  `current_headless_renderer()` under
  `cfg(any(feature = "test-support", feature = "bench"))` instead of
  only `cfg(feature = "test-support")`.

`crates/benchmarks` now depends on `gpui_platform` with `["bench",
"font-kit"]` instead of `["test-support", "font-kit"]`.

`script/check-gpui-bench-feature-isolation` gains a macOS-only check
that walks `cargo tree --invert` for `benchmarks` against
`gpui_platform`, `gpui_macos`, and `gpui_apple` and fails if any of
them still resolve `test-support`, the same shape as the existing
gpui-level check.

Before this change, `cargo tree -p benchmarks --edges features
--invert gpui_platform` (and the `gpui_macos`/`gpui_apple` equivalents)
showed a `test-support` edge from `benchmarks`. After this change, the
same commands show only `bench` edges; `test-support` no longer
appears for any of the three platform crates.

Validation performed on this stack:
- `cargo check -p gpui_apple --no-default-features --features bench`,
  same for `gpui_macos` and `gpui_platform`, all bench-only (no
  test-support), all pass.
- All four `benchmarks` bench targets compile.
- `cargo tree` before/after comparison for `benchmarks` against each
  platform crate confirms the `test-support` edge is gone and replaced
  by `bench`.
- `script/check-gpui-bench-feature-isolation` passes, including the new
  macOS-only platform-crate loop.
- `gpui_apple` and `gpui_macos` test suites pass.
- `gpui_platform`'s test failure is pre-existing and reproduces on the
  base branch, unrelated to this change.
- `cargo fmt --check` and targeted `clippy` pass for the touched
  crates.

Remaining edges out of scope: `crates/benchmarks/Cargo.toml` still
requests `test-support` from several application crates (`agent`,
`editor`, `language`, `language_model`, `lsp`, `project`, `settings`,
`theme`, `util`) to build fixtures and harnesses those benchmarks
exercise. Those are unrelated to the gpui platform split this change
addresses and are left untouched.

Release Notes:

- N/A
2026-08-21 15:02:44 -04:00
..
src gpui_platform: Stop bench feature from pulling in test-support 2026-08-21 15:02:44 -04:00
Cargo.toml gpui_platform: Stop bench feature from pulling in test-support 2026-08-21 15:02:44 -04:00
LICENSE-APACHE gpui: Extract gpui_platform out of gpui (#49277) 2026-02-19 18:57:49 +01:00