Home Explore Blog CI



rustc

5th chunk of `src/tests/directives.md`
3f2f718a59f7d87c9c32317dd12e3c9abc2eaa12c07d4ecf0000000100000fe6
    where the test binary's stdout and stderr gets concatenated and then
    `error-pattern`s are matched on this combined output, which is ??? slightly
    questionable to say the least.

### Controlling when tests are run

These directives are used to ignore the test in some situations, which
means the test won't be compiled or run.

* `ignore-X` where `X` is a target detail or other criteria on which to ignore the test (see below)
* `only-X` is like `ignore-X`, but will *only* run the test on that target or
  stage
* `ignore-auxiliary` is intended for files that *participate* in one or more other
  main test files but that `compiletest` should not try to build the file itself.
  Please backlink to which main test is actually using the auxiliary file.
* `ignore-test` always ignores the test. This can be used to temporarily disable
  a test if it is currently not working, but you want to keep it in tree to
  re-enable it later.

Some examples of `X` in `ignore-X` or `only-X`:

- A full target triple: `aarch64-apple-ios`
- Architecture: `aarch64`, `arm`, `mips`, `wasm32`, `x86_64`, `x86`,
  ...
- OS: `android`, `emscripten`, `freebsd`, `ios`, `linux`, `macos`, `windows`,
  ...
- Environment (fourth word of the target triple): `gnu`, `msvc`, `musl`
- WASM: `wasm32-bare` matches `wasm32-unknown-unknown`. `emscripten` also
  matches that target as well as the emscripten targets.
- Pointer width: `32bit`, `64bit`
- Endianness: `endian-big`
- Stage: `stage1`, `stage2`
- Binary format: `elf`
- Channel: `stable`, `beta`
- When cross compiling: `cross-compile`
- When [remote testing] is used: `remote`
- When particular debuggers are being tested: `cdb`, `gdb`, `lldb`
- When particular debugger versions are matched: `ignore-gdb-version`
  `compare-mode-split-dwarf`, `compare-mode-split-dwarf-single`
- The two different test modes used by coverage tests:
  `ignore-coverage-map`, `ignore-coverage-run`
- When testing a dist toolchain: `dist`
  - This needs to be enabled with `COMPILETEST_ENABLE_DIST_TESTS=1`
- The `rustc_abi` of the target: e.g. `rustc_abi-x86_64-sse2`

The following directives will check rustc build settings and target
settings:

- `needs-asm-support` — ignores if it is running on a target that doesn't have
  stable support for `asm!`
- `needs-profiler-runtime` — ignores the test if the profiler runtime was not
  enabled for the target
  (`build.profiler = true` in rustc's `bootstrap.toml`)
- `needs-sanitizer-support` — ignores if the sanitizer support was not enabled
  for the target (`sanitizers = true` in rustc's `bootstrap.toml`)
- `needs-sanitizer-{address,hwaddress,leak,memory,thread}` — ignores if the
  corresponding sanitizer is not enabled for the target (AddressSanitizer,
  hardware-assisted AddressSanitizer, LeakSanitizer, MemorySanitizer or
  ThreadSanitizer respectively)
- `needs-run-enabled` — ignores if it is a test that gets executed, and running
  has been disabled. Running tests can be disabled with the `x test --run=never`
  flag, or running on fuchsia.
- `needs-unwind` — ignores if the target does not support unwinding
- `needs-rust-lld` — ignores if the rust lld support is not enabled (`rust.lld =
  true` in `bootstrap.toml`)
- `needs-threads` — ignores if the target does not have threading support
- `needs-subprocess`  — ignores if the target does not have subprocess support
- `needs-symlink` — ignores if the target does not support symlinks. This can be
  the case on Windows if the developer did not enable privileged symlink
  permissions.
- `ignore-std-debug-assertions` — ignores if std was built with debug
  assertions.
- `needs-std-debug-assertions` — ignores if std was not built with debug
  assertions.
- `ignore-rustc-debug-assertions` — ignores if rustc was built with debug
  assertions.
- `needs-rustc-debug-assertions` — ignores if rustc was not built with debug
  assertions.
- `needs-target-has-atomic` — ignores if target does not have support for all
  specified atomic widths, e.g. the test with `//@ needs-target-has-atomic: 8,

Title: Controlling Test Execution: Ignore, Only, and Target-Specific Directives
Summary
This section details directives that control when tests are executed, including `ignore-X` and `only-X` for target-specific exclusions or inclusions, `ignore-auxiliary` for excluding auxiliary files from direct compilation, and `ignore-test` for temporarily disabling tests. It lists examples of `X` such as target triples, architectures, operating systems, environments, WASM targets, pointer widths, endianness, stages, binary formats, channels, cross-compilation, remote testing, debuggers, coverage test modes, dist toolchains and rustc ABIs. The section also covers directives that check rustc build settings and target settings like `needs-asm-support`, `needs-profiler-runtime`, `needs-sanitizer-support`, `needs-run-enabled`, `needs-unwind`, `needs-rust-lld`, `needs-threads`, `needs-subprocess`, `needs-symlink`, and others related to debug assertions and atomic support.