|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "This Month in Our Test Infra: September 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: September 2024 |
| 9 | + |
| 10 | +This is a quick summary of the changes in the test infrastructure for the |
| 11 | +[rust-lang/rust][rust] repository[^scope] for September 2024. It also includes |
| 12 | +brief descriptions of on-going work. |
| 13 | + |
| 14 | +[^scope]: The test infra here refers to the test harness [compiletest] and |
| 15 | +supporting components in our build system [bootstrap]. This test infra is used |
| 16 | +mainly by rustc and rustdoc. Other tools like cargo, miri or rustfmt maintain |
| 17 | +their own test infra. |
| 18 | + |
| 19 | +As usual, if you encounter bugs or UX issues when using our test infrastrucutre, |
| 20 | +please [file an issue][new-issue]. Bugs and papercuts can't be fixed if we don't |
| 21 | +know about them! |
| 22 | + |
| 23 | +## Changes |
| 24 | + |
| 25 | +### `run-make` test suite now has access to a properly-staged cargo |
| 26 | + |
| 27 | +[bootstrap] now builds a properly-staged cargo and makes it available for |
| 28 | +`run-make` tests. Previously, `run-make` tests just used whatever initial cargo |
| 29 | +[bootstrap] had access to, but this caused problems if a `run-make` test uses a |
| 30 | +cargo feature that's present in nightly but not in beta. We encountered some |
| 31 | +interesting build cache invalidation issues related to differing `RUSTFLAGS` in |
| 32 | +the process, but were able to fix them. We want to add mechanisms to [bootstrap] |
| 33 | +to make it harder to misuse `RUSTFLAGS` which may lead to hard-to-diagnose build |
| 34 | +cache invalidation in the future. |
| 35 | + |
| 36 | +- bootstrap: [Fix cargo staging for run-make tests #130739](https://github.com/rust-lang/rust/pull/130739) |
| 37 | +- bootstrap/compiletest: [Pass the current cargo to run-make tests #130642](https://github.com/rust-lang/rust/pull/130642) |
| 38 | +- bootstrap: [Prevent building cargo from invalidating build cache of other |
| 39 | + tools due to conditionally applied `-Zon-broken-pipe=kill` via tracked |
| 40 | + `RUSTFLAGS` #131155](https://github.com/rust-lang/rust/pull/131155) |
| 41 | + |
| 42 | +Why `-Zon-broken-pipe=kill` is required when building rustc was its [own entire |
| 43 | +rabbit hole](https://github.com/rust-lang/rust/issues/131436), in case you were |
| 44 | +curious. |
| 45 | + |
| 46 | +### More `run-make` migrations and fixes |
| 47 | + |
| 48 | +The `emit-to-stdout` `run-make` test was ported to `rmake.rs`, only [10 more to |
| 49 | +go]. The remaining ones are stuck on being quite tricky. See the [tracking |
| 50 | +issue][port-run-make] for why we are transitioning away from `Makefile`s in |
| 51 | +`run-make` tests. |
| 52 | + |
| 53 | +- run-make: [port `emit-to-stdout` to rmake.rs #131355](https://github.com/rust-lang/rust/pull/131355) |
| 54 | + |
| 55 | +Misc: |
| 56 | + |
| 57 | +- run-make: [Add missing `needs-llvm-components` directives for run-make tests |
| 58 | + that need target-specific codegen |
| 59 | + #129605](https://github.com/rust-lang/rust/pull/129605) |
| 60 | + |
| 61 | +[remaining-run-make-tests]: https://github.com/rust-lang/rust/blob/883f9a2c8f8923eafafbeba8b18361424b148f05/src/tools/tidy/src/allowed_run_make_makefiles.txt#L1C1-L10C30 |
| 62 | +[port-run-make]: https://github.com/rust-lang/rust/issues/121876 |
| 63 | + |
| 64 | +### `run_make_support` library updates |
| 65 | + |
| 66 | +`run_make_support` is the support library built and made available to `run-make` |
| 67 | +tests. |
| 68 | + |
| 69 | +- run_make_support: [Add `llvm-pdbutil` wrapper #130048](https://github.com/rust-lang/rust/pull/130048) |
| 70 | +- run_make_support: [Rename `Command::stdin` to `stdin_buf` and add |
| 71 | + `std{in,out,err}` config helpers |
| 72 | + #129973](https://github.com/rust-lang/rust/pull/129973) |
| 73 | +- run_make_support: [Rectify symlink handling |
| 74 | + #130427](https://github.com/rust-lang/rust/pull/130427) |
| 75 | + |
| 76 | +### [compiletest] improvements and fixes |
| 77 | + |
| 78 | +We dropped [compiletest]'s legacy directive check (e.g. `// ignore-test hello` |
| 79 | +no longer warns). This was originally added when we migrated from `//` to `//@` |
| 80 | +to help test writers notice the new directives, but now a long time has passed |
| 81 | +so we can remove it as it was causing friction in adding new directives and |
| 82 | +authoring tests. For example, the [Specification Team][t-spec] wanted to add a |
| 83 | +`//@ reference` directive, but the legacy directive check would trigger on: |
| 84 | + |
| 85 | +```rust,no_run |
| 86 | +// So what if we added a |
| 87 | +// reference to the <- `reference` is a known directive, and |
| 88 | +// `// reference` looks suspcious! |
| 89 | +// rustc-dev-guide? |
| 90 | +``` |
| 91 | + |
| 92 | +This was added to initially to help migration from `//` to `//@`, but since a |
| 93 | +long time has passed we no longer need this check to help contributors know that |
| 94 | +legacy directives are being phased out. |
| 95 | + |
| 96 | +- compiletest: [Drop compiletest legacy directive check |
| 97 | + #131392](https://github.com/rust-lang/rust/pull/131392) |
| 98 | + |
| 99 | +[t-spec]: https://www.rust-lang.org/governance/teams/lang#team-spec |
| 100 | + |
| 101 | +We updated some `compiletest` normalizations and directive renaming. In |
| 102 | +particular, we restricted `//@ ignore-mode-*` directives to not accept *all* |
| 103 | +test suites, and later converted `//@ ignore-mode-coverage-map` and `//@ |
| 104 | +ignore-mode-coverage-run` to `//@ ignore-coverage-map` and `//@ |
| 105 | +ignore-coverage-run` because only `coverage-map` and `coverage-run` were special |
| 106 | +in that the same test source files ran under two test suite configurations. |
| 107 | + |
| 108 | +- compiletest: [Add `{{rust-src-base}}` (for sysroot src base) |
| 109 | + #129687](https://github.com/rust-lang/rust/pull/129687) |
| 110 | +- compiletest: [Restrict `ignore-mode-*` directives |
| 111 | + #131346](https://github.com/rust-lang/rust/pull/131346) |
| 112 | +- compiletest: [Simplify the compiletest directives for ignoring coverage-test |
| 113 | + modes #131400](https://github.com/rust-lang/rust/pull/131400) |
| 114 | + |
| 115 | +We broke up [compiletest]'s `runtest.rs` as it was [previously |
| 116 | +*massive*][prev-runtest], clocking in at 4710 lines. It's now around 2700 lines, |
| 117 | +so still massive, but at least slightly less so. |
| 118 | + |
| 119 | +- compiletest: [Break up compiletest `runtest.rs` into smaller helper modules |
| 120 | + #130566](https://github.com/rust-lang/rust/pull/130566) |
| 121 | + |
| 122 | +[prev-runtest]: https://github.com/rust-lang/rust/blob/b7b9453ea7354ee39b15390ffd0b4f9e2000076b/src/tools/compiletest/src/runtest.rs |
| 123 | + |
| 124 | +We added a help message upon `crashes` test failure that you can set |
| 125 | +`COMPILETEST_VERBOSE_CRASHES=1` to get compiler stderr/stdout output from trying |
| 126 | +to build the failing `crashes` test. |
| 127 | + |
| 128 | +- compiletest: [Mention `COMPILETEST_VERBOSE_CRASHES` on crashes test failure |
| 129 | + #130793](https://github.com/rust-lang/rust/pull/130793) |
| 130 | + |
| 131 | +We also registered [tool docs][compiletest-tool-docs] for [compiletest]. There |
| 132 | +currently isn't much doc comments in [compiletest], but having them getting |
| 133 | +built and made available as part of nightly rustc docs is a good first step. |
| 134 | + |
| 135 | +- bootstrap: [Register tool docs for compiletest |
| 136 | + #130567](https://github.com/rust-lang/rust/pull/130567) |
| 137 | + |
| 138 | +[compiletest-tool-docs]: https://doc.rust-lang.org/nightly/nightly-rustc/compiletest/index.html |
| 139 | + |
| 140 | +Misc: |
| 141 | + |
| 142 | +- compiletest: [Rename "runtest/crash.rs" to "runtest/crashes.rs" to be in line |
| 143 | + with the test directory |
| 144 | + #130973](https://github.com/rust-lang/rust/pull/130973) |
| 145 | + |
| 146 | +### Testing documentation improvements |
| 147 | + |
| 148 | +We improved testing docs in [rustc-dev-guide][dev-guide-testing]. We added a |
| 149 | +[testing best practices chapter][dev-guide-testing-best-practices], and updated |
| 150 | +the [compiletest directives listing][dev-guide-directives-listing]. |
| 151 | + |
| 152 | +- rustc-dev-guide: [Revise testing chapters excluding the directives chapter |
| 153 | + #2088](https://github.com/rust-lang/rustc-dev-guide/pull/2088) |
| 154 | +- rustc-dev-guide: [Revise directives docs |
| 155 | + #2089](https://github.com/rust-lang/rustc-dev-guide/pull/2089) |
| 156 | +- rustc-dev-guide: [Revise test naming advice to discourage using issue numbers |
| 157 | + alone #2090](https://github.com/rust-lang/rustc-dev-guide/pull/2090) |
| 158 | +- rustc-dev-guide: [Document compiletest directives `ignore-coverage-map` and |
| 159 | + `ignore-coverage-run` |
| 160 | + #2094](https://github.com/rust-lang/rustc-dev-guide/pull/2094) |
| 161 | +- rustc-dev-guide: [Small follow-up to my "internal #[rustc_*] TEST attributes" |
| 162 | + PR #2082](https://github.com/rust-lang/rustc-dev-guide/pull/2082) |
| 163 | +- rustc-dev-guide: [Note lldb debuginfo requires `python310.dll` to be present |
| 164 | + in `PATH` on Windows |
| 165 | + #2076](https://github.com/rust-lang/rustc-dev-guide/pull/2076) |
| 166 | +- rustc-dev-guide: [Document crashes test suite |
| 167 | + #2075](https://github.com/rust-lang/rustc-dev-guide/pull/2075) |
| 168 | +- rustc-dev-guide: [Purge `run-pass-valgrind mentions` |
| 169 | + #2091](https://github.com/rust-lang/rustc-dev-guide/pull/2091) |
| 170 | +- rustc-dev-guide: [Add documentation for `{{rust-src-base}}` |
| 171 | + #2079](https://github.com/rust-lang/rustc-dev-guide/pull/2079) |
| 172 | + |
| 173 | +There's still a lot of room for improvement in our testing docs -- in |
| 174 | +[compiletest], [bootstrap] and [rustc-dev-guide], but one step at a time. |
| 175 | + |
| 176 | +[dev-guide-testing]: https://rustc-dev-guide.rust-lang.org/tests/intro.html |
| 177 | +[dev-guide-testing-best-practices]: https://rustc-dev-guide.rust-lang.org/tests/best-practices.html |
| 178 | +[dev-guide-directives-listing]: https://rustc-dev-guide.rust-lang.org/tests/directives.html |
| 179 | + |
| 180 | +### Test suite cleanups |
| 181 | + |
| 182 | +We deleted an entire test suite `run-pass-valgrind` because it was never |
| 183 | +properly wired up and properly implemented, and was not used. It turns out |
| 184 | +deleting the test suite actually fixes a bug from 2017 [run-pass-valgrind tests |
| 185 | +don't actually run in valgrind |
| 186 | +#44816](https://github.com/rust-lang/rust/issues/44816) because you can't have a |
| 187 | +test suite related bug if the test suite doesn't exist! |
| 188 | + |
| 189 | +- bootstrap/compiletest/opt-dist: [Remove valgrind test suite and support from |
| 190 | + compiletest, bootstrap and opt-dist |
| 191 | + #131351](https://github.com/rust-lang/rust/pull/131351) |
| 192 | + |
| 193 | +Misc: |
| 194 | + |
| 195 | +- rustdoc: [Rename `issue-\d+.rs` tests to have meaningful names (part 9) |
| 196 | + #130287](https://github.com/rust-lang/rust/pull/130287) |
| 197 | + |
| 198 | +## On-going developments |
| 199 | + |
| 200 | +- Add test infrastructure support for a `minicore` test auxiliary, so that |
| 201 | + `#![no_std]` cross-compiling build-only tests don't need to reinvent and |
| 202 | + reimplement `core` prelude stubs again and again. See |
| 203 | + <https://github.com/rust-lang/rust/issues/131485>. |
| 204 | +- We want to make `RUSTFLAGS` harder to misuse that can lead to tool build cache |
| 205 | + invalidation, leading to unnecessary rebuilds. |
| 206 | +- There's on-going effort to redesign stage0 std, to help make [bootstrap] |
| 207 | + staging more consistent and more intuitive. |
| 208 | + |
| 209 | +[rust]: https://github.com/rust-lang/rust |
| 210 | +[compiletest]: https://github.com/rust-lang/rust/tree/master/src/tools/compiletest |
| 211 | +[bootstrap]: https://github.com/rust-lang/rust/tree/master/src/bootstrap |
| 212 | +[new-issue]: https://github.com/rust-lang/rust/issues/new |
| 213 | +[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/getting-started.html |
0 commit comments