about summary refs log tree commit diff
path: root/src/tools/compiletest
AgeCommit message (Collapse)AuthorLines
2022-11-04Auto merge of #103298 - ferrocene:pa-compile-flags-last, r=jyn514bors-39/+71
Ensure that compile-flags arguments are the last in UI tests Before this PR, compiletest would add `-L path/to/aux` at the end of the rustc flags, even after the custom ones set with the compile-flags header comment. This made it impossible to check how rustc would behave when a flag requiring an argument was passed without the argument, because the argument would become `-L`. This PR fixes that by adding the `-L path/to/aux` before the arguments defined in compile-flags, at least for UI tests. Other test suites might either be fixed as well by this change, or still present the old behavior (`-L` is now always passed before, but other tests suites might add additional flags after the custom ones).
2022-11-03put custom flags as last in codegen and asm testsPietro Albini-33/+41
2022-11-01Rollup merge of #103781 - JakobDegen:mir-opt-tidy, r=jyn514Manish Goregaokar-92/+39
Detect unused files in `src/test/mir-opt` and error on them in tidy. Closes #97564 . Determining which files are generated by a given mir opt test is somewhat difficult. Because of this, we extract the logic for doing it out into a common crate that both compiletest and tidy can depend on. This avoids making compiletest a dependency of tidy which would negatively impact compile times for tidy. Testing for this is that it catches 5 files that violated this lint (and removes them).
2022-10-31Detect unused files in `src/test/mir-opt` and error on them in tidy.Jakob Degen-92/+39
2022-10-29compiletest: set the dylib path when gathering target cfgJosh Stone-33/+37
If the compiler is built with `rpath = false`, then it won't find its own libraries unless the library search path is set. We already do that while running the actual compiletests, but #100260 added another rustc command for getting the target cfg. Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu) thread 'main' panicked at 'error: failed to get cfg info from "[...]/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" --- stdout --- stderr [...]/build/x86_64-unknown-linux-gnu/stage1/bin/rustc: error while loading shared libraries: librustc_driver-a2a76dc626cd02d2.so: cannot open shared object file: No such file or directory ', src/tools/compiletest/src/common.rs:476:13 Now the library path is set here as well, so it works without rpath.
2022-10-29Rollup merge of #102634 - andrewpollack:refactor-test-rustcflags, ↵Guillaume Gomez-36/+15
r=Mark-Simulacrum compiletest: Refactor test rustcflags Refactoring `host-rustcflags` and `target-rustcflags` from `Option<String>` to `Vec<String>` Ref: #102438 r? `@Mark-Simulacrum`
2022-10-25ensure that compile-flags arguments are the last in ui testsPietro Albini-18/+42
Before this commit, compiletest would add `-L path/to/aux` at the end of the rustc flags, even after the custom ones set with the compile-flags header comment. This made it impossible to check how rustc would behave when a flag requiring an argument was passed without the argument, because the argument would become `-L`. This PR fixes that by adding the `-L path/to/aux` before the arguments defined in compile-flags, at least for UI tests. Other test suites might either be fixed as well by this change, or still present the old behavior.
2022-10-24Update src/tools/compiletest/src/runtest.rsAndrew Pollack-1/+1
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
2022-10-24Rollup merge of #99939 - saethlin:pre-sort-tests, r=thomcc,jackh726Yuki Okushi-0/+2
Sort tests at compile time, not at startup Recently, another Miri user was trying to run `cargo miri test` on the crate `iced-x86` with `--features=code_asm,mvex`. This configuration has a startup time of ~18 minutes. That's ~18 minutes before any tests even start to run. The fact that this crate has over 26,000 tests and Miri is slow makes a lot of code which is otherwise a bit sloppy but fine into a huge runtime issue. Sorting the tests when the test harness is created instead of at startup time knocks just under 4 minutes out of those ~18 minutes. I have ways to remove most of the rest of the startup time, but this change requires coordinating changes of both the compiler and libtest, so I'm sending it separately. (except for doctests, because there is no compile-time harness)
2022-10-19compiletest: refactor rustcflags to VecAndrew Pollack-36/+15
2022-10-18Retrieve LLVM version from llvm-filecheck binary if it is not set yetGuillaume Gomez-1/+18
2022-10-05Auto merge of #102438 - andrewpollack:add-target-rustc-flags, r=Mark-Simulacrumbors-2/+4
Adding target_rustcflags to `compiletest` TargetCfg creation Adjustment to https://github.com/rust-lang/rust/pull/102134, ensures config returned by `rustc --target foo --print cfg` accurately reflects rustflags passed via `target_rustcflags`. Fixes breaking change of not correctly handling `x.py test ... --test-args "--target-rustcflags -Cpanic=abort --target-rustcflags -Zpanic_abort_tests"` cc `@djkoloski`
2022-10-02Rollup merge of #100451 - hovinen:no-panic-on-result-err-in-test, ↵Dylan DPC-1/+4
r=Mark-Simulacrum Do not panic when a test function returns Result::Err. Rust's test library allows test functions to return a `Result`, so that the test is deemed to have failed if the function returns a `Result::Err` variant. Currently, this works by having `Result` implement the `Termination` trait and asserting in assert_test_result that `Termination::report()` indicates successful completion. This turns a `Result::Err` into a panic, which is caught and unwound in the test library. This approach is problematic in certain environments where one wishes to save on both binary size and compute resources when running tests by: * Compiling all code with `--panic=abort` to avoid having to generate unwinding tables, and * Running most tests in-process to avoid the overhead of spawning new processes. This change removes the intermediate panic step and passes a `Result::Err` directly through to the test runner. To do this, it modifies `assert_test_result` to return a `Result<(), String>` where the `Err` variant holds what was previously the panic message. It changes the types in the `TestFn` enum to return `Result<(), String>`. This tries to minimise the changes to benchmark tests, so it calls `unwrap()` on the `Result` returned by `assert_test_result`, effectively keeping the same behaviour as before. Some questions for reviewers: * Does the change to the return types in the enum `TestFn` constitute a breaking change for the library API? Namely, the enum definition is public but the test library indicates that "Currently, not much of this is meant for users" and most of the library API appears to be marked unstable. * Is there a way to test this change, i.e., to test that no panic occurs if a test returns `Result::Err`? * Is there a shorter, more idiomatic way to fold `Result<Result<T,E>,E>` into a `Result<T,E>` than the `fold_err` function I added?
2022-09-28Adding target_rustcflags to TargetCfgAndrew Pollack-2/+4
2022-09-23Detect panic strategy using `rustc --print cfg`Florian Bartels-16/+17
Instead of relying on a command line parameter, detect if a target is able to unwind or not. Ignore tests that require unwinding on targets that don't support it.
2022-09-20Update rustc's information on Android's sanitizersChris Wailes-0/+6
This patch updates sanitizier support definitions for Android inside the compiler. It also adjusts the logic to make sure no pre-built sanitizer runtime libraries are emitted as these are instead provided dynamically on Android targets.
2022-09-16Do not panic when a test function returns Result::Err.Bradford Hovinen-1/+4
Rust's test library allows test functions to return a Result, so that the test is deemed to have failed if the function returns a Result::Err variant. Currently, this works by having Result implement the Termination trait and asserting in assert_test_result that Termination::report() indicates successful completion. This turns a Result::Err into a panic, which is caught and unwound in the test library. This approach is problematic in certain environments where one wishes to save on both binary size and compute resources when running tests by: * Compiling all code with --panic=abort to avoid having to generate unwinding tables, and * Running most tests in-process to avoid the overhead of spawning new processes. This change removes the intermediate panic step and passes a Result::Err directly through to the test runner. To do this, it modifies assert_test_result to return a Result<(), String> where the Err variant holds what was previously the panic message. It changes the types in the TestFn enum to return Result<(), String>. This tries to minimise the changes to benchmark tests, so it calls unwrap() on the Result returned by assert_test_result, effectively keeping the same behaviour as before.
2022-09-14Remove check_missing_items.pyNixon Enraght-Moony-9/+0
2022-09-14jsondoclint: New ToolNixon Enraght-Moony-0/+13
2022-09-11Avoid `Iterator::last`KaDiWa-1/+1
2022-09-07fix compiletest detection of needs-rust-lld testsRémy Rakic-3/+15
for both windows and unixes
2022-09-01Sort tests at compile time, not at startupBen Kimock-0/+2
Recently, another Miri user was trying to run `cargo miri test` on the crate `iced-x86` with `--features=code_asm,mvex`. This configuration has a startup time of ~18 minutes. That's ~18 minutes before any tests even start to run. The fact that this crate has over 26,000 tests and Miri is slow makes a lot of code which is otherwise a bit sloppy but fine into a huge runtime issue. Sorting the tests when the test harness is created instead of at startup time knocks just under 4 minutes out of those ~18 minutes. I have ways to remove most of the rest of the startup time, but this change requires coordinating changes of both the compiler and libtest, so I'm sending it separately.
2022-08-28Auto merge of #100497 - kadiwa4:remove_clone_into_iter, r=cjgillotbors-1/+1
Avoid cloning a collection only to iterate over it `@rustbot` label: +C-cleanup
2022-08-28Rollup merge of #98301 - ortem:pretty-printers-nonzero, r=wesleywiserMatthias Krüger-0/+1
Add GDB/LLDB pretty-printers for NonZero types Add GDB/LLDB pretty-printers for `NonZero` types. These pretty-printers were originally implemented for IntelliJ Rust by ```@Kobzol``` in https://github.com/intellij-rust/intellij-rust/pull/5270. Part of #29392.
2022-08-26Auto merge of #98051 - davidtwco:split-dwarf-stabilization, r=wesleywiserbors-2/+5
session: stabilize split debuginfo on linux Stabilize the `-Csplit-debuginfo` flag... - ...on Linux for all values of the flag. Split DWARF has been implemented for a few months, hasn't had any bug reports and has had some promising benchmarking for incremental debug build performance. - ..on other platforms for the default value. It doesn't make any sense that `-Csplit-debuginfo=packed` is unstable on Windows MSVC when that's the default behaviour, but keep the other values unstable.
2022-08-24Add GDB/LLDB pretty-printers for NonZero typesArtem Mukhin-0/+1
2022-08-18session: stabilize split debuginfo on linuxDavid Wood-2/+5
Stabilize the `-Csplit-debuginfo` flag... - ...on Linux for all values of the flag. Split DWARF has been implemented for a few months, hasn't had any bug reports and has had some promising benchmarking for incremental debug build performance. - ..on other platforms for the default value. It doesn't make any sense that `-Csplit-debuginfo=packed` is unstable on Windows MSVC when that's the default behaviour, but keep the other values unstable. Signed-off-by: David Wood <david.wood@huawei.com>
2022-08-16compiletest: fix typo in runtest.rsIkko Ashimine-1/+1
nonexistant -> nonexistent
2022-08-13avoid cloning and then iteratingKaDiWa-1/+1
2022-08-12[compiletest] Add compiler-bundled NatVis files to test input stamp.Michael Woerister-0/+2
2022-08-08compiletest: Add warning and comment about running tests without RUSTCEric Huss-1/+16
2022-08-07compiletest: match ignores on target familyEric Huss-0/+29
This primarily is so that `ignore-wasm` works as expected (ignores all wasm-like targets).
2022-08-07compiletest: use precise cfg matching instead of hard-coded tablesEric Huss-208/+301
2022-07-28Use line numbers relative to function in mir opt testsNilstrieb-0/+1
This adds a new option, `-Zmir-pretty-relative-line-numbers`, that is then used in compiletest for the mir-opt tests.
2022-07-24Auto merge of #95548 - rcvalle:rust-cfi-2, r=nagisabors-0/+19
Add fine-grained LLVM CFI support to the Rust compiler This PR improves the LLVM Control Flow Integrity (CFI) support in the Rust compiler by providing forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue https://github.com/rust-lang/rust/issues/89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto). Thank you again, `@eddyb,` `@nagisa,` `@pcc,` and `@tmiasko` for all the help!
2022-07-23Auto merge of #98208 - ivanloz:master, r=nagisabors-0/+5
Add support for LLVM ShadowCallStack. LLVMs ShadowCallStack provides backward edge control flow integrity protection by using a separate shadow stack to store and retrieve a function's return address. LLVM currently only supports this for AArch64 targets. The x18 register is used to hold the pointer to the shadow stack, and therefore this only works on ABIs which reserve x18. Further details are available in the [LLVM ShadowCallStack](https://clang.llvm.org/docs/ShadowCallStack.html) docs. # Usage `-Zsanitizer=shadow-call-stack` # Comments/Caveats * Currently only enabled for the aarch64-linux-android target * Requires the platform to define a runtime to initialize the shadow stack, see the [LLVM docs](https://clang.llvm.org/docs/ShadowCallStack.html) for more detail.
2022-07-23Add fine-grained LLVM CFI support to the Rust compilerRamon de C Valle-0/+19
This commit improves the LLVM Control Flow Integrity (CFI) support in the Rust compiler by providing forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue #89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).
2022-07-20Add ShadowCallStack SupportIvan Lozano-0/+5
Adds support for the LLVM ShadowCallStack sanitizer.
2022-07-20compiletest: dedup revision line logic.Luqman Aden-31/+27
2022-07-20compiletest: allow using revisions with debuginfo testsLuqman Aden-13/+47
2022-07-12Add regex-error-pattern flag in compiletestGuillaume Gomez-19/+66
2022-07-11compiletest: trim edition before passing as flagDeadbeef-1/+1
This makes `edition: 2021` work instead of the ugly `edition:2021` one has to write.
2022-07-04Auto merge of #98817 - the8472:dont-optimize-ui-tests, r=Mark-Simulacrumbors-0/+32
Only obey optimize-tests flag on UI tests that are run-pass stage1 UI tests walltime on my machine: ``` optimize-tests = false, master 25.98s optimize-tests = true, master 34.69s optimize-tests = true, patched 28.79s ``` Effects: - faster UI tests - llvm asserts get exercised less on build-pass tests - the difference between opt and nopt builds shrinks a bit - aux libs don't get optimized since they don't have a pass mode and almost never have explicit compile flags
2022-07-02move optimize-tests flag handling from bootstrap to compiletestThe 8472-16/+28
2022-07-02Only obey optimize-tests flag on UI tests that are run-passThe 8472-0/+20
``` optimize-tests = false, master 25.98s optimize-tests = true, master 34.69s optimize-tests = true, patched 28.79s ``` Effects: - faster UI tests - llvm asserts get exercised less on build-pass tests - the difference between opt and nopt builds shrinks a bit - aux libs don't get optimized since they don't have a pass mode and almost never have explicit compile flags
2022-07-02Fix bug in `rustdoc -Whelp`Joshua Nelson-2/+4
Previously, this printed the debugging options, not the lint options, and only handled `-Whelp`, not `-A/-D/-F`. This also fixes a few other misc issues: - Fix `// check-stdout` for UI tests; previously it only worked for run-fail and compile-fail tests - Add lint headers for tool lints, not just builtin lints - Remove duplicate run-make test
2022-06-28Rollup merge of #98564 - jyn514:remove-tmp-dir, r=Mark-SimulacrumMatthias Krüger-5/+0
Remove references to `./tmp` in-tree These used to be used by codegen-units tests, but were switched from manually specifying directories to just using `// incremental` in https://github.com/rust-lang/rust/pull/89101. Remove the old references. Fixes https://github.com/rust-lang/rust/issues/34586.
2022-06-26Remove references to `./tmp` in-treeJoshua Nelson-5/+0
These used to be used by codegen-units tests, but were switched from manually specifying directories to just using `// incremental` in https://github.com/rust-lang/rust/pull/89101. Remove the old references.
2022-06-26compiletest: add issue number param to `known-bug`David Knaack-1/+23
2022-06-22use `-Cstrip=debuginfo` with ui tests to reduce disk space usageklensy-0/+2