Skip to content

Commit 26ec6fe

Browse files
committed
feat(test): add test:changed and make it the local check during implementation
Adds `bun run test:changed`, which runs only the tests whose import graph touches the diff, and rewrites AGENTS.md, src/AGENTS.md and the eight contributing guides so the full suite is the PR-ready gate rather than the routine local one. `--changed` gets `--pass-with-no-tests` (a graph filter selecting nothing is a valid answer, not a failure) and must not receive a default `./tests/` path, or Bun treats the graph filter as unused. MEASURED CAVEAT, unresolved and worth deciding before this lands: `--changed=dev` compares against the LOCAL `dev` branch. On this machine that branch sits 296 commits behind upstream, so a 3-file change selected 753 of 902 test files — 13053 tests, 81s. The failure is silent in both directions: a stale `dev` quietly runs most of the suite, and a diverged one can select too little while the guides now say the full suite is no longer required for shared routing, config or server edits. That combination is the risk, not the graph filter itself, which selects correctly relative to whatever ref it is given. Left as `dev` deliberately rather than guessing a remote name: `origin` is a fork here and `upstream` is the real repo, while a direct contributor's layout is the reverse. Candidate fixes (pin a remote ref, fetch first, warn when the selection is implausibly large or small) are a repo-convention call. Stacked on the --parallel fix, which introduces resolveBunTestArgs. Gate: 14439 pass / 1 fail; that failure also fails on untouched upstream/dev at this commit. Zero regressions.
1 parent 4518004 commit 26ec6fe

13 files changed

Lines changed: 69 additions & 33 deletions

File tree

‎AGENTS.md‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,23 @@ it binds you regardless of which mechanism is within reach.
163163
```bash
164164
bun install
165165
bun run typecheck # bun x tsc --noEmit (strict)
166-
bun run test # full tests/ suite
166+
bun run test:changed # tests whose import graph touches the diff against `dev`
167+
bun run test # full tests/ suite (PR-ready / explicit ask only)
167168
bun run lint:gui # GUI eslint
168169
bun run privacy:scan # credential/privacy scan used by CI
169170
bun run build:gui # Vite GUI build
170171
```
171172

172173
During implementation, use the smallest focused checks that directly cover the
173-
changed subsystem. Do not run repository-wide `bun run typecheck` or
174-
`bun run test` for a scoped change unless the change affects shared runtime,
175-
routing, config, server behavior, a focused result is failed or ambiguous, or
176-
the user explicitly asks for full validation.
174+
changed subsystem. Prefer `bun test tests/<name>.test.ts` for a known file, or
175+
`bun run test:changed` when the touch set is broader than one file. Do **not**
176+
run repository-wide `bun run typecheck`, `bun run test`, or a bare `bun test`
177+
with no file arguments for a scoped change. Shared runtime, routing, config, or
178+
server edits are not an exception: `bun run test:changed` already selects every
179+
test that imports those modules. The full suite is ~850 files; launching it
180+
without an explicit ask blocks the machine for minutes and starves other work.
181+
Run it only when a focused result failed or is ambiguous, or the user explicitly
182+
asks for full validation.
177183

178184
Before creating or updating a non-trivial PR as review-ready, or before
179185
approving such a PR, run `bun run typecheck` and `bun run test`. CI runs these
@@ -274,8 +280,8 @@ reviewers (Codex, CodeRabbit).
274280
assumptions about a compile step, or code paths that break `bun run
275281
typecheck` / `bun run test`.
276282
- **Tests:** behavior changes in `src/` need a focused regression test near
277-
the existing tests for that subsystem. Shared routing, adapter, config, or
278-
server changes need the full suite green.
283+
the existing tests for that subsystem. During implementation, `bun run test:changed`
284+
(or the focused file) is the local check; the full suite is the PR-ready gate.
279285
- **Docs sync:** user-facing behavior changes should update `docs-site/` (and
280286
keep translated locales from contradicting the English source).
281287
- **Privacy:** `bun run privacy:scan` must stay green; never introduce logging

‎docs-site/src/content/docs/contributing.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ scripts so local commands match CI:
2828

2929
```bash
3030
bun run typecheck # strict TypeScript check
31-
bun run test # complete tests/ suite
31+
bun run test:changed # tests affected by the diff against `dev`
32+
bun run test # complete tests/ suite (PR-ready / explicit ask)
3233
bun test tests/router.test.ts # focused test file
3334
bun run build:gui # Vite GUI build + package preparation
3435
bun run privacy:scan # credential/privacy scan used by CI
@@ -37,8 +38,8 @@ bun run prepare:package # refresh package launchers/assets
3738

3839
Most tests are flat `tests/*.test.ts` Bun tests. `tests/helpers/` contains shared fixtures and
3940
`tests/e2e-style/` contains broader native-parity scenarios. Keep a focused regression near the
40-
existing tests for the subsystem you change; run the full suite for shared routing, adapters, config,
41-
or server behavior.
41+
existing tests for the subsystem you change. During implementation run that file or `bun run test:changed`;
42+
run the complete suite with `bun run test` before marking a PR review-ready.
4243

4344
The docs site you're reading lives in `docs-site/` (Astro + Starlight):
4445

‎docs-site/src/content/docs/fr/contributing.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ distincte. Utilisez les scripts enregistrés afin que les commandes locales corr
2828

2929
```bash
3030
bun run typecheck # strict TypeScript check
31-
bun run test # complete tests/ suite
31+
bun run test:changed # tests affected by the diff against `dev`
32+
bun run test # complete tests/ suite (PR-ready / explicit ask)
3233
bun test tests/router.test.ts # focused test file
3334
bun run build:gui # Vite GUI build + package preparation
3435
bun run privacy:scan # credential/privacy scan used by CI
@@ -37,8 +38,8 @@ bun run prepare:package # refresh package launchers/assets
3738

3839
La plupart des tests Bun sont des fichiers plats `tests/*.test.ts`. `tests/helpers/` contient les fixtures
3940
partagées et `tests/e2e-style/` des scénarios plus larges de parité native. Placez une régression ciblée près
40-
des tests existants du sous-système modifié. Exécutez la suite complète pour le routage partagé, les adaptateurs,
41-
la configuration ou le comportement du serveur.
41+
des tests existants du sous-système modifié. Pendant l’implémentation, lancez ce fichier ou `bun run test:changed` ;
42+
la suite complète (`bun run test`) est le seuil review-ready d’une PR.
4243

4344
Le site de documentation que vous lisez se trouve dans `docs-site/` (Astro + Starlight) :
4445

‎docs-site/src/content/docs/ja/contributing.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ bun run test # bun test ./tests/
2626

2727
```bash
2828
bun run typecheck # 厳密な TypeScript 検査
29-
bun run test # tests/ の全体スイート
29+
bun run test:changed # `dev` との diff が影響するテスト
30+
bun run test # tests/ の全体スイート (PR review-ready / 明示時)
3031
bun test tests/router.test.ts # 特定テストファイル
3132
bun run build:gui # Vite GUI ビルド + パッケージ準備
3233
bun run privacy:scan # CI で使う資格情報/個人情報検査
@@ -35,8 +36,8 @@ bun run prepare:package # パッケージランチャー/asset 更新
3536

3637
ほとんどのテストは `tests/*.test.ts` に並んで配置された Bun テストです。共有 fixture は
3738
`tests/helpers/`、範囲の広いネイティブ等価性シナリオは `tests/e2e-style/` にあります。変更した
38-
サブシステムの既存テストの近くに集中した回帰テストを追加してください。共有ルーティング、アダプター、設定、サーバー
39-
動作を触った場合は全体スイートも実行します。
39+
サブシステムの既存テストの近くに集中した回帰テストを追加してください。実装中はそのファイルか `bun run test:changed` を実行し、
40+
全体スイートは PR を review-ready にする前、または明示されたときだけ実行します。
4041

4142
いま読んでいるドキュメントサイトは `docs-site/` にあります(Astro + Starlight)。
4243

‎docs-site/src/content/docs/ko/contributing.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ bun run test # bun test ./tests/
2626

2727
```bash
2828
bun run typecheck # 엄격한 TypeScript 검사
29-
bun run test # tests/ 전체 스위트
29+
bun run test:changed # `dev` diff가 영향을 주는 테스트
30+
bun run test # tests/ 전체 스위트 (PR review-ready / 명시 요청 시)
3031
bun test tests/router.test.ts # 특정 테스트 파일
3132
bun run build:gui # Vite GUI 빌드 + 패키지 준비
3233
bun run privacy:scan # CI에서 쓰는 자격 증명/개인정보 검사
@@ -35,8 +36,8 @@ bun run prepare:package # 패키지 런처/asset 갱신
3536

3637
대부분의 테스트는 `tests/*.test.ts`에 나란히 놓인 Bun 테스트입니다. 공용 fixture는
3738
`tests/helpers/`, 범위가 넓은 네이티브 동등성 시나리오는 `tests/e2e-style/`에 있습니다. 바꾼
38-
subsystem의 기존 테스트 근처에 집중된 회귀 테스트를 추가하세요. 공용 라우팅, 어댑터, 설정, 서버
39-
동작을 건드렸다면 전체 스위트도 실행합니다.
39+
subsystem의 기존 테스트 근처에 집중된 회귀 테스트를 추가하세요. 구현 중에는 해당 파일 또는 `bun run test:changed`를 실행하고,
40+
전체 스위트는 PR을 review-ready로 만들기 전이나 명시적으로 요청된 때만 실행합니다.
4041

4142
지금 읽고 있는 문서 사이트는 `docs-site/`에 있습니다(Astro + Starlight).
4243

‎docs-site/src/content/docs/ru/contributing.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ bun run test # bun test ./tests/
2525

2626
```bash
2727
bun run typecheck # строгая проверка TypeScript
28-
bun run test # полный набор tests/
28+
bun run test:changed # тесты, затронутые diff относительно `dev`
29+
bun run test # полный набор tests/ (PR review-ready / явная просьба)
2930
bun test tests/router.test.ts # отдельный тестовый файл
3031
bun run build:gui # сборка GUI на Vite + подготовка пакета
3132
bun run privacy:scan # проверка учётных данных/приватности, используемая в CI
@@ -34,8 +35,8 @@ bun run prepare:package # обновление лаунчеров/ре
3435

3536
Большинство тестов — плоские Bun-тесты `tests/*.test.ts`. В `tests/helpers/` лежат общие fixtures,
3637
а в `tests/e2e-style/` — более широкие сценарии нативного паритета. Добавляйте сфокусированный
37-
регрессионный тест рядом с существующими тестами изменяемой подсистемы; если затронуты общая
38-
маршрутизация, адаптеры, конфигурация или поведение сервера, запускайте полный набор.
38+
регрессионный тест рядом с существующими тестами изменяемой подсистемы. Во время работы запускайте этот файл или `bun run test:changed`;
39+
полный набор — перед пометкой PR как review-ready или по явной просьбе.
3940

4041
Сайт документации, который вы сейчас читаете, находится в `docs-site/` (Astro + Starlight):
4142

‎docs-site/src/content/docs/tr/contributing.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Yerel komutların CI ile eşleşmesi için depodaki betikleri kullanın:
3232

3333
```bash
3434
bun run typecheck # katı TypeScript denetimi
35-
bun run test # tests/ paketinin tamamı
35+
bun run test:changed # `dev` farkının etkilediği testler
36+
bun run test # tests/ paketinin tamamı (PR review-ready / açık istek)
3637
bun test tests/router.test.ts # odaklanmış test dosyası
3738
bun run build:gui # Vite GUI derlemesi + paket hazırlığı
3839
bun run privacy:scan # CI tarafından kullanılan kimlik/gizlilik taraması
@@ -42,9 +43,8 @@ bun run prepare:package # paket başlatıcılarını ve varlıkların
4243
Testlerin çoğu düz `tests/*.test.ts` Bun testleridir. `tests/helpers/`
4344
paylaşılan test ortamlarını (fixtures) ve `tests/e2e-style/` daha geniş yerel
4445
parite senaryolarını içerir. Değiştirdiğiniz alt sistemin mevcut testlerinin
45-
yakınında odaklanmış bir regresyon testi bulundurun; paylaşılan yönlendirme,
46-
adaptörler, yapılandırma veya sunucu davranışları için test paketinin tamamını
47-
çalıştırın.
46+
yakınında odaklanmış bir regresyon testi bulundurun. Uygulama sırasında o dosyayı veya `bun run test:changed` komutunu çalıştırın;
47+
tam paketi `bun run test` ile yalnızca PR review-ready yapılmadan önce veya açıkça istendiğinde çalıştırın.
4848

4949
Okumakta olduğunuz dokümantasyon sitesi `docs-site/` (Astro + Starlight)
5050
dizinindedir:

‎docs-site/src/content/docs/zh-cn/contributing.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ bun run test # bun test ./tests/
2525

2626
```bash
2727
bun run typecheck # 严格 TypeScript 检查
28-
bun run test # 完整 tests/ suite
28+
bun run test:changed # 相对 `dev` 的 diff 影响到的测试
29+
bun run test # 完整 tests/ suite(PR review-ready / 明确要求时)
2930
bun test tests/router.test.ts # 聚焦单个测试文件
3031
bun run build:gui # Vite GUI 构建 + package 准备
3132
bun run privacy:scan # CI 使用的 credential/privacy 扫描
@@ -34,7 +35,7 @@ bun run prepare:package # 刷新 package launcher/asset
3435

3536
大多数测试是平铺在 `tests/*.test.ts` 下的 Bun test。`tests/helpers/` 存放共享 fixture,
3637
`tests/e2e-style/` 存放范围更广的原生一致性场景。请在对应 subsystem 的现有测试附近加入聚焦的
37-
回归测试;若改动涉及共享 routing、adapter、config 或 server 行为,还应运行完整 suite。
38+
回归测试。实现过程中跑该文件或 `bun run test:changed`;完整 suite 只在 PR 标记 review-ready 前,或明确要求时再跑。
3839

3940
你正在阅读的文档站点位于 `docs-site/`(Astro + Starlight):
4041

‎docs-site/src/content/docs/zh-tw/contributing.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ bun run test # bun test ./tests/
2525

2626
```bash
2727
bun run typecheck # 嚴格 TypeScript 檢查
28-
bun run test # 完整 tests/ suite
28+
bun run test:changed # 相對 `dev` 的 diff 影響到的測試
29+
bun run test # 完整 tests/ suite(PR review-ready / 明確要求時)
2930
bun test tests/router.test.ts # 聚焦單個測試檔案
3031
bun run build:gui # Vite GUI 建置 + package 準備
3132
bun run privacy:scan # CI 使用的 credential/privacy 掃描
@@ -34,7 +35,7 @@ bun run prepare:package # 重新整理 package launcher/asset
3435

3536
大多數測試是平鋪在 `tests/*.test.ts` 下的 Bun test。`tests/helpers/` 存放共享 fixture,
3637
`tests/e2e-style/` 存放範圍更廣的原生一致性場景。請在對應 subsystem 的現有測試附近加入聚焦的
37-
迴歸測試;若改動涉及共享 routing、adapter、config 或 server 行為,還應執行完整 suite。
38+
迴歸測試。實作過程中跑該檔案或 `bun run test:changed`;完整 suite 只在 PR 標記 review-ready 前,或明確要求時再跑。
3839

3940
你正在閱讀的文件站點位於 `docs-site/`(Astro + Starlight):
4041

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"dev:gui": "cd gui && bun run dev",
4040
"start": "bun run src/cli/index.ts start",
4141
"test": "bun scripts/test.ts",
42+
"test:changed": "bun scripts/test.ts --changed=dev",
4243
"typecheck": "bun x tsc --noEmit",
4344
"audit:high": "bun audit --audit-level=high && cd gui && bun audit --audit-level=high",
4445
"privacy:scan": "bun scripts/privacy-scan.ts",

0 commit comments

Comments
 (0)