Visual Studio Code, rebuilt in Rust
Rust
build(tools): fail loudly on broken or empty test runs and bound native/target with cargo gc (#25)
Artur Rokdeb28d81d80a
diff --git a/.agents/skills/port-crew/SKILL.md b/.agents/skills/port-crew/SKILL.mdnew file mode 100644index 00000000000..7061e392173--- /dev/null+++ b/.agents/skills/port-crew/SKILL.md@@ -0,0 +1,31 @@+---+name: port-crew+description: Brief and land worker sessions on the port. Use when starting a session or subagent on a port task in its own worktree, or when merging a worker's branch into main.+---++# Port crew++A coordinator splits port work across workers, each in its own worktree and branch, and lands their branches on main one at a time.++## Brief a worker++A brief is the task, then the contract.++The task names each ledger row with the `rg` command that finds it (`rg -n '^\| workbench/contrib/scm ' port/ledger.md`), each gap by its words in the gaps cell and its `path:line`, the upstream files it follows, and the check that proves it (a `port/tools/cargo-test` filter, a ui-pair fixture). Name the files another worker owns.++Then the contract, verbatim with the placeholders filled:++```+Read AGENTS.md first and follow it. Work only in this worktree (<path>, branch <branch>). Other sessions work in <worktrees>: leave those checkouts alone and keep your diff to the files this task needs, so the merges stay clean. Commit in small commits; do not push, merge or open a PR. A closed gap leaves its ledger cell and the row's status changes in the commit that closes it; `bun port/tools/ledger-check.ts` passes. Done when every gap named above is closed with its check passing, or written back to its ledger cell with why it stays open. Final answer: per gap, closed with the command and its real result, or open and why; then the branch and its commits.+```++Done when every gap in the brief has its check and the contract has no placeholder left.++## Land a worker's branch++1. Start a fresh worktree at the main branch and rebase the worker's commits onto it.+2. Resolve conflicts. `README.md`'s coverage block is generated: take either side, then `bun port/tools/readme-coverage.ts`. A `port/ledger.md` row both sides changed keeps only the gaps neither side closed, with the status those gaps allow.+3. Run `bun port/tools/ledger-check.ts`, `bun test port/tools`, `port/tools/cargo-test -p app` and `port/tools/cargo-test -p exthost`, where AGENTS.md says tests run.+4. Push to main only when the owner asked for it. Then remove the landing worktree and the worker's.++Done when the checks pass and the branch is on main, or the report names the check that fails.diff --git a/.worktreeinclude b/.worktreeincludenew file mode 100644index 00000000000..045951300cf--- /dev/null+++ b/.worktreeinclude@@ -0,0 +1 @@+upstreamdiff --git a/AGENTS.md b/AGENTS.mdindex affd83a7eaf..d284ee827f9 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -18,11 +18,12 @@ Rules:- Port 1:1: match upstream 1.148.0's behavior, look and tests, citing the upstream file. A difference is a decision in `port/notes.md` or a ledger row that is not `verified`.- Builds, tests and GUI runs go to the Studio: `port/tools/studio '<cmd>'`, GUI tools with `port/tools/studio --lane '<cmd>'`.+- Run tests with `port/tools/cargo-test [-p <crate>] <filter>`, and every other cargo command as `cargo gc <cmd>` (bounds `native/target`): only failures and summaries, and a filter that matches nothing fails.- Markdown: one paragraph per source line, no hard wrapping.- UI labels use title-style capitalization, as upstream's.- The repository is public: no credentials, personal data or internal links in code, commits or docs.- Remove temporary files and scripts made while working.-- `unsafe` only in `app` and `exthost`, each block under a `// SAFETY:` comment that names the fact it relies on, its file a row of the inventory in `docs/memory-safety.md`. The check: `cargo clippy -p app -p exthost --all-targets -- -A clippy::all`.+- `unsafe` only in `app` and `exthost`, each block under a `// SAFETY:` comment that names the fact it relies on, its file a row of the inventory in `docs/memory-safety.md`. The check: `cargo gc clippy -p app -p exthost --all-targets -- -A clippy::all`.- No I/O and no work in proportion to the whole document or tree on the main thread in a hot path. A change to a hot path reports the numbers of its gate (`docs/performance.md`) from before and after.- Before writing a piece that is new to the project from scratch, read how 2 or 3 open-source projects do it, and name them with the choice in `port/notes.md`.- Documents cite code as a path plus a symbol, never a line number. After a rename, a move or a deleted symbol: `bun port/tools/docs-check.ts`.diff --git a/ARCHITECTURE.md b/ARCHITECTURE.mdindex 8d648a9c346..1c8fb6b7a71 100644--- a/ARCHITECTURE.md+++ b/ARCHITECTURE.md@@ -182,7 +182,7 @@ The tools in `port/tools` each start with a header that states their use. The ma## Build, packaging, release- Build inputs. The build needs the upstream checkout: `native/vscode_src.rs` resolves it for the build scripts. `app/build.rs` makes the NLS index from upstream's `localize` calls and renders the Dock icons. A few modules embed upstream files, and tests read upstream fixtures. A binary outside a package also reads the checkout at run time as its app root: `product.json`, icons and the built-in extensions.-- Build order. Compile upstream once, run `bun port/tools/build-exthost`, then `cargo build --release -p app`. `README.md` has the commands. The debug profile builds dependencies with optimization and the port's crates without (`native/Cargo.toml`).+- Build order. Compile upstream once, run `bun port/tools/build-exthost`, then `cargo gc build --release -p app`. `README.md` has the commands. The debug profile builds dependencies with optimization and the port's crates without (`native/Cargo.toml`).- Packaging. `port/tools/package-app` makes the signed macOS app and its update files. `port/tools/package-linux` makes the Linux archive. `port/tools/app-files.ts` lists the files a package ships.- CI. `.github/workflows/ci.yml` runs the repository checks and every crate's tests on macOS, Linux and Windows for each push to `main` and each pull request. `.github/workflows/linux.yml` and `.github/workflows/windows.yml` build a package by hand. A release is a manual step.diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex ee17da0e497..6c7078b3616 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -4,13 +4,13 @@ VSRustium is a 1:1 port of VS Code 1.148.0 to Rust and [GPUI](https://www.gpui.r## Setup-You need Rust (stable), [Bun](https://bun.sh) 1.4.5 and Node.js 24 (for VS Code's own install and compile).+You need Rust (stable) with [cargo-gc](https://cargo-gc.leostera.dev) 0.2.0 (`cargo install cargo-gc --version 0.2.0 --locked`), [Bun](https://bun.sh) 1.4.5 and Node.js 24 (for VS Code's own install and compile). Every cargo command runs as `cargo gc <cmd>`: it removes the build artifacts no recent build used, so `native/target` stays bounded.```shgit clone --branch 1.148.0 --depth 1 https://github.com/microsoft/vscode upstream(cd upstream && npx -y [email protected] install && npx -y [email protected] run compile)bun port/tools/build-exthost-(cd native && cargo build --release -p app)+(cd native && cargo gc build --release -p app)native/target/release/vsrustium```@@ -32,9 +32,9 @@ native/target/release/vsrustium## The bar for a change- Match upstream 1.148.0: its behavior, look and tests. Cite the upstream file the change follows. A deliberate difference is a decision in `port/notes.md`.-- A fix comes with a test that fails without it (`cargo test -p app <name>`).+- A fix comes with a test that fails without it (`port/tools/cargo-test <name>`).- A UI change comes with a side-by-side check against VS Code: `port/tools/pixel-check` for still windows, `port/tools/ui-pair` for states reached by clicks and keys.-- An `unsafe` block has a `// SAFETY:` comment and its file a row in the inventory of [docs/memory-safety.md](docs/memory-safety.md). `cargo clippy -p app -p exthost --all-targets -- -A clippy::all` fails without the comment, `bun port/tools/docs-check.ts` without the row.+- An `unsafe` block has a `// SAFETY:` comment and its file a row in the inventory of [docs/memory-safety.md](docs/memory-safety.md). `cargo gc clippy -p app -p exthost --all-targets -- -A clippy::all` fails without the comment, `bun port/tools/docs-check.ts` without the row.- A change to a hot path comes with the numbers of its gate from before and after ([docs/performance.md](docs/performance.md)).- Commits follow [Conventional Commits](https://www.conventionalcommits.org): `fix(titlebar): draw disabled Go Back in disabledForeground`.- Markdown: one paragraph per source line, no hard wrapping. UI labels use title-style capitalization, as upstream's.diff --git a/README.md b/README.mdindex 861e2c465df..03f7535a3a8 100644--- a/README.md+++ b/README.md@@ -109,13 +109,14 @@ Counted from the agent session logs, each call once; cost at OpenRouter list pri## Build-Rust (stable), [Bun](https://bun.sh) 1.4.5 and Node.js 24:+Rust (stable) with [cargo-gc](https://cargo-gc.leostera.dev) 0.2.0, [Bun](https://bun.sh) 1.4.5 and Node.js 24:```shgit clone --branch 1.148.0 --depth 1 https://github.com/microsoft/vscode upstream(cd upstream && npx -y [email protected] install && npx -y [email protected] run compile)+cargo install cargo-gc --version 0.2.0 --lockedbun port/tools/build-exthost-(cd native && cargo build --release -p app)+(cd native && cargo gc build --release -p app)native/target/release/vsrustium```diff --git a/docs/extension-host.md b/docs/extension-host.mdindex 2b63518471e..d7d20593f0d 100644--- a/docs/extension-host.md+++ b/docs/extension-host.md@@ -68,7 +68,7 @@ The workbench does not need a running host to know what extensions contribute. `## Check a change-- `cargo test -p exthost` runs the protocol and session tests without a host.+- `port/tools/cargo-test -p exthost` runs the protocol and session tests without a host.- `exthost/src/bin/exthost-probe.rs` starts a real host without a window, activates every built-in extension and prints a report.- `port/tools/api-tests` runs upstream's `vscode-api-tests` against the port. This is the check for any change to a main thread class.- `port/tools/extension-tests` runs the integration tests of one built-in extension.diff --git a/docs/memory-safety.md b/docs/memory-safety.mdindex 40cec10710f..9154beb3dbf 100644--- a/docs/memory-safety.md+++ b/docs/memory-safety.md@@ -89,9 +89,9 @@ Each check fails on a violation. "Shown red" names the planted violation that prNotes on the checks:- Clippy sees only the code of the OS it builds for, so the gate is one run per OS. `-A clippy::all` turns the other clippy lints off: the run is only the memory safety gate. All three run from a laptop through the Studio:- - macOS: `port/tools/studio 'cd native && cargo clippy --workspace --all-targets --locked -- -A clippy::all'`+ - macOS: `port/tools/studio 'cd native && cargo gc clippy --workspace --all-targets --locked -- -A clippy::all'`- Windows: `port/tools/windows-build 'cargo xwin clippy -p app -p exthost --all-targets --target x86_64-pc-windows-msvc --locked -- -A clippy::all'`- - Linux: `port/tools/linux-build 'cd native && rustup component add clippy && cargo clippy --workspace --all-targets --locked -- -A clippy::all'`. The image of `port/tools/linux/Dockerfile` has no clippy, so each run adds it.+ - Linux: `port/tools/linux-build 'cd native && rustup component add clippy && cargo gc clippy --workspace --all-targets --locked -- -A clippy::all'`. The image of `port/tools/linux/Dockerfile` has no clippy, so each run adds it.- An ignored advisory in `native/deny.toml` has a reason. If the reason no longer holds, remove the entry.- `.github/workflows/ci.yml` runs clippy in each `test` job, so once per OS. The Linux and Windows jobs are `expected-red` until their tests pass: a clippy failure there shows in the job but does not fail the workflow. Until then the `port/tools/windows-build` and `port/tools/linux-build` commands of this list are the gate for those two.diff --git a/docs/performance.md b/docs/performance.mdindex 6d2323f85a9..77c5c6382d8 100644--- a/docs/performance.md+++ b/docs/performance.md@@ -67,7 +67,7 @@ Each rule has a regression behind it. `port/notes.md` ("Benchmarks", "SchedulingMeasure a release build. The debug profile builds the port's crates without optimization (`native/Cargo.toml`), so a debug build is much slower and points at the wrong places.- The whole app: `port/tools/bench`. Its header has the method. `port/results/benchmark.md` has the full command and how to read the numbers.-- Frame times without a window: the ignored tests of [Budgets](#frame-times-measured-inside-tests), with `cargo test --release -p app -- --ignored <name> --nocapture`. They draw a real workbench without a GPU.+- Frame times without a window: the ignored tests of [Budgets](#frame-times-measured-inside-tests), with `cargo gc test --release -p app -- --ignored <name> --nocapture`. They draw a real workbench without a GPU.- A benchmark of one GPUI path with Criterion: the skill in `.agents/skills/gpui-bench` has the rules. The main one: no `test-support` feature in a benchmark, or it measures test code.- Where the time goes: `sample <pid>` or Instruments (Time Profiler, `xctrace record --template 'Time Profiler'`) on the release app. For "who caused this draw", add `#[track_caller]` logging to `notify` for the run.- Startup phases: `Developer: Startup Performance` in the app shows the `code/...` marks of `app/src/perf.rs`.@@ -79,9 +79,9 @@ The machine is shared, and its load changes a time by about 30%. Check the load| Gate | Command | Fails when ||---|---|---|| Whole-app budgets | `port/tools/bench > run.tsv`, then `bun port/tools/bench-check.ts run.tsv` | A median is over its budget by more than its margin |-| Typing | `cargo test --release -p app -- --ignored typing_latency_on_a_large_file --nocapture` | p95 per edit is 16 ms or more |-| Scroll frames | `cargo test --release -p app -- --ignored scroll_frame_time --nocapture --test-threads=1` | A median or p95 is 8 ms or more |-| Render counts | `cargo test -p app part_view` | A part draws that did not change |+| Typing | `cargo gc test --release -p app -- --ignored typing_latency_on_a_large_file --nocapture` | p95 per edit is 16 ms or more |+| Scroll frames | `cargo gc test --release -p app -- --ignored scroll_frame_time --nocapture --test-threads=1` | A median or p95 is 8 ms or more |+| Render counts | `port/tools/cargo-test part_view` | A part draws that did not change |`port/tools/bench-check.ts` reads the output of `port/tools/bench` and `port/budgets.json`. It prints each metric with its limit and exits 1 on a failure. `port/tools/bench-check.test.ts` shows it red on a planted regression.diff --git a/docs/testing.md b/docs/testing.mdindex 79a65a7cbbd..9ebf60a44b4 100644--- a/docs/testing.md+++ b/docs/testing.md@@ -4,7 +4,9 @@ The port's bar is "the same as VS Code", so most checks compare with upstream: i## Where tests run-Builds and tests run on the build machine (the Studio), not on a laptop: `port/tools/studio 'cd native && cargo test -p app <name>'`. The tool mirrors the checkout, uncommitted changes included, and runs the command there. A tool that opens a window runs in a GUI lane: `port/tools/studio --lane '<command>'`. `port/tools/linux-build` and `port/tools/windows-build` run a command for the other two systems.+Builds and tests run on the build machine (the Studio), not on a laptop: `port/tools/studio 'port/tools/cargo-test <name>'`. The tool mirrors the checkout, uncommitted changes included, and runs the command there. A tool that opens a window runs in a GUI lane: `port/tools/studio --lane '<command>'`. `port/tools/linux-build` and `port/tools/windows-build` run a command for the other two systems.++`port/tools/cargo-test [-p <crate>] [<filter>...]` (default crate `app`) runs `cargo gc test` in `native/` and prints only compile errors, failed tests and the summary lines. It exits non-zero when cargo fails or when the filter matches no test, where `cargo test ... | rg` passes on both. Use it on any machine, through `port/tools/studio` too.`.github/workflows/ci.yml` runs on each push to `main` and each pull request: the repository checks (`ledger-check`, the tests of `port/tools`, `docs-check`, licenses, advisories) and `cargo test --workspace` on macOS, Linux and Windows. The Linux and Windows jobs are `expected-red` until milestones M23 and M24 close their test gaps. The checks that need the reference app and a window do not run there.@@ -16,7 +18,7 @@ The workspace has about 4000 tests. The `app` suite takes about a minute after t|---|---|---|| Unit tests of a model | The logic matches upstream's test cases. | `#[test]` beside the module, in a `tests.rs` file or a `tests` module || Workbench tests | A feature works through keys, clicks and commands in a window. | `#[gpui::test]` in `app/src/workbench` |-| Extension host tests | The protocol and the session without a host. | `cargo test -p exthost` |+| Extension host tests | The protocol and the session without a host. | `port/tools/cargo-test -p exthost` || API tests | The extension API behaves as in VS Code. | `port/tools/api-tests`, `port/tools/extension-tests` || Pixel checks | A still window looks the same. | `port/tools/pixel-check` || Paired UI runs | A state reached by input looks the same. | `port/tools/ui-pair` with step files in `port/fixtures/ui-steps` |@@ -67,7 +69,7 @@ A test with `#[ignore = "test.skip upstream"]` mirrors a test that upstream skip## Before a report or a commit1. The narrowest check of the unit you changed.-2. `cargo test` for each crate you touched.+2. `port/tools/cargo-test -p <crate>` for each crate you touched.3. `bun port/tools/ledger-check.ts` and `bun port/tools/docs-check.ts`.4. For `unsafe` code: the checks of [memory-safety.md](memory-safety.md).5. For a hot path: the gate of [performance.md](performance.md), before and after.diff --git a/native/Cargo.toml b/native/Cargo.tomlindex 5804ddb1542..164edf50ce9 100644--- a/native/Cargo.toml+++ b/native/Cargo.toml@@ -9,7 +9,7 @@ edition = "2024"license = "MIT"# The memory safety gates of docs/memory-safety.md. rustc checks the first on every build; the second is a clippy lint:-# cargo clippy --workspace --all-targets --locked -- -A clippy::all+# cargo gc clippy --workspace --all-targets --locked -- -A clippy::all[workspace.lints.rust]unsafe_op_in_unsafe_fn = "deny"diff --git a/native/crates/app/src/host_sync.rs b/native/crates/app/src/host_sync.rsindex fd114da87c4..3c9fbda9241 100644--- a/native/crates/app/src/host_sync.rs+++ b/native/crates/app/src/host_sync.rs@@ -992,7 +992,7 @@ mod tests {/// The real host on Bun takes every message of an open, an edit and a save without an error reply,/// and TypeScript reports diagnostics for the text the edit made.#[test]- #[ignore = "starts the extension host: VSCODE_GPUI_EXTENSIONS=<built extensions> cargo test -p app -- --ignored live_host"]+ #[ignore = "starts the extension host: VSCODE_GPUI_EXTENSIONS=<built extensions> cargo gc test -p app -- --ignored live_host"]fn live_host_takes_edits_and_typescript_sees_the_new_text() {use exthost::rpc::Arg;use exthost::scan::scan_builtin_extensions;diff --git a/native/crates/app/src/main.rs b/native/crates/app/src/main.rsindex 2f6c86a20e2..33bf70848c5 100644--- a/native/crates/app/src/main.rs+++ b/native/crates/app/src/main.rs@@ -876,7 +876,7 @@ fn save_screenshot(window: &Window, path: &std::path::Path) -> anyhow::Result<()#[cfg(not(feature = "screenshot"))]fn save_screenshot(_window: &Window, _path: &std::path::Path) -> anyhow::Result<()> {- anyhow::bail!("built without the screenshot feature: cargo build --features screenshot")+ anyhow::bail!("built without the screenshot feature: cargo gc build --features screenshot")}/// The color theme setting for the host scheme (`getColorThemeSettingId`); a theme no extension contributes falls back to the default, as ThemeService does.diff --git a/native/crates/app/src/update/install/tests.rs b/native/crates/app/src/update/install/tests.rsindex 3c0792d6dc1..21711a654c8 100644--- a/native/crates/app/src/update/install/tests.rs+++ b/native/crates/app/src/update/install/tests.rs@@ -128,7 +128,7 @@ fn a_failed_move_in_puts_the_installed_app_back() {}/// The failure cases of port/tools/update-check on its signed packages, without a window:-/// `UPDATE_CHECK_PACKAGES=/tmp/update-check/packages cargo test -p app update::install -- --ignored`.+/// `UPDATE_CHECK_PACKAGES=/tmp/update-check/packages cargo gc test -p app update::install -- --ignored`.#[test]#[ignore = "needs the packages of port/tools/update-check"]fn the_packaged_builds_verify_as_the_update_check_expects() {diff --git a/native/crates/app/src/workbench/scroll_frame_time.rs b/native/crates/app/src/workbench/scroll_frame_time.rsindex 336f6551397..a6dff4574ba 100644--- a/native/crates/app/src/workbench/scroll_frame_time.rs+++ b/native/crates/app/src/workbench/scroll_frame_time.rs@@ -2,7 +2,7 @@//! installed and running: each frame is one 30px pixel wheel event, then the draw. Text is laid out by gpui's//! NoopTextSystem (CoreText needs the main thread, which libtest never gives) and nothing reaches the GPU. The gate//! is 8 ms at the median and p95, a 120 Hz frame. Run in release:-//! `cargo test --release -p app -- --ignored scroll_frame_time --nocapture`.+//! `cargo gc test --release -p app -- --ignored scroll_frame_time --nocapture`.use std::path::{Path, PathBuf};use std::sync::{Arc, Mutex};diff --git a/port/tools/api-tests b/port/tools/api-testsindex 7ca057637c8..244e1541f85 100755--- a/port/tools/api-tests+++ b/port/tools/api-tests@@ -17,7 +17,7 @@ cp -cR "$REF/extensions/vscode-api-tests" "$OUT/tree/extensions/"cp "$REF/test/integration/electron/testrunner.js" "$OUT/tree/test/integration/electron/"ln -s "$REF/node_modules" "$OUT/tree/node_modules"tests=$OUT/tree/extensions/vscode-api-tests-(cd native && cargo build --release -q -p app) || exit 1+(cd native && cargo gc build --release -q -p app) || exit 1source port/tools/gui-lock.shrows=()diff --git a/port/tools/cargo-test b/port/tools/cargo-testnew file mode 100755index 00000000000..f1718276577--- /dev/null+++ b/port/tools/cargo-test@@ -0,0 +1,43 @@+#!/bin/bash+# Runs `cargo gc test` in native/ and prints only compile errors, failed tests and the summary lines.+# Exits non-zero when cargo fails or when the filters match no test, so a mistyped filter cannot pass.+# Usage: port/tools/cargo-test [-p <crate>] [<filter or test flag>...] (default crate: app; the rest goes after --)+set -uo pipefail+cd "$(dirname "$0")/../../native"+crate=app+if [[ ${1:-} == -p ]]; then+ crate=$2+ shift 2+fi+log=$(mktemp)+trap 'rm -f "$log"' EXIT+cargo gc test -p "$crate" -- "$@" >"$log" 2>&1+status=$?+awk -v status="$status" '+ /^test result:/ {+ ran += $4 + $6+ if ($4 + $6 > 0) { print; printed = 1 }+ failures = 0+ next+ }+ /^error(\[|:)/ { diagnostic = 1 }+ /^failures:$/ { failures = 1 }+ diagnostic || failures { print; printed = 1 }+ diagnostic && /^$/ { diagnostic = 0 }+ { tail[NR % 30] = $0 }+ END {+ # A failure with no error or failures block (a killed test binary): show the end of the log.+ if (status != 0 && !printed) {+ for (i = NR - 29; i <= NR; i++) if (i > 0) print tail[i % 30]+ }+ if (status == 0 && ran == 0) exit 2+ }+' "$log"+matched=$?+if ((status != 0)); then+ exit "$status"+fi+if ((matched == 2)); then+ echo "cargo-test: no test of $crate matches: $*" >&2+ exit 1+fidiff --git a/port/tools/cargo-test.test.ts b/port/tools/cargo-test.test.tsnew file mode 100644index 00000000000..1a7d291ea28--- /dev/null+++ b/port/tools/cargo-test.test.ts@@ -0,0 +1,57 @@+import { expect, test } from 'bun:test';+import { chmodSync, cpSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';++// Runs port/tools/cargo-test with a stand-in cargo that prints `log`, exits with `status` and records its arguments.+function cargoTest(log: string, status: number, args: string[] = []) {+ const root = mkdtempSync(join(tmpdir(), 'cargo-test-test-'));+ mkdirSync(join(root, 'port/tools'), { recursive: true });+ mkdirSync(join(root, 'native'));+ mkdirSync(join(root, 'bin'));+ cpSync(join(import.meta.dir, 'cargo-test'), join(root, 'port/tools/cargo-test'));+ writeFileSync(join(root, 'log'), log);+ writeFileSync(join(root, 'bin/cargo'), `#!/bin/bash\n[[ $1 == gc ]] || exit 1\nshift\necho "$@" > ${root}/args\ncat ${root}/log\nexit ${status}\n`);+ chmodSync(join(root, 'bin/cargo'), 0o755);+ // An exported bash function named cargo (BASH_FUNC_cargo%%) would win over the stand-in on PATH.+ const env = Object.fromEntries(Object.entries(process.env).filter(([name]) => !name.startsWith('BASH_FUNC_')));+ const run = Bun.spawnSync(['bash', join(root, 'port/tools/cargo-test'), ...args], { env: { ...env, PATH: `${join(root, 'bin')}:${process.env.PATH}` } });+ const result = { exitCode: run.exitCode, stdout: run.stdout.toString(), stderr: run.stderr.toString(), args: readFileSync(join(root, 'args'), 'utf8').trim() };+ rmSync(root, { recursive: true });+ return result;+}++const compiling = ' Compiling app v0.1.0\n Finished `test` profile\n Running unittests src/main.rs\n';++test('a passing run prints only the summary of the targets that ran tests', () => {+ const run = cargoTest(`${compiling}running 2 tests\ntest a ... ok\ntest b ... ok\n\ntest result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 9 filtered out; finished in 0.01s\n\nrunning 0 tests\n\ntest result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 3 filtered out; finished in 0.00s\n`, 0, ['-p', 'config', 'menus']);+ expect(run.exitCode).toBe(0);+ expect(run.stdout).toBe('test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 9 filtered out; finished in 0.01s\n');+ expect(run.args).toBe('test -p config -- menus');+});++test('a filter that matches no test fails', () => {+ const run = cargoTest(`${compiling}running 0 tests\n\ntest result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 12 filtered out; finished in 0.00s\n`, 0, ['typo']);+ expect(run.exitCode).toBe(1);+ expect(run.stderr).toContain('no test of app matches: typo');+ expect(run.args).toBe('test -p app -- typo');+});++test('a failing test prints its failures block and keeps cargo\'s exit code', () => {+ const failures = "failures:\n\n---- a stdout ----\nthread 'a' panicked at src/a.rs:3:5:\nleft: 1\nright: 2\n\n\nfailures:\n a\n\n";+ const run = cargoTest(`${compiling}running 2 tests\ntest a ... FAILED\ntest b ... ok\n\n${failures}test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s\n\nerror: test failed, to rerun pass \`-p app --bin vsrustium\`\n`, 101);+ expect(run.exitCode).toBe(101);+ expect(run.stdout).toBe(`${failures}test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s\nerror: test failed, to rerun pass \`-p app --bin vsrustium\`\n`);+});++test('a compile error prints its diagnostic with the location', () => {+ const run = cargoTest(' Compiling app v0.1.0\nwarning: unused import\n --> src/b.rs:1:5\n\nerror[E0425]: cannot find function `x`\n --> src/a.rs:4:5\n |\n4 | x();\n | ^ not found\n\nerror: could not compile `app` (bin "vsrustium" test) due to 1 previous error\n', 101);+ expect(run.exitCode).toBe(101);+ expect(run.stdout).toBe('error[E0425]: cannot find function `x`\n --> src/a.rs:4:5\n |\n4 | x();\n | ^ not found\n\nerror: could not compile `app` (bin "vsrustium" test) due to 1 previous error\n');+});++test('a failure without an error or failures block shows the end of the log', () => {+ const run = cargoTest(`${compiling}running 3 tests\nprocess didn't exit successfully (signal: 9, SIGKILL: kill)\n`, 101);+ expect(run.exitCode).toBe(101);+ expect(run.stdout).toBe(`${compiling}running 3 tests\nprocess didn't exit successfully (signal: 9, SIGKILL: kill)\n`);+});diff --git a/port/tools/corner-lab b/port/tools/corner-labindex b4b1cc50704..e22f23413f0 100755--- a/port/tools/corner-lab+++ b/port/tools/corner-lab@@ -1,6 +1,6 @@#!/usr/bin/env bun// Renders port/fixtures/corners/lab.json with the reference's Chromium (Electron, 2x display, sRGB) to-// port/fixtures/corners/chromium.png, the golden image `cargo test -p app rounded_quads_match_chromium` compares+// port/fixtures/corners/chromium.png, the golden image `cargo gc test -p app rounded_quads_match_chromium` compares// GPUI's quads against. Run on the Studio: port/tools/corner-lab [out.png]import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';diff --git a/port/tools/docs-check.test.ts b/port/tools/docs-check.test.tsindex 2e19bf9d952..bc67381dd4c 100644--- a/port/tools/docs-check.test.ts+++ b/port/tools/docs-check.test.ts@@ -17,7 +17,7 @@ function check(architecture: string, inventory = '| `app/src/main.rs` | libc | a}test('live paths, symbols and links pass, from the repo root or from a crate', () => {- const { code, out } = check('`app/src/main.rs::open_window`, `native/crates/app/src/main.rs` and [the rules](docs/memory-safety.md#rules). Upstream `src/vs/base/common/uri.ts` and `port/patches/*.patch` are not checked.');+ const { code, out } = check('`app/src/main.rs::open_window`, `native/crates/app/src/main.rs` and [the rules](docs/memory-safety.md#rules). Upstream `src/vs/base/common/uri.ts`, `port/patches/*.patch` and the build output `native/target` are not checked.');expect(out).toContain('every cited path and symbol exists');expect(code).toBe(0);});diff --git a/port/tools/docs-check.ts b/port/tools/docs-check.tsindex 2f5b78a056e..191cee8c6cf 100644--- a/port/tools/docs-check.ts+++ b/port/tools/docs-check.ts@@ -19,7 +19,7 @@ const resolve = (path: string) => [join(root, path), join(crates, path)].find(exfunction checkWord(word: string, where: string) {const [path, ...symbols] = word.split('::');- if (!path.includes('/') || /[*<>${}]|:\/\//.test(word) || path.startsWith('native/target/')) {+ if (!path.includes('/') || /[*<>${}]|:\/\//.test(word) || /^native\/target(\/|$)/.test(path)) {return;}if (!roots.includes(path.split('/')[0])) {diff --git a/port/tools/extension-tests b/port/tools/extension-testsindex 78eab9da427..74b097ee311 100755--- a/port/tools/extension-tests+++ b/port/tools/extension-tests@@ -26,7 +26,7 @@ if [[ ${APP:-port} == reference ]]; thenSHELL=/bin/bash VSCODE_DEV=1 NODE_ENV=development timeout 600 "$REF/.build/electron/Code - OSS.app/Contents/MacOS/Code - OSS" "$REF" "${args[@]}" \--disable-extension GitHub.copilot-chat >"$OUT/log" 2>&1else- (cd native && cargo build --release -q -p app) || exit 1+ (cd native && cargo gc build --release -q -p app) || exit 1# configuration-editing's extensions.json cases expect js-debug, a product.json built-in a new mirror lacks.port/tools/fetch-builtin-extensions >/dev/null || exit 1source port/tools/gui-lock.shdiff --git a/port/tools/extensions-check b/port/tools/extensions-checkindex 4629c574b34..8cdb764f5b0 100755--- a/port/tools/extensions-check+++ b/port/tools/extensions-check@@ -9,7 +9,7 @@ for fixture in port/fixtures/extensions/vsix-*; domkdir -p "$out/pack/extension" && rm -rf "$out/pack/extension"/* && cp -R "$fixture"/. "$out/pack/extension/"(cd "$out/pack" && zip -qr "$out/$(basename "$fixture").vsix" extension)done-(cd native && cargo build --release -q -p app)+(cd native && cargo gc build --release -q -p app)source port/tools/gui-lock.shsource port/tools/vscode-src.shtests=$PWD/port/fixtures/extensions/install-testsdiff --git a/port/tools/linux-build b/port/tools/linux-buildindex dc7a36f0f8e..5068bd81dd8 100755--- a/port/tools/linux-build+++ b/port/tools/linux-build@@ -1,5 +1,5 @@#!/bin/bash# Syncs this checkout to its Mac Studio mirror (port/tools/studio) and runs a command in the Linux container there.-# Usage: port/tools/linux-build 'cd native && timeout 1500 cargo check -p app'+# Usage: port/tools/linux-build 'cd native && timeout 1500 cargo gc check -p app'set -euo pipefailexec "$(dirname "$0")/studio" "port/tools/linux/run $(printf '%q' "$1")"diff --git a/port/tools/linux/Dockerfile b/port/tools/linux/Dockerfileindex 30060d34e21..4ef9592e536 100644--- a/port/tools/linux/Dockerfile+++ b/port/tools/linux/Dockerfile@@ -1,7 +1,7 @@# Linux build and test image for VSRustium (port/tools/linux-build runs it on the Mac Studio, linux/arm64).# Packages: GPUI's Linux platform (wu script/linux: xkbcommon, wayland, x11/xcb, fontconfig, freetype, vulkan, alsa),# WebKitGTK 4.1 and libsecret for the webview and secrets, Xvfb and Mesa's Vulkan driver to run the app headless,-# squashfs-tools for port/tools/package-linux's AppImage.+# squashfs-tools for port/tools/package-linux's AppImage, ripgrep for the output filters of commands run here.FROM node:24-trixie-slim AS nodeFROM oven/bun:1.4.5-debian AS bunFROM rust:1-trixie@@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \libasound2-dev libfontconfig-dev libfreetype-dev libwayland-dev libx11-xcb-dev libxcb1-dev libxkbcommon-x11-dev \libvulkan1 mesa-vulkan-drivers libssl-dev libzstd-dev libdbus-1-dev \libwebkit2gtk-4.1-dev libsecret-1-dev \- xvfb xauth git file squashfs-tools \+ xvfb xauth git file squashfs-tools ripgrep \&& rm -rf /var/lib/apt/lists/*COPY --from=node /usr/local/bin/node /usr/local/bin/node@@ -23,10 +23,10 @@ COPY --from=bun /usr/local/bin/bun /usr/local/bin/bun# cargo-gc, so builds run as `cargo gc <cmd>` here too and the target volume stays bounded.RUN arch=$(uname -m) \&& case $arch in \- aarch64) sum=74291a050e0d2c258eebed7979b80e0d65b6f6684ff7cb03b6650f5a85ed1470 ;; \- x86_64) sum=29476ae8128827cda3e3a3ed9b46bbe482966ecdd8d7eaf2543f54d88a3db260 ;; \+ aarch64) sum=4b7e766d5e603efb5bfa274ba4c5f67b3b9b531c48930899b173930fe349178c ;; \+ x86_64) sum=d9c54f01095e39195173db70d97e792545a8d4745d30e80aabde33f2aa486601 ;; \esac \- && curl -fsSL -o /tmp/cargo-gc.tgz "https://github.com/leostera/cargo-gc/releases/download/v0.1/cargo-gc-v0.1-$arch-unknown-linux-gnu.tar.gz" \+ && curl -fsSL -o /tmp/cargo-gc.tgz "https://github.com/leostera/cargo-gc/releases/download/v0.2/cargo-gc-v0.2-$arch-unknown-linux-gnu.tar.gz" \&& echo "$sum /tmp/cargo-gc.tgz" | sha256sum -c - \&& tar xzf /tmp/cargo-gc.tgz -C /usr/local/cargo/bin ./cargo-gc \&& rm /tmp/cargo-gc.tgzdiff --git a/port/tools/linux/run b/port/tools/linux/runindex 5c37b6eea7f..7c35ae78ba5 100755--- a/port/tools/linux/run+++ b/port/tools/linux/run@@ -1,6 +1,6 @@#!/bin/bash# Runs a command (bash -c) in the Linux build container, at the Studio mirror root this script lives in.-# Called by port/tools/linux-build; on the Studio itself: port/tools/linux/run 'cd native && cargo check -p app'.+# Called by port/tools/linux-build; on the Studio itself: port/tools/linux/run 'cd native && cargo gc check -p app'.# The image is built from Dockerfile beside this script and tagged by its hash; older tags are deleted.# Cargo's home (registry, git checkouts) and the Linux target dir are docker volumes, so the mirror's native/target is never touched.set -euo pipefaildiff --git a/port/tools/package-app b/port/tools/package-appindex 6227d511851..52f44a39a10 100755--- a/port/tools/package-app+++ b/port/tools/package-app@@ -7,7 +7,7 @@// a Developer ID signs in the GUI session), NOTARIZE=1 (notarize and staple), VSCODE_GPUI_EXTENSIONS (default the reference's extensions), OUT (default native/target/VSRustium.app),// VERSION (default the VS Code tree's), PRERELEASE=1 (a pre-release: quality insider, version <VERSION>-insider; else quality stable), TAG (the GitHub release tag, default v<display version>, app-files.ts displayVersion),// PRODUCT (a JSON object merged into product.json, for tests: '{"updateUrl": "http://127.0.0.1:8080"}'),-// ARCH (arm64 or x64, default the host's; for another arch first `cargo build --release -p app --target <triple>`)+// ARCH (arm64 or x64, default the host's; for another arch first `cargo gc build --release -p app --target <triple>`)// Next to the app it writes the update zip and the feed entries of port/notes.md "Update feed", per platform and arch:// VSRustium-<display version>-darwin-<arch>.zip and darwin-<arch>-prerelease.json, and darwin-<arch>.json unless PRERELEASE=1.import { cpSync, existsSync, mkdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs';diff --git a/port/tools/package-linux b/port/tools/package-linuxindex ae80ead63b5..0c8e53a64b0 100755--- a/port/tools/package-linux+++ b/port/tools/package-linux@@ -6,7 +6,7 @@// VSRustium-<display version>-linux-<arch>.tar.gz and the folder as VSRustium-<display version>-linux-<arch>.AppImage// (port/tools/linux/appimage) next to the folder, and the feed entries of port/notes.md "Update feed":// linux-<arch>-prerelease.json and, unless PRERELEASE=1, linux-<arch>.json.-// Run on Linux after `cargo build --release -p app` and port/tools/build-exthost, for the host's arch:+// Run on Linux after `cargo gc build --release -p app` and port/tools/build-exthost, for the host's arch:// port/tools/linux-build 'port/tools/package-linux' env VSCODE_GPUI_EXTENSIONS (default the VS Code tree's// extensions), OUT (default <target dir>/VSRustium-linux-<arch>), VERSION, PRERELEASE=1, TAG, PRODUCT as package-app.import { cpSync, existsSync, mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';diff --git a/port/tools/pixel-check b/port/tools/pixel-checkindex 80011ab3e7f..2848388e415 100755--- a/port/tools/pixel-check+++ b/port/tools/pixel-check@@ -18,7 +18,7 @@ OUT=${OUT:-/tmp/pixel-check-$(basename "$PWD")}mkdir -p "$OUT"rm -rf "$OUT/workspace" "$OUT/workspace2" "$OUT/folding" && cp -R port/fixtures/workspace "$OUT/workspace" && cp -R port/fixtures/workspace/docs "$OUT/workspace2" && cp -R port/fixtures/folding "$OUT/folding"echo '{ "folders": [{ "path": "workspace" }, { "path": "workspace2", "name": "Second Folder" }] }' >"$OUT/multi.code-workspace"-(cd native && cargo build --release -q -p app --features screenshot && cargo build --release -q -p pixeldiff) || exit 1+(cd native && cargo gc build --release -q -p app --features screenshot && cargo gc build --release -q -p pixeldiff) || exit 1source port/tools/gui-lock.sh# GPUI takes hover from the real pointer on the first frame; the reference window gets no mouse move.echo 'import CoreGraphics; CGWarpMouseCursorPosition(.zero)' | swift - || exit 1diff --git a/port/tools/user-data-fs-check b/port/tools/user-data-fs-checkindex b2adaecb8e3..b63c3c9dad8 100755--- a/port/tools/user-data-fs-check+++ b/port/tools/user-data-fs-check@@ -1,6 +1,6 @@#!/bin/bash# Runs port/fixtures/extensions/user-data-fs-tests in the release build: workspace.fs on `vscode-userdata` resources.-# On the Studio after `cargo build --release -p app`: port/tools/studio --lane port/tools/user-data-fs-check+# On the Studio after `cargo gc build --release -p app`: port/tools/studio --lane port/tools/user-data-fs-check# TESTS=<copy in /tmp> when a GUI VM's share still lists an older fixture folder (gui-lane copies /tmp paths in).set -uo pipefailsource port/tools/gui-lock.shdiff --git a/port/tools/webview-check b/port/tools/webview-checkindex 7fef9a2c688..ca0f7fcef7f 100755--- a/port/tools/webview-check+++ b/port/tools/webview-check@@ -5,7 +5,7 @@set -uo pipefailcd "$(dirname "$0")/../.."REF=${REF:-$HOME/Developer/vscode-ref-1.148.0}-(cd native && cargo build --release -q -p app) || exit 1+(cd native && cargo gc build --release -q -p app) || exit 1source port/tools/gui-lock.shtests=$PWD/port/fixtures/extensions/${FIXTURE:-webview-tests}status=0