about summary refs log tree commit diff
path: root/src/tools/compiletest
AgeCommit message (Collapse)AuthorLines
2024-05-30compiletest: clarify COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS errorRalf Jung-3/+6
also improve wording for an ignore reason
2024-05-30compiletest: Unify `cmd2procres` with `run_command_to_procres`Zalathar-29/+19
2024-05-29Extract coverage-specific code out of `compiletest::runtest`Zalathar-426/+372
This moves a few hundred lines of coverage-specific code out of the main module, making navigation a bit easier.
2024-05-28Make more of the test suite run on Mac CatalystMads Marquart-3/+10
This adds the `only-apple`/`ignore-apple` compiletest directive, and uses that basically everywhere instead of `only-macos`/`ignore-macos`. Some of the updates in `run-make` are a bit redundant, as they use `ignore-cross-compile` and won't run on iOS - but using Apple in these is still more correct, so I've made that change anyhow.
2024-05-23Rollup merge of #125156 - zachs18:for_loops_over_fallibles_behind_refs, ↵Matthias Krüger-2/+2
r=Nilstrieb Expand `for_loops_over_fallibles` lint to lint on fallibles behind references. Extends the scope of the (warn-by-default) lint `for_loops_over_fallibles` from just `for _ in x` where `x: Option<_>/Result<_, _>` to also cover `x: &(mut) Option<_>/Result<_>` ```rs fn main() { // Current lints for _ in Some(42) {} for _ in Ok::<_, i32>(42) {} // New lints for _ in &Some(42) {} for _ in &mut Some(42) {} for _ in &Ok::<_, i32>(42) {} for _ in &mut Ok::<_, i32>(42) {} // Should not lint for _ in Some(42).into_iter() {} for _ in Some(42).iter() {} for _ in Some(42).iter_mut() {} for _ in Ok::<_, i32>(42).into_iter() {} for _ in Ok::<_, i32>(42).iter() {} for _ in Ok::<_, i32>(42).iter_mut() {} } ``` <details><summary><code>cargo build</code> diff</summary> ```diff diff --git a/old.out b/new.out index 84215aa..ca195a7 100644 --- a/old.out +++ b/new.out `@@` -1,33 +1,93 `@@` warning: for loop over an `Option`. This is more readably written as an `if let` statement --> src/main.rs:3:14 | 3 | for _ in Some(42) {} | ^^^^^^^^ | = note: `#[warn(for_loops_over_fallibles)]` on by default help: to check pattern in a loop use `while let` | 3 | while let Some(_) = Some(42) {} | ~~~~~~~~~~~~~~~ ~~~ help: consider using `if let` to clear intent | 3 | if let Some(_) = Some(42) {} | ~~~~~~~~~~~~ ~~~ warning: for loop over a `Result`. This is more readably written as an `if let` statement --> src/main.rs:4:14 | 4 | for _ in Ok::<_, i32>(42) {} | ^^^^^^^^^^^^^^^^ | help: to check pattern in a loop use `while let` | 4 | while let Ok(_) = Ok::<_, i32>(42) {} | ~~~~~~~~~~~~~ ~~~ help: consider using `if let` to clear intent | 4 | if let Ok(_) = Ok::<_, i32>(42) {} | ~~~~~~~~~~ ~~~ -warning: `for-loops-over-fallibles` (bin "for-loops-over-fallibles") generated 2 warnings - Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.04s +warning: for loop over a `&Option`. This is more readably written as an `if let` statement + --> src/main.rs:7:14 + | +7 | for _ in &Some(42) {} + | ^^^^^^^^^ + | +help: to check pattern in a loop use `while let` + | +7 | while let Some(_) = &Some(42) {} + | ~~~~~~~~~~~~~~~ ~~~ +help: consider using `if let` to clear intent + | +7 | if let Some(_) = &Some(42) {} + | ~~~~~~~~~~~~ ~~~ + +warning: for loop over a `&mut Option`. This is more readably written as an `if let` statement + --> src/main.rs:8:14 + | +8 | for _ in &mut Some(42) {} + | ^^^^^^^^^^^^^ + | +help: to check pattern in a loop use `while let` + | +8 | while let Some(_) = &mut Some(42) {} + | ~~~~~~~~~~~~~~~ ~~~ +help: consider using `if let` to clear intent + | +8 | if let Some(_) = &mut Some(42) {} + | ~~~~~~~~~~~~ ~~~ + +warning: for loop over a `&Result`. This is more readably written as an `if let` statement + --> src/main.rs:9:14 + | +9 | for _ in &Ok::<_, i32>(42) {} + | ^^^^^^^^^^^^^^^^^ + | +help: to check pattern in a loop use `while let` + | +9 | while let Ok(_) = &Ok::<_, i32>(42) {} + | ~~~~~~~~~~~~~ ~~~ +help: consider using `if let` to clear intent + | +9 | if let Ok(_) = &Ok::<_, i32>(42) {} + | ~~~~~~~~~~ ~~~ + +warning: for loop over a `&mut Result`. This is more readably written as an `if let` statement + --> src/main.rs:10:14 + | +10 | for _ in &mut Ok::<_, i32>(42) {} + | ^^^^^^^^^^^^^^^^^^^^^ + | +help: to check pattern in a loop use `while let` + | +10 | while let Ok(_) = &mut Ok::<_, i32>(42) {} + | ~~~~~~~~~~~~~ ~~~ +help: consider using `if let` to clear intent + | +10 | if let Ok(_) = &mut Ok::<_, i32>(42) {} + | ~~~~~~~~~~ ~~~ + +warning: `for-loops-over-fallibles` (bin "for-loops-over-fallibles") generated 6 warnings + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s ``` </details> ----- Question: * ~~Currently, the article `an` is used for `&Option`, and `&mut Option` in the lint diagnostic, since that's what `Option` uses. Is this okay or should it be changed? (likewise, `a` is used for `&Result` and `&mut Result`)~~ The article `a` is used for `&Option`, `&mut Option`, `&Result`, `&mut Result` and (as before) `Result`. Only `Option` uses `an` (as before). `@rustbot` label +A-lint
2024-05-18Fix typos (taking into account review comments)blyxyas-3/+3
2024-05-16Fix `for_loops_over_fallibles` hits in compiletest/src/json.rszachs18-2/+2
2024-05-11Make crashes dump mir to build dirMichael Goulet-8/+14
2024-05-09Tidy check for test revisions that are mentioned but not declaredZalathar-0/+2
If a `[revision]` name appears in a test header directive or error annotation, but isn't declared in the `//@ revisions:` header, that is almost always a mistake. In cases where a revision needs to be temporarily disabled, adding it to an `//@ unused-revision-names:` header will suppress these checks for that name. Adding the wildcard name `*` to the unused list will suppress these checks for the entire file.
2024-05-04compiletest: add enable-by-default check-cfgUrgau-3/+22
2024-05-04compiletest: add no-auto-check-cfg directiveUrgau-0/+7
this directive prevents compiletest from adding any implicit and automatic --check-cfg arguments
2024-05-02Rollup merge of #124138 - mati865:ignore-llvm-abi-in-dlltool-tests, r=davidtwcoMatthias Krüger-46/+24
Ignore LLVM ABI in dlltool tests since those targets don't use dlltool Otherwise those two tests fail when running `./x.py test` with this target.
2024-05-01Auto merge of #124491 - madsmtm:target_vendor-apple, r=workingjubileebors-2/+2
Use `target_vendor = "apple"` instead of `target_os = "..."` Use `target_vendor = "apple"` instead of `all(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos")`. The apple targets are quite close to being identical, with iOS, tvOS, watchOS and visionOS being even closer, so using `target_vendor` when possible makes it clearer when something is actually OS-specific, or just Apple-specific. Note that `target_vendor` will [be deprecated in the future](https://github.com/rust-lang/rust/issues/100343), but not before an alternative (like `target_family = "apple"`) is available. While doing this, I found various inconsistencies and small mistakes in the standard library, see the commits for details. Will follow-up with an extra PR for a similar issue that need a bit more discussion. EDIT: https://github.com/rust-lang/rust/pull/124494 Since you've talked about using `target_vendor = "apple"` in the past: r? workingjubilee CC `@simlay,` `@thomcc` `@rustbot` label O-macos O-ios O-tvos O-watchos O-visionos
2024-04-30Rollup merge of #124280 - beetrees:repr128-test-rmake, r=jieyouxu许杰友 Jieyou Xu (Joe)-0/+1
Port repr128-dwarf run-make test to rmake This PR ports the repr128-dwarf run-make test to rmake, using the `gimli` crate instead of the `llvm-dwarfdump` command. Note that this PR changes `rmake.rs` files to be compiled with the 2021 edition (previously no edition was passed to `rustc`, meaning they were compiled with the 2015 edition). This means that `panic!("{variable}")` will now work as expected in `rmake.rs` files (there's already a usage in the [wasm-symbols-not-exported test](https://github.com/rust-lang/rust/blob/aca749eefceaed0cda19a7ec5e472fce9387bc00/tests/run-make/wasm-symbols-not-exported/rmake.rs#L34) that this will fix). Tracking issue: #121876
2024-04-30Port repr128-dwarf run-make test to rmakebeetrees-0/+1
2024-04-29aux-bin: Avoid old .so files from old tests; clean auxiliary dir rootMartin Nordholts-0/+1
2024-04-28Also raise fd limit on tvOS when testingMads Marquart-2/+2
2024-04-27Remove lazycell and once_cell from compiletest dependenciesGeorge Bateman-104/+80
2024-04-24Skip dlltool tests on non `*windows-gnu` targetsMateusz Mikuła-0/+5
2024-04-24Refactor dlltool searching code into separate functionMateusz Mikuła-46/+19
2024-04-20Rollup merge of #124196 - RalfJung:mir-opt-tests, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-3/+3
mir-opt tests: rename unit-test -> test-mir-pass "unit-test" is extremely non-descriptive, no idea how one is supposed to read that and know that this specifies the MIR pass being tested.
2024-04-20mir-opt tests: rename unit-test -> test-mir-passRalf Jung-3/+3
2024-04-19Match hyphen in multi-revision comment matchersTrevor Gross-1/+16
Currently, the matcher `//[rev-foo,rev-bar]~` does not get selected by the regex. Change the matcher to also match strings that contain a `-`.h
2024-04-17Rollup merge of #123975 - lqd:rust-lld-tests, r=jieyouxuGuillaume Gomez-0/+1
Port the 2 `rust-lld` run-make tests to `rmake` In preparation for finalizing most of the `rust-lld` work, this PR ports the following tests to `rmake`: - `tests/run-make/rust-lld` - `tests/run-make/rust-lld-custom-target` As they use `$(CGREP) -e` I added `regex` as an exported dependency to the `run_make_support` library. Unfortunately, the most recent versions depend on `memchr` 2.6.0 but it's currently pinned at 2.5.0 in the workspace, and therefore had to settle for the older `regex-1.8.0`. r? `@jieyouxu`
2024-04-16Make ui_test backtraces short by defaultOli Scherer-1/+4
2024-04-16Unset test env vars before setting new ones.Oli Scherer-2/+2
If you want to override an env var, don't unset it, just set it
2024-04-15add missing lld directive to compiletestRémy Rakic-0/+1
2024-04-15Auto merge of #122997 - matthiaskrgr:compiletest_ices, r=oli-obkbors-7/+54
compiletest ice tracking see https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/where.20to.20mass-add.20known.20ices.20.2F.20merging.20glacier.20into.20rust/near/429082963 This will allow us to sunset most of https://github.com/rust-lang/glacier The rustc ices will be tracked directly inside the rust testsuite There are a couple of .sh tests remaining that I have not ported over yet. This adds `tests/crashes`, a file inside this directory MUST ice, otherwise it is considered test-fail. This will be used to track ICEs from glacier and the bugtracker. When someones pr accidentally fixes one of these ICEs, they can move the test from `crashes` into `ui` for example. I also added a new tidy lint that warns when a test inside `tests/crashes` does not have a `//@ known-bug: ` line the env var `COMPILETEST_VERBOSE_CRASHES` can be set to get exit code, stderr and stdout of a crash-test to aid debugging/adding tests.
2024-04-14update README and add COMPILETEST_VERBOSE_CRASHES env var which when set ↵Matthias Krüger-7/+12
print stdout, stderr and exit code of "crashes" tests, useful for debugging or adding new tests
2024-04-14crashes: fix ice detection which did not trigger if code compiled without ↵Matthias Krüger-8/+8
error by accident
2024-04-14compiletest: switch crash detection logic for run_crash_test aroundMatthias Krüger-5/+6
previously we would explicitly look for exit code 101 and call it a crash, however in case of stack overflows for example, exit code could differ due to the process being killed by a signal which is not easy to detect on none-unix. So now we reject everything that exits with 0 (no error) or 1 (compiler failed to compile code) and "accept" everyhing else as an internal compiler error.
2024-04-14run_crash_test(): better error message when we get a none-iceMatthias Krüger-1/+5
2024-04-14compiletest: crashes: turn off backtraces for faster testsMatthias Krüger-2/+13
2024-04-14tidy: add tidy check agains \.rs files inside tests/crashes that are missing ↵Matthias Krüger-1/+1
"//@ known-bug: "
2024-04-14add ignore-mode-crashes to the know list of compiletest directive namesMatthias Krüger-0/+1
2024-04-14bootstrap/compiletest: implement "crashes" tests that fail if no ice is ↵Matthias Krüger-6/+31
reproduced
2024-04-13Update rustfix to 0.8.1Eric Huss-1/+1
2024-04-12Auto merge of #121430 - madsmtm:mac-catalyst-iOSSupport, r=wesleywiserbors-0/+7
Add `/System/iOSSupport` to the library search path on Mac Catalyst On macOS, `/System/iOSSupport` contains iOS frameworks like UIKit, which is the whole idea of Mac Catalyst. To link to these, we need to explicitly tell the linker about the support library stubs provided in the macOS SDK under the same path. Concretely, when building a binary for Mac Catalyst, Xcode passes the following flags to the linker: ``` -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/iOSSupport/System/Library/Frameworks -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/iOSSupport/usr/lib ``` This is not something that can be disabled (it's enabled as soon as you enable `SUPPORTS_MACCATALYST`), so I think it's pretty safe to say that we don't need an option to turn these off. I've chosen to slightly deviate from what Xcode does and use `-F` instead of `-iframework`, since we don't need to change the header search path, and this way the flags nicely match on all the linkers. From what I could tell by reading Clang sources, there shouldn't be a difference when just running the linker. CC `@BlackHoleFox,` `@shepmaster` (I accidentally let rustbot choose the reviewer).
2024-04-12Rollup merge of #123763 - cuviper:host-rpath-run-make-v2, r=jieyouxuMatthias Krüger-12/+17
Set the host library path in run-make v2 When the build is configured with `[rust] rpath = false`, we need to set `LD_LIBRARY_PATH` (or equivalent) to what would have been the `RPATH`, so the compiler can find its own libraries. The old `tools.mk` code has this environment prefixed in the `$(BARE_RUSTC)` variable, so we just need to wire up something similar for run-make v2. This is now set while building each `rmake.rs` itself, as well as in the `rust-make-support` helpers for `rustc` and `rustdoc` commands. This is also available in a `set_host_rpath` function for manual commands, like in the `compiler-builtins` test.
2024-04-11Use `env::split_paths`/`join_paths` in runtestJosh Stone-16/+15
2024-04-10Set the host library path in run-make v2Josh Stone-0/+6
When the build is configured with `[rust] rpath = false`, we need to set `LD_LIBRARY_PATH` (or equivalent) to what would have been the `RPATH`, so the compiler can find its own libraries. The old `tools.mk` code has this environment prefixed in the `$(BARE_RUSTC)` variable, so we just need to wire up something similar for run-make v2. This is now set while building each `rmake.rs` itself, as well as in the `rust-make-support` helpers for `rustc` and `rustdoc` commands. This is also available in a `set_host_rpath` function for manual commands, like in the `compiler-builtins` test.
2024-04-11compiletest: error when finding a trailing directiveUrgau-5/+52
2024-04-10Add Apple platforms to compiletest KNOWN_DIRECTIVE_NAMESMads Marquart-0/+7
2024-04-10Rollup merge of #123612 - kxxt:riscv-target-abi, r=jieyouxu,nikic,DianQKMatthias Krüger-0/+1
Set target-abi module flag for RISC-V targets Fixes cross-language LTO on RISC-V targets (Fixes #121924)
2024-04-09Rollup merge of #123672 - davidtwco:compiletest-unset-log-color, r=clubby789Guillaume Gomez-1/+1
compiletest: unset `RUSTC_LOG_COLOR` If this leaks in from the environment then it can make tests fail when they deliberately trigger `WARN` or `ERROR` logging, currently this stops these tests from failing if you set `RUSTC_LOG_COLOR=always` in the parent environment: - `tests/ui/coherence/occurs-check/associated-type.rs#next` - `tests/ui/coherence/occurs-check/associated-type.rs#old` - `tests/ui/higher-ranked/structually-relate-aliases.rs` - `tests/ui/self/arbitrary-self-from-method-substs.rs#default` - `tests/ui/traits/next-solver/issue-118950-root-region.rs`
2024-04-09Rollup merge of #123626 - Zalathar:test-tools-mcdc, r=oli-obkGuillaume Gomez-52/+61
Add MC/DC support to coverage test tools Extracted and squashed from #123409 by `@ZhuUx.` These updates to the coverage test tools can land ahead of the main changes, slightly reducing the size and complexity of that PR. --- The `coverage-dump` changes aren't directly tested in this PR, but the tests in #123409 demonstrate that they do work on real MC/DC coverage output. `@rustbot` label +A-code-coverage
2024-04-09compiletest: unset `RUSTC_LOG_COLOR`David Wood-1/+1
If this leaks in from the environment then it can make tests fail when they deliberately trigger `WARN` or `ERROR` logging. Signed-off-by: David Wood <david@davidtw.co>
2024-04-09Convert tests/run-make/cross-lang-lto-riscv-abi to rmakekxxt-0/+1
2024-04-08Fix UI tests with dist-vendored dependenciesJosh Stone-0/+5
There is already a workaround in `compiletest` to deal with custom `CARGO_HOME` using `-Zignore-directory-in-diagnostics-source-blocks={}`. A similar need exists when dependencies come from the local `vendor` directory, which distro builds often use, so now we ignore that too. Also, `issue-21763.rs` was normalizing `hashbrown-` paths, presumably expecting a version suffix, but the vendored path doesn't include the version. Now that matches `[\\/]hashbrown` instead.
2024-04-08Replace branch coverage line anonymization test with MC/DCZalathar-52/+48
We don't need the branch coverage version of this test, but we can recycle is to make sure that the MC/DC coverage support works as expected.