CodeVetter · Repo Unpack · Testing signals
rust-lang/rust
Testing is dominated by compiletest-driven suites under tests/ (~27k .rs files; tests/ui alone has ~21k), organized by 15 TestModes with //@-style file directives. Unit tests live inside compiler crates as #[cfg(test)] modules and in library/coretests + alloctests. tidy enforces repo-wide hygiene. CI runs everything via the citool-computed matrix in jobs.yml, and bootstrap itself has python and Rust self-tests. Coverage tests exercise LLVM source-based coverage; rustdoc has html/json/js/gui suites.
- tests/ contains suites: ui, ui-fulldeps, mir-opt, codegen-llvm, codegen-units, assembly-llvm, coverage, coverage-run-rustdoc, crashes, debuginfo, incremental, pretty, run-make, run-make-cargo, rustdoc-html, rustdoc-js, rustdoc-js-std, rustdoc-json, rustdoc-gui, build-std; tests/ui alone contains ~21,000 .rs files.
- compiletest's TestMode enum (common.rs) maps each suite to a mode; each mode has a runner module under src/tools/compiletest/src/runtest/ (ui.rs, mir_opt.rs, codegen.rs, incremental.rs, run_make.rs, coverage.rs, debuginfo.rs, rustdoc.rs, rustdoc_json.rs, js_doc.rs, crashes.rs, pretty.rs, assembly.rs, codegen_units.rs).
- Test files declare behavior via directives parsed by src/tools/compiletest/src/directives.rs: KNOWN_DIRECTIVE_NAMES_SET in directive_names.rs, a DIRECTIVE_HANDLERS_MAP in directives/handlers.rs, ignore-*/only-*/needs-* cfg conditions precompiled in DirectivesCache, and AuxProps for aux builds.
- UI tests compare compiler output against checked-in .stderr/.stdout/.svg snapshots; compute_diff in runtest produces line diffs and `--bless` regenerates expectations (per AGENTS.md, bless runs only after a human authors new diagnostic text).
- Compiler crates carry in-tree unit tests: e.g. compiler/rustc_interface/src/tests.rs, compiler/rustc_middle/src/tests.rs, compiler/rustc_feature/src/tests.rs, rustc_target/src/tests.rs, compiletest/src/tests.rs; bootstrap has src/bootstrap/bootstrap_test.py and builder/tests.rs.
- Standard library tests live in separate crates in the library workspace: coretests and alloctests exercise core/alloc without running inside std; library/test is the user-facing #[test] harness crate.
- tidy acts as a repo-wide lint gate: src/tools/tidy/src/main.rs spawns per-check threads (style, alphabetical ordering, deps/extdeps allowlist, error_codes, features, ui_tests conventions, target_policy, unit_tests placement, edition, mir_opt_tests) runnable via ./x test tidy.
- run-make tests are driven by the src/tools/run-make-support library and live in tests/run-make and tests/run-make-cargo; coverage tests use the coverage-map/coverage-run modes sharing tests/coverage files.
- CI executes tests through the matrix in src/ci/github-actions/jobs.yml computed by src/ci/citool (calculate-job-matrix), with the actual build/test run delegated to src/ci/scripts/run-build-from-ci.sh inside ci.yml's 'run the build' step.
- rustdoc-gui tests are a separate excluded workspace (tests/rustdoc-gui in Cargo.toml exclude list) driven by src/tools/rustdoc-gui-test and compiletest's rustdoc_gui_test module.
- tests/crashes is a dedicated ICE-regression suite, and tests/debuginfo is skipped on emscripten targets (run_tests special-cases TestMode::DebugInfo for emscripten).
- Cross/remote testing is supported by src/tools/remote-test-client and remote-test-server, and test-float-parse is an optimized dev/release binary used to validate float parsing.