Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention RUSTC_BOOTSTRAP for misc testing #2136

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- [Rust for Linux](./tests/rust-for-linux.md)
- [Performance testing](./tests/perf.md)
- [Suggest tests tool](./tests/suggest-tests.md)
- [Misc info](./tests/misc.md)
- [Debugging the compiler](./compiler-debugging.md)
- [Using the tracing/logging instrumentation](./tracing.md)
- [Profiling the compiler](./profiling.md)
Expand Down
4 changes: 4 additions & 0 deletions src/tests/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ chapter](ecosystem.md) for more details.
A separate infrastructure is used for testing and tracking performance of the
compiler. See the [Performance testing chapter](perf.md) for more details.

## Miscellaneous information

There are some other useful testing-related info at [Misc info](misc.md).

## Further reading

The following blog posts may also be of interest:
Expand Down
40 changes: 40 additions & 0 deletions src/tests/misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Miscellaneous testing-related info

## `RUSTC_BOOTSTRAP` and stability

<!-- date-check: Nov 2024 -->

This is a bootstrap/compiler implementation detail, but it can also be useful
for testing:

- `RUSTC_BOOTSTRAP=1` will "cheat" and bypass usual stability checking, allowing
you to use unstable features and cli flags on a stable `rustc`.
- `RUSTC_BOOTSTRAP=-1` will force a given `rustc` to pretend that is a stable
compiler, even if it's actually a nightly `rustc`. This is useful because some
behaviors of the compiler (e.g. diagnostics) can differ depending on whether
the compiler is nightly or not.

In `ui` tests and other test suites that support `//@ rustc-env`, you can specify

```rust,ignore
// Force unstable features to be usable on stable rustc
//@ rustc-env:RUSTC_BOOTSTRAP=1

// Or force nightly rustc to pretend it is a stable rustc
//@ rustc-env:RUSTC_BOOTSTRAP=-1
```

For `run-make` tests, `//@ rustc-env` is not supported. You can do something
like the following for individual `rustc` invocations.

```rust,ignore
use run_make_support::rustc;

fn main() {
rustc()
// Pretend that I am very stable
.env("RUSTC_BOOTSTRAP", "-1")
//...
.run();
}
```