bazel-test-hygiene

작성자: cloudflare

개발 중 bazel 테스트 실행을 위한 필수 규칙입니다. 특히 수정 사항을 검증할 때 bazel 테스트 명령을 실행하기 전에 이 스킬을 로드하세요.

npx skills add https://github.com/cloudflare/workerd --skill bazel-test-hygiene

Bazel Test Hygiene

The Three Rules

1. Always disable caching

bazel test //... --nocache_test_results

Why: Bazel's action cache can serve stale test binaries even after you edit source files. Without --nocache_test_results, you may be running the OLD binary and seeing OLD results. This is not hypothetical — it has caused real false-positive/false-negative confusion in this repo.

Always include --nocache_test_results. No exceptions.

2. Keep it simple — no filter flags

Do NOT use --test_arg='-f' or similar filter flags to run individual test cases.

Why: KJ test's -f flag silently passes when zero tests match. If you typo the filter or the test name changes, bazel reports "PASSED" with zero tests actually run. This gives completely false confidence.

Run the full test target. If you need to check a specific test, look for its name in the full output. If the full suite is too slow, run the specific test target (e.g., //src/workerd/api:streams/standard-test@), not a filtered subset within a target.

3. Run the full suite before claiming done

A single test target passing does not mean you haven't broken something else. Fixes to shared code (queue.c++, standard.c++, common.h) can break tests in completely different directories.

Before claiming any fix is complete:

bazel test //... --nocache_test_results

Check the final summary line: Executed N out of N tests: N tests pass. All N must match. If any test fails, the fix is not done.

Red-Green Verification for Regression Tests

When writing a regression test for a bug fix, you MUST verify the test actually catches the bug:

  1. Green: Run bazel test //... --nocache_test_results — all tests pass (fix in place)
  2. Red: Remove the fix, run bazel test //... --nocache_test_results — the new test(s) MUST fail
  3. Green: Restore the fix, run bazel test //... --nocache_test_results — all tests pass again

If step 2 passes (test doesn't fail without the fix), the test is not testing what you think. Go back and fix the test.

Do the red-green on the full suite, not just the one target. This catches two problems at once: (a) the regression test actually detects the bug, and (b) the fix doesn't break anything else.

Anti-Patterns

Don'tDo instead
bazel test //target (no cache flag)bazel test //target --nocache_test_results
--test_arg='-f' --test_arg='test name'Run the full target, grep output for test name
Run one target, claim fix is doneRun //..., check all-pass summary
Claim "tests pass" from a previous runRun fresh, read fresh output
Trust filter-based "PASSED" at face valueCheck that the expected test names appear in output

cloudflare의 다른 스킬

workerd-api-review
cloudflare
workerd 코드 리뷰를 위한 성능 최적화, API 설계 및 호환성, 보안 취약점, 표준 사양 준수. tcmalloc 인식…
official
workerd-safety-review
cloudflare
메모리 안전성, 스레드 안전성, 동시성, 그리고 workerd 코드 리뷰를 위한 중요 탐지 패턴. V8/KJ 경계 위험 요소, 수명 관리 등을 다룹니다.
official
module-registry
cloudflare
workerd에서 모듈 레지스트리를 작업할 때 로드 — 모듈 해석, 컴파일, 평가, 등록을 읽기, 수정, 디버깅, 검토하는 경우…
official
reproduce
cloudflare
cloudflare/agents GitHub 이슈를 재현하기 위해 최소한의 Agents/Worker 프로젝트를 스캐폴딩하고 임시 Cloudflare 계정에 배포한 후 보고합니다…
official
local-explorer
cloudflare
로컬 탐색기 또는 로컬 API에 제품/리소스를 추가하는 방법. 새로운 로컬 API나 UI 라우트를 구현할 때 사용합니다.
official
commit-categories
cloudflare
커밋을 체인지로그와 "새로운 기능" 요약으로 분류하는 규칙입니다. 체인지로그 또는 whats-new 명령에서 커밋을 분류하기 전에 반드시 로드되어야 합니다. 제공하는 기능:
official
architecture
cloudflare
코드베이스를 처음 탐색할 때, 새 클라이언트 메서드를 추가할 때, 새 컨테이너 핸들러/서비스를 추가할 때, 또는 요청 흐름을 이해할 때 사용합니다.
official
changesets
cloudflare
변경셋을 생성하거나, 릴리즈를 준비하거나, 버전을 올릴 때 사용합니다. 참조할 패키지, 사용자 대상 변경셋 설명 작성 방법 등을 다룹니다.
official