Skip to content

Commit ce63356

Browse files
committed
Add Dec 2024 issue of This Month In Our Test Infra
1 parent ceca203 commit ce63356

File tree

1 file changed

+220
-0
lines changed

1 file changed

+220
-0
lines changed
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
---
2+
layout: post
3+
title: "This Month in Our Test Infra: December 2024"
4+
author: Jieyou Xu
5+
team: the Bootstrap Team <https://www.rust-lang.org/governance/teams/infra#team-bootstrap>
6+
---
7+
8+
# This Month in Our Test Infra: December 2024
9+
10+
<!-- time period: 2024-12-04 through 2025-01-05 -->
11+
12+
Happy new year, dear reader! This is the last *This Month in Our Test Infra* issue for 2024.
13+
14+
This is a quick summary of the changes in the test infrastructure for the [rust-lang/rust] repository[^scope] for **December 2024**.
15+
16+
[^scope]: The test infra here refers to the test harness [compiletest] and supporting components in our build system [bootstrap]. This test infra is used mainly by rustc and rustdoc. Other tools like cargo, miri or rustfmt maintain their own test infra.
17+
18+
As usual, if you encounter bugs or UX issues when using our test infrastructure, please [file an issue][new-issue]. Bugs and papercuts can't be fixed if we don't know about them!
19+
20+
**Thanks to everyone who contributed to our test infra!**
21+
22+
## Highlights
23+
24+
### `rustc-dev-guide` is now a `josh` subtree!
25+
26+
Previously, [rustc-dev-guide] was a submodule inside [rust-lang/rust], and updates to [rustc-dev-guide] had to be done in a separate PR against the [rustc-dev-guide] repository.
27+
28+
Now, thanks to [@Kobzol](https://github.com/Kobzol)'s efforts (which included overcoming many unforeseen obstacles), [`rustc-dev-guide` is now a `josh` subtree][pr-134907]. This is a significant improvement for contribution workflows because it means that documentation updates to [rustc-dev-guide] can accompany the implementation change in [rust-lang/rust] in the same PR. The reduction in contribution friction also encourages [rustc-dev-guide] updates because you no longer have to author and maintain two separate PRs.
29+
30+
[pr-134907]: https://github.com/rust-lang/rust/pull/134907
31+
32+
### compiletest will now show the difference between normalized output and actual output for differing lines
33+
34+
Previously, it can be very difficult to tell when a ui test fails what the actual output is pre-normalization, as you would have to resort to `--nocapture` or similar.
35+
36+
Now, [compiletest will also show the pre-normalization mismatched output lines on failure to make this easier to tell][pr-133733]. Example output:
37+
38+
```text
39+
failures:
40+
41+
---- [ui] tests/ui/layout/enum.rs stdout ----
42+
diff of stderr:
43+
44+
- error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: $PREF_ALIGN }
45+
+ error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: $PREF_ALIN }
46+
2 --> $DIR/enum.rs:9:1
47+
3 |
48+
4 LL | enum UninhabitedVariantAlign {
49+
50+
Note: some mismatched output was normalized before being compared
51+
- error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: Align(8 bytes) }
52+
- --> /home/jyn/src/rust2/tests/ui/layout/enum.rs:9:1
53+
+ error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: $PREF_ALIN }
54+
```
55+
56+
[pr-133733]: https://github.com/rust-lang/rust/pull/133733
57+
58+
### compiletest now allows using a specific debugger when running debuginfo tests
59+
60+
For a long time, the `tests/debuginfo` test suite could only be successfully run if you had all the tested debuggers (being `lldb`, `gdb`, `cdb`). This is very annoying locally if:
61+
62+
- One or more of these debuggers are not available or don't work locally[^lldb].
63+
- You just wanted to look at the test failures for a given debugger.
64+
65+
Now, you are able to run the `tests/debuginfo` test suite with a *specific* debugger, to only run the tests against that specified debugger. Example usage:
66+
67+
```bash
68+
$ ./x test tests/debuginfo -- --debugger gdb
69+
```
70+
71+
### `ui` tests now support `//@ forbid-output`
72+
73+
`ui` tests can now use the `//@ forbid-output: REGEX` directive to check for a pattern which must not appear in the stderr. If the `REGEX` pattern is matched, then the `ui` test will fail.
74+
75+
Please consult [rustc-dev-guide] for more details.
76+
77+
### `./x test` now accepts a `--no-capture` flag which will be forwarded to compiletest (and thus libtest)
78+
79+
Previously, if you wanted to pass the `--nocapture` flag through [bootstrap], through [compiletest], to the underlying [libtest] runner, on Linux you have to write:
80+
81+
```bash
82+
$ ./x test tests/ui -- --nocapture
83+
```
84+
85+
On native Windows msvc it's even worse, I recall having to write
86+
87+
```powershell
88+
PS> ./x test tests/ui -- -- --nocapture
89+
```
90+
91+
Which is hard to discover and a contributor papercut[^nocapture].
92+
93+
Now, you can just write
94+
95+
```bash
96+
$ ./x test tests/ui --no-capture
97+
```
98+
99+
and bootstrap will forward this flag as `--nocapture` to the underlying [libtest].
100+
101+
102+
## Notable changes
103+
104+
This section is intended to be like a "compatibility notes" but for human test writers.
105+
106+
### `FileCheck`-based test suites no longer predefine `MSVC` and `NONMSVC` `FileCheck` prefixes
107+
108+
In the *current* setup, compiletest will register a [`FileCheck`][filecheck] custom prefix for each compiletest `//@ revision`. However, for historical reasons compiletest also predefined `MSVC` and `NONMSVC` `FileCheck` prefixes depending on the *host*. But this is very surprising for two reasons:
109+
110+
1. It's "spooky action in a distance" because the user never declared these custom prefixes, and these prefixes are conditionally set based on the host. It's hard to debug too.
111+
2. If the user also wants to add their own `//@ revision: MSVC NONMSVC` revisions, because compiletest would pass `--check-prefix` for those names twice, this will cause `FileCheck` to report an error about duplicate prefixes.
112+
113+
Therefore, in [compiletest: don't register predefined `MSVC`/`NONMSVC` `FileCheck` prefixes #134463](https://github.com/rust-lang/rust/pull/134463) we no longer predefine these two `FileCheck` prefixes.
114+
115+
If you want the previous `MSVC` vs `NONMSVC` behavior, you will need to explicitly write out
116+
117+
```rs
118+
//@ revisions: MSVC NONMSVC
119+
//@[MSVC] only-windows-msvc
120+
//@[NONMSVC] ignore-windows-msvc
121+
```
122+
123+
### `normalize-{stderr,stdout}-test` directives are renamed to `normalize-{stderr,stdout}`
124+
125+
Mostly a cleanup, the `-test` suffixes provide no additionally useful information, and only make these two `normalize-*` directives hard to discover.
126+
127+
`normalize-{stderr,stdout}-test` directives are now [renamed to `normalize-{stderr,stdout}`][pr-134759]. `normalize-{stderr,stdout}-{32,64}bit` directives remain unaffected.
128+
129+
[pr-134759]: https://github.com/rust-lang/rust/pull/134759
130+
131+
### compiletest will now deny usages of builtin `FileCheck` suffixes as revision names (for `FileCheck`-based test suites)
132+
133+
For [`FileCheck`][filecheck]-based test suites (`assembly`, `codegen`, `mir-opt`), compiletest will register a custom `FileCheck` prefix for each compiletest `//@ revision`. However, `FileCheck` also has some [builtin suffixes][filecheck-suffixes] such as:
134+
135+
```rust
136+
// COM:
137+
// CHECK:
138+
// CHECK-NEXT:
139+
// CHECK-SAME:
140+
// CHECK-EMPTY:
141+
// CHECK-NOT:
142+
// CHECK-COUNT:
143+
// CHECK-DAG:
144+
// CHECK-LABEL:
145+
```
146+
147+
When combined, this previously meant that the compiletest revision + builtin `FileCheck` suffix constructions such as
148+
149+
```rust
150+
// next:
151+
// same-SAME:
152+
// not-NOT:
153+
// next-NEXT:
154+
// not-SAME:
155+
```
156+
157+
are permitted by compiletest, which are incredibly confusing.
158+
159+
As such, compiletest will now reject `CHECK`, `COM`, `NEXT`, `SAME`, `EMPTY`, `NOT`, `COUNT`, `DAG`, `LABEL` as revision names in `FileCheck`-based test suites.
160+
161+
[filecheck-suffixes]: https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-next-directive
162+
163+
164+
## PR listing
165+
166+
### Improvements
167+
168+
- [rustc-dev-guide]: [Turn `rustc-dev-guide` into a `josh` subtree #134907](https://github.com/rust-lang/rust/pull/134907)
169+
- [compiletest]: [Show the difference between the normalized output and the actual output for lines which didn't match #133733](https://github.com/rust-lang/rust/pull/133733)
170+
- [compiletest]: [Explain that UI tests are expected not to compile by default #133813](https://github.com/rust-lang/rust/pull/133813)
171+
- [compiletest]: [Allow using a specific debugger when running `debuginfo` tests #134629](https://github.com/rust-lang/rust/pull/134629)
172+
- [compiletest], [run-make-support]: [Improve `compiletest` and `run-make-support` symlink handling](https://github.com/rust-lang/rust/pull/134659)
173+
- [compiletest]: [Support `forbid-output` in UI tests #134738](https://github.com/rust-lang/rust/pull/134738)
174+
- [bootstrap]: [Add `--no-capture`/`--nocapture` as bootstrap arguments #134809](https://github.com/rust-lang/rust/pull/134809)
175+
- [bootstrap]: [Allow `./x check compiletest` #134848](https://github.com/rust-lang/rust/pull/134848)
176+
- [compiletest]: [Deny usage of special `FileCheck` suffixes as revision names #134925](https://github.com/rust-lang/rust/pull/134925)
177+
- [tidy]: [Run Python formatting check in `tidy` on CI #134964](https://github.com/rust-lang/rust/pull/134964)
178+
- [tidy]: [Print how to rebless Python formatting in `tidy` #134968](https://github.com/rust-lang/rust/pull/134968)
179+
180+
### Fixes
181+
182+
- [compiletest]: [Fix `--nocapture` for `run-make` tests #134111](https://github.com/rust-lang/rust/pull/134111)
183+
- [compiletest]: [Remove empty 'expected' files when blessing #134808](https://github.com/rust-lang/rust/pull/134808)
184+
- [run-make]: [Fix `assert_stderr_not_contains_regex` #134113](https://github.com/rust-lang/rust/pull/134113)[^oops]
185+
186+
### Cleanups
187+
188+
- [compiletest]: [Don't register predefined `MSVC`/`NONMSVC` `FileCheck` prefixes](https://github.com/rust-lang/rust/pull/134463)
189+
- [compiletest]: [Remove the `-test` suffix from `normalize-*` directives #134759](https://github.com/rust-lang/rust/pull/134759)
190+
- [compiletest]: [Only pass the post-colon value to `parse_normalize_rule` #134840](https://github.com/rust-lang/rust/pull/134840)
191+
- [compiletest]: [Slightly simplify the handling of debugger directive prefixes #134849](https://github.com/rust-lang/rust/pull/134849)
192+
- [bootstrap]: [Consolidate the macros for declaring compiletest test suites #134876](https://github.com/rust-lang/rust/pull/134876)
193+
- [tidy]: [Replace `black` with `ruff` in `tidy` #133821](https://github.com/rust-lang/rust/pull/133821)
194+
195+
### Documentation updates
196+
197+
- [Document how to run the split Docker pipelines #134894](https://github.com/rust-lang/rust/pull/134894)
198+
- [Document the `--dev` flag for `src/ci/docker/run.sh` #134669](https://github.com/rust-lang/rust/pull/134669)
199+
- [rustc-dev-guide]: [`compiletest`: Document the `--debugger` flag #2170](https://github.com/rust-lang/rustc-dev-guide/pull/2170)
200+
- [rustc-dev-guide]: [Document `forbid-output` for UI tests #2171](https://github.com/rust-lang/rustc-dev-guide/pull/2171)
201+
- [rustc-dev-guide]: [Remove the `-test` suffix from normalize directives #2172](https://github.com/rust-lang/rustc-dev-guide/pull/2172)
202+
- [rustc-dev-guide]: [Document `x test --no-capture` #2174](https://github.com/rust-lang/rustc-dev-guide/pull/2174)
203+
- [rustc-dev-guide]: [Describe how to use rust-analyzer with `rmake.rs` #2191](https://github.com/rust-lang/rustc-dev-guide/pull/2191)
204+
205+
206+
[rust-lang/rust]: https://github.com/rust-lang/rust
207+
[rustc-dev-guide]: https://github.com/rust-lang/rustc-dev-guide
208+
[compiletest]: https://github.com/rust-lang/rust/tree/master/src/tools/compiletest
209+
[run-make-support]: https://github.com/rust-lang/rust/tree/master/src/tools/run-make-support
210+
[bootstrap]: https://github.com/rust-lang/rust/tree/master/src/bootstrap
211+
[libtest]: https://github.com/rust-lang/rust/tree/master/library/test
212+
[new-issue]: https://github.com/rust-lang/rust/issues/new
213+
[filecheck]: https://llvm.org/docs/CommandGuide/FileCheck.html
214+
[run-make]: https://github.com/rust-lang/rust/tree/master/tests/run-make
215+
[tidy]: https://github.com/rust-lang/rust/tree/master/src/tools/tidy
216+
217+
218+
[^lldb]: For example, I keep having to debug the debugger like `lldb` when the older `lldb` versions keep complaining about `ModuleNotFoundError: No module named '_lldb'`.
219+
[^nocapture]: I don't know about you, but I can never for the life of me remember what the flag is called. I keep thinking it's `--no-capture` when currently libtest only accepts `--nocapture`. Thankfully T-testing-devex FCP'd to add the more conventional version `--no-capture`, looking forward to that. I can also never figure out how many `--` dashes I need, I keep finding myself having to add more `--` until it starts working.
220+
[^oops]: Nyehehehe

0 commit comments

Comments
 (0)