Skip to content

Commit 4ee5139

Browse files
committed
feat(ui-tests): add awk directive parser and per-nightly test infrastructure
Add an awk-based directive parser (parse_test_directives.awk) that extracts test metadata (editions, compile-flags, skip conditions) from rustc UI test source files. This replaces shell-level heuristics with a single-pass parser that handles: - //@ directives (edition, compile-flags, needs-*, ignore-*) - Architecture and subprocess filtering - Range-based nightly gating via override TSV files Rewrite run_ui_tests.sh and remake_ui_tests.sh to use the shared parser. Add diff_test_lists.sh for generating per-nightly effective test lists with caching. Include unit tests and boundary notes. Per-nightly override TSV files allow fine-grained control over which tests pass/fail on each nightly without modifying the base lists.
1 parent d440b10 commit 4ee5139

51 files changed

Lines changed: 39861 additions & 191 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tests/ui/README.md

Lines changed: 80 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,92 @@
1-
# Rust UI Tests
1+
# UI Tests
22

3-
These tests are taken from The [Rust compiler UI test suite](https://github.com/rust-lang/rust/tests/ui/).
4-
Some tests here are not appropriate for us to test with yet, so we need to filter valid tests for
5-
the current state of Stable MIR JSON are generated. To generate and run the tests a checkout of the
6-
rust compiler is required.
3+
Regression tests drawn from the [Rust compiler UI test suite](https://github.com/rust-lang/rust/tree/master/tests/ui). We run a curated subset of rustc's UI tests through stable-mir-json and check that they process successfully (exit 0). A checkout of the rust compiler source is required.
74

8-
## Usage
9-
To generate the tests
5+
## Quick start
106

117
```bash
12-
cd tests/ui/
13-
RUST_TOP=`<PATH-TO-RUST>` ./collect_test_sources.sh > ui_sources.txt
8+
# Run against the pinned nightly (uses base passing.tsv):
9+
RUST_DIR_ROOT=/path/to/rust make test-ui
10+
11+
# Run against a different nightly (uses effective list if available):
12+
RUSTUP_TOOLCHAIN=nightly-2025-03-01 RUST_DIR_ROOT=/path/to/rust make test-ui
13+
```
14+
15+
## Directory layout
16+
17+
```
18+
tests/ui/
19+
├── base-nightly.txt # which nightly the base lists were generated against
20+
├── passing.tsv # base passing list (one test path per line)
21+
├── failing.tsv # base failing list (path<TAB>exit_code)
22+
23+
├── overrides/
24+
│ ├── nightly-2025-03-01.tsv # manual overrides for behavior changes
25+
│ └── nightly-2025-03-01/
26+
│ ├── passing.tsv # effective passing list (generated)
27+
│ └── failing.tsv # effective failing list (generated)
28+
29+
├── run_ui_tests.sh # test runner
30+
├── diff_test_lists.sh # generates effective lists from base+delta
31+
├── collect_test_sources.sh # discovers candidate tests from rustc source
32+
├── remake_ui_tests.sh # regenerates base lists from scratch
33+
├── ensure_rustc_commit.sh # checks out the right rustc commit
34+
├── rustc_mir.sh # helper: runs rustc to emit MIR (used by collect)
35+
├── has_match.sh # helper: grep wrapper (used by collect)
36+
└── ui_sources.txt # intermediate output from collect_test_sources.sh
1437
```
1538

16-
To remake the ui tests and filter into the passing and failing directories (optionally storing the output)
39+
## How it works
40+
41+
The base lists (`passing.tsv`, `failing.tsv`) are the ground truth, generated against the nightly recorded in `base-nightly.txt`. They don't change when you target a different nightly.
42+
43+
For other nightlies, upstream test files may have been deleted, renamed, or modified. Rather than maintaining full copies of the lists per nightly (they're 99.5% identical), `diff_test_lists.sh` computes the delta:
44+
45+
1. **Deletions**: files removed upstream are dropped from the list
46+
2. **Renames**: files that moved get their paths updated
47+
3. **Manual overrides**: behavior changes that git can't detect (e.g., a test was rewritten to use syntax our driver doesn't handle) are recorded in `overrides/<nightly>.tsv`
48+
49+
`run_ui_tests.sh` detects the active nightly via `rustup show active-toolchain` and automatically uses the effective list from `overrides/<nightly>/` if it exists, falling back to the base list otherwise.
50+
51+
## Adding support for a new nightly
1752

1853
```bash
19-
cd tests/ui/
20-
./remake_ui_tests.sh <PATH-TO-RUST> [y|n]
54+
# 1. See what changed:
55+
./tests/ui/diff_test_lists.sh /path/to/rust nightly-YYYY-MM-DD
56+
57+
# 2. If any tests have behavior changes, create a manual override file:
58+
# tests/ui/overrides/nightly-YYYY-MM-DD.tsv
59+
# Format: action<TAB>path
60+
# Actions: skip, -, +, fail (with exit code), pass
61+
62+
# 3. Generate the effective lists:
63+
./tests/ui/diff_test_lists.sh --emit /path/to/rust nightly-YYYY-MM-DD
64+
65+
# 4. Run the tests:
66+
RUSTUP_TOOLCHAIN=nightly-YYYY-MM-DD RUST_DIR_ROOT=/path/to/rust make test-ui
67+
68+
# 5. Commit the override file and generated lists.
2169
```
2270

23-
To run the passing tests again
71+
## Regenerating the base lists
72+
73+
To regenerate from scratch against a new base nightly (only needed when re-baselining, not for routine nightly bumps):
2474

2575
```bash
26-
cd tests/ui/
27-
./run_ui_tests.sh <PATH-TO-RUST>
28-
```
76+
# Discover candidate test sources:
77+
RUST_TOP=/path/to/rust ./tests/ui/collect_test_sources.sh > tests/ui/ui_sources.txt
78+
79+
# Regenerate passing/failing lists:
80+
./tests/ui/remake_ui_tests.sh /path/to/rust
81+
82+
# Update the base nightly marker:
83+
echo "nightly-YYYY-MM-DD" > tests/ui/base-nightly.txt
84+
```
85+
86+
## diff_test_lists.sh modes
87+
88+
| Mode | Description |
89+
|------|-------------|
90+
| `--report` (default) | Human-readable summary per nightly: deletions, renames, modifications, effective list size |
91+
| `--chain` | Incremental diffs between consecutive breakpoint nightlies |
92+
| `--emit` | Write effective `passing.tsv` and `failing.tsv` to `overrides/<nightly>/` |

tests/ui/base-nightly.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nightly-2024-11-29

0 commit comments

Comments
 (0)