about summary refs log tree commit diff
path: root/src/tools/compiletest
AgeCommit message (Collapse)AuthorLines
2023-07-13Auto merge of #113637 - Mark-Simulacrum:bootstrap-bump, r=ozkanonurbors-1/+4
Bump bootstrap to 1.72 beta
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-1/+4
2023-07-11Support build-pass in codegen testsJubilee Young-12/+13
2023-07-09Auto merge of #113306 - tgross35:debuginfo-better-output, r=Mark-Simulacrumbors-108/+131
Update debuginfo test runner to provide more useful output This change makes debuginfo tests more user friendly. Changes: - Print all lines that fail to match the patterns instead of just the first - Provide better error messages that also say what did match - Strip leading whitespace from directives so they are not skipped if indented - Improve documentation and improve nesting on some related items As an example, given the following intentional fail (and a few not shown): ```rust // from tests/debuginfo/rc_arc.rs // cdb-command:dx rc,d // cdb-check:rc,d : 111 [Type: alloc::rc::Rc<i32>] // cdb-check: [Reference count] : 11 [Type: core::cell FAIL::Cell<usize>] // cdb-check: [Weak reference count] : 2 [Type: core::cell FAIL::Cell<usize>] ``` The current output (tested in #113313) will show: ``` 2023-07-04T08:10:00.1939267Z ---- [debuginfo-cdb] tests\debuginfo\rc_arc.rs stdout ---- 2023-07-04T08:10:00.1942182Z 2023-07-04T08:10:00.1957463Z error: line not found in debugger output: [Reference count] : 11 [Type: core:: cell FAIL::Cell<usize>] 2023-07-04T08:10:00.1958272Z status: exit code: 0 ``` With this chane, you are able to see all failures in that check group, as well as what parts were successful. The output is now: ``` 2023-07-04T09:45:57.2514224Z error: check directive(s) from `C:\a\rust\rust\tests\debuginfo\rc_arc.rs` not found in debugger output. errors: 2023-07-04T09:45:57.2514631Z (rc_arc.rs:31) ` [Reference count] : 11 [Type: core::cell FAIL::Cell<usize>]` 2023-07-04T09:45:57.2514908Z (rc_arc.rs:32) ` [Weak reference count] : 2 [Type: core::cell FAIL::Cell<usize>]` 2023-07-04T09:45:57.2515181Z (rc_arc.rs:41) ` [Reference count] : 21 [Type: core::sync::atomic FAIL::AtomicUsize]` 2023-07-04T09:45:57.2515452Z (rc_arc.rs:50) `dyn_rc,d [Type: alloc::rc::Rc<dyn$<core::fmt FAIL::Debug> >]` 2023-07-04T09:45:57.2515695Z the following subset of check directive(s) was found successfully:: 2023-07-04T09:45:57.2516080Z (rc_arc.rs:30) `rc,d : 111 [Type: alloc::rc::Rc<i32>]` 2023-07-04T09:45:57.2516312Z (rc_arc.rs:35) `weak_rc,d : 111 [Type: alloc::rc::Weak<i32>]` 2023-07-04T09:45:57.2516555Z (rc_arc.rs:36) ` [Reference count] : 11 [Type: core::cell::Cell<usize>]` 2023-07-04T09:45:57.2516881Z (rc_arc.rs:37) ` [Weak reference count] : 2 [Type: core::cell::Cell<usize>]` ... ``` Which makes it easier to see what did and didn't succeed without manual comparison against the source test file.
2023-07-06Rollup merge of #113246 - mirkootter:fix-compiletest-crash, r=pietroalbiniMatthias Krüger-1/+1
fix compiletest crash ### Motivation When running compiler-tests locally for the `wasm32` platform, one test repeatedly crashed. It does not crash on the CI, only locally. Investigation shows that the `compiletest` itself crashes > panicked-at-attempt-to-subtract-with-overflow ```rust let mut head = replace(bytes, Vec::new()); let mut middle = head.split_off(HEAD_LEN); // The following line will panic let tail = middle.split_off(middle.len() - TAIL_LEN).into_boxed_slice(); let skipped = new_len - HEAD_LEN - TAIL_LEN; ``` ### Background The code in question collects the output of a process. Small output is kept completely, but larger output is kept only partially: the first 160 kB and the last 256 kB. The code that performs this split crashes if the data size is less than 416 kB. There is an early out based on the "filtered" length, but it is possible that the filtered length is greater than the real length. It seems that this code was written with the assumption that the filtered length is larger than the real length, which is not true in general. When running CI tests locally using `src/ci/docker/run.sh`, the filtered folder is `/checkout`, which is shorter than the placeholder length of 32 bytes. ### Note This PR should not change any behaviour. It only adds an early our for a case which will definitely crash (at least if compiletest is build with integer checks). Note that an early out makes sense here: If the real data is too small, it does not sense to split it.
2023-07-06Rollup merge of #112295 - ↵Matthias Krüger-1/+4
ForrestOfBarnes:tests-listing-format-json-windows-fix, r=pietroalbini Fix the tests-listing-format-json test on Windows tests/ui/test-attrs/tests-listing-json-format.rs was failing on Windows because each path in the json-formatted output contained "\\\\" instead of "\\". `runtest::TestCx::normalize_output` already checks the compile flags for json-related arguments to handle this case, so I added an equivalent check for the new run flag.
2023-07-04Update debuginfo test runner to provide more useful outputTrevor Gross-108/+131
This change makes debuginfo tests more user friendly. Changes: - Print all lines that fail to match the patterns instead of just the first - Provide better error messages that also say what did match - Strip leading whitespace from directives so they are not skipped if indented - Improve documentation and improve nesting on some related items As an example, given the following debuginfo test with intentional fails: ```rust // from tests/debuginfo/rc_arc.rs // cdb-command:dx rc,d // cdb-check:rc,d : 111 [Type: alloc::rc::Rc<i32>] // cdb-check: [Reference count] : 11 [Type: core::cell FAIL::Cell<usize>] // cdb-check: [Weak reference count] : 2 [Type: core::cell FAIL::Cell<usize>] // ... ``` The current output (tested in #113313) only shows the first mismatch: ``` 2023-07-04T08:10:00.1939267Z ---- [debuginfo-cdb] tests\debuginfo\rc_arc.rs stdout ---- 2023-07-04T08:10:00.1942182Z 2023-07-04T08:10:00.1957463Z error: line not found in debugger output: [Reference count] : 11 [Type: core::cell FAIL::Cell<usize>] 2023-07-04T08:10:00.1958272Z status: exit code: 0 ``` With this change, you are able to see all failures in that check group, as well as what parts were successful. The output is now: ``` 2023-07-04T09:45:57.2514224Z error: check directive(s) from `C:\a\rust\rust\tests\debuginfo\rc_arc.rs` not found in debugger output. errors: 2023-07-04T09:45:57.2514631Z (rc_arc.rs:31) ` [Reference count] : 11 [Type: core::cell FAIL::Cell<usize>]` 2023-07-04T09:45:57.2514908Z (rc_arc.rs:32) ` [Weak reference count] : 2 [Type: core::cell FAIL::Cell<usize>]` 2023-07-04T09:45:57.2515181Z (rc_arc.rs:41) ` [Reference count] : 21 [Type: core::sync::atomic FAIL::AtomicUsize]` 2023-07-04T09:45:57.2515452Z (rc_arc.rs:50) `dyn_rc,d [Type: alloc::rc::Rc<dyn$<core::fmt FAIL::Debug> >]` 2023-07-04T09:45:57.2515695Z the following subset of check directive(s) was found successfully:: 2023-07-04T09:45:57.2516080Z (rc_arc.rs:30) `rc,d : 111 [Type: alloc::rc::Rc<i32>]` 2023-07-04T09:45:57.2516312Z (rc_arc.rs:35) `weak_rc,d : 111 [Type: alloc::rc::Weak<i32>]` 2023-07-04T09:45:57.2516555Z (rc_arc.rs:36) ` [Reference count] : 11 [Type: core::cell::Cell<usize>]` 2023-07-04T09:45:57.2516881Z (rc_arc.rs:37) ` [Weak reference count] : 2 [Type: core::cell::Cell<usize>]` ... ``` Which makes it easier to see what did and didn't succeed without manual comparison against the source test file.
2023-07-03Remove compare modeMichael Goulet-4/+0
2023-07-01fix compiletest crashJan-Mirko Otter-1/+1
2023-07-01Rollup merge of #113189 - Zalathar:trim-end, r=ozkanonurMatthias Krüger-1/+1
compiletest: Only trim the end of process output As of #94196, compiletest automatically trims process stderr/stdout output before printing it, to make failure info more compact. This causes the first line of `run-coverage` output to be displayed incorrectly, because it uses leading whitespace to align line numbers. Trimming only the end of the output string should still have the intended effect (e.g. removing trailing newlines), without causing problems for output that deliberately uses leading whitespace on the first line. ## Before ``` --- stdout ------------------------------- 1| 1|fn main() { // 2| 1| let num = 9; 3| 1| while num >= 10 { 4| 0| } 5| 1|} ------------------------------------------ stderr: none ``` ## After ``` --- stdout ------------------------------- 1| 1|fn main() { // 2| 1| let num = 9; 3| 1| while num >= 10 { 4| 0| } 5| 1|} ------------------------------------------ stderr: none ```
2023-06-30fix loading target specs in compiletest not working with custom targetsPietro Albini-1/+13
2023-06-30compiletest: Only trim the end of process outputZalathar-1/+1
2023-06-28Remove the old `coverage-reports` and `coverage` directoriesZalathar-1/+1
2023-06-28Re-bless the newly-migrated testsZalathar-12/+0
2023-06-28Migrate the remaining `run-make/coverage-reports` tests over to `run-coverage`Zalathar-0/+12
To make it easier to verify that the output snapshots have been migrated faithfully, this change adds some temporary helper code that lets us avoid having to completely re-bless the existing snapshots. A later change in this PR will then re-bless the tests and remove the temporary helper code.
2023-06-28Expand `run-coverage` to support the remaining `coverage-reports` testsZalathar-3/+115
2023-06-28Add a custom `run-coverage` mode to compiletestZalathar-3/+232
2023-06-28Move the `RUSTC_PROFILER_SUPPORT` check into `CachedNeedsConditions`Zalathar-1/+3
2023-06-28Remember whether `failure-status` was explicitly specifiedZalathar-8/+5
Currently a test without a `failure-status` directive is treated as having an expected failure-status of 1, but `run-coverage` tests will want to treat those tests as expecting success instead.
2023-06-28Introduce `exec_compiled_test_general`Zalathar-1/+12
This will allow the `run-coverage` mode to easily set environment variable `LLVM_PROFILE_FILE`, and to prevent the executable from being deleted after a successful run.
2023-06-28Extract a common function for setting up environment varsZalathar-13/+12
2023-06-20add support for needs-dynamic-linkingPietro Albini-0/+5
2023-06-20avoid dynamic linking on targets that do not support dynamic linkingPietro Albini-1/+3
2023-06-20merge target spec and --print=cfg for compiletest target infoPietro Albini-64/+24
2023-06-18Fixes tests/ui/test-attrs/tests-listing-format-json.rs on WindowsForrestOfBarnes-1/+4
2023-06-17Rollup merge of #112435 - antoyo:allow-overwrite-sysroot, r=Mark-SimulacrumMatthias Krüger-1/+3
Allow overwriting the sysroot compile flag via --rustc-args Hi. As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/How.20to.20overwrite.20sysroot.20in.20x.2Epy.20test/near/364272269), this is a solution to allow the codegens to overwrite the sysroot as part of their test suite. Thanks for the review.
2023-06-15Remove comments from mir-opt MIR dumpsBen Kimock-1/+0
2023-06-12add way to split mir-opt into panic=abort and panic=unwindPietro Albini-9/+19
2023-06-08Allow overwriting the sysroot compile flag via --rustc-argsAntoni Boucher-1/+3
2023-06-06Make TraitEngine::new use the right solver, add compare modeMichael Goulet-0/+4
2023-05-31Rollup merge of #111975 - jyn514:normalization, r=cjgillotMatthias Krüger-29/+18
Stop normalizing so many different prefixes Previously, we would normalize *all* of - the absolute path to the repository checkout - the /rustc/$sha for stage1 (if `remap-debuginfo` was enabled) - the /rustc/$sha for download-rustc - the sysroot for download-rustc Now, we consistently only normalize /rustc/FAKE_PREFIX. Not only is this much simpler, but it also avoids ongoing maintenance for download-rustc and makes it much less likely that tests break by accident. - Change `tests/ui/track-diagnostics/track6.rs` to use a relative path instead of an absolute one. I am not actually sure why `track_caller` works here, but it does seem to work :shrug: - Pass `-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX` to all suites, not just UI. In particular, mir-opt tests emit /rustc/ paths in their output. r? ```@cjgillot``` since you reviewed https://github.com/rust-lang/rust/pull/110699 - this is the test that it doesn't regress :)
2023-05-28Auto merge of #111813 - scottmcm:pretty-mir, r=cjgillotbors-1/+4
MIR: opt-in normalization of `BasicBlock` and `Local` numbering This doesn't matter at all for actual codegen, but after spending some time reading pre-codegen MIR, I was wishing I didn't have to jump around so much in reading post-inlining code. So this add two passes that are off by default for every mir level, but can be enabled (`-Zmir-enable-passes=+ReorderBasicBlocks,+ReorderLocals`) for humans.
2023-05-28Auto merge of #112000 - wesleywiser:safestack, r=Amanieubors-0/+9
Add support for LLVM SafeStack Adds support for LLVM [SafeStack] which provides backward edge control flow protection by separating the stack into two parts: data which is only accessed in provable safe ways is allocated on the normal stack (the "safe stack") and all other data is placed in a separate allocation (the "unsafe stack"). SafeStack support is enabled by passing `-Zsanitizer=safestack`. [SafeStack]: https://clang.llvm.org/docs/SafeStack.html cc `@rcvalle` #39699
2023-05-27Auto merge of #111348 - ozkanonur:remove-hardcoded-rustdoc-flags, ↵bors-1136/+1148
r=albertlarsan68,oli-obk new tool `rustdoc-gui-test` Implements new tool `rustdoc-gui-test` that allows using compiletest headers for `rustdoc-gui` tests.
2023-05-26Add SafeStack support to rustcWesley Wiser-0/+9
Adds support for LLVM [SafeStack] which provides backward edge control flow protection by separating the stack into two parts: data which is only accessed in provable safe ways is allocated on the normal stack (the "safe stack") and all other data is placed in a separate allocation (the "unsafe stack"). SafeStack support is enabled by passing `-Zsanitizer=safestack`. [SafeStack]: https://clang.llvm.org/docs/SafeStack.html
2023-05-26Stop normalizing so many different prefixesjyn-29/+18
Previously, we would normalize *all* of - the absolute path to the repository checkout - the /rustc/$sha for stage1 (if `remap-debuginfo` was enabled) - the /rustc/$sha for download-rustc - the sysroot for download-rustc Now, we consistently only normalize /rustc/FAKE_PREFIX. Not only is this much simpler, but it also avoids ongoing maintenance for download-rustc and makes it much less likely that tests break by accident. - Change `tests/ui/track-diagnostics/track6.rs` to use a relative path instead of an absolute one. I am not actually sure why `track_caller` works here, but it does seem to work :shrug: - Pass `-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX` to all suites, not just UI. In particular, mir-opt tests emit /rustc/ paths in their output.
2023-05-21Normalize block and local orders in mir-opt testsScott McMurray-1/+4
Since this only affects `PreCodegen MIR, and it would be nice for that to be resilient to permutations of things that don't affect the actual semantic behaviours.
2023-05-20derive `Default` trait for `compiletest::common::Config`ozkanonur-1/+7
2023-05-18Rollup merge of #111561 - dtolnay:compiletestdirexists, r=Mark-SimulacrumDylan DPC-1/+7
Include better context for "already exists" error in compiletest I encountered the following error from `x.py test tests/ui` today. ```console ---- [ui] tests/ui/impl-trait/multiple-lifetimes/multiple-lifetimes.rs stdout ---- thread '[ui] tests/ui/impl-trait/multiple-lifetimes/multiple-lifetimes.rs' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 17, kind: AlreadyExists, message: "File exists" }', src/tools/compiletest/src/runtest.rs:134:43 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` I found it impossible to unblock myself without knowing which directory it was stuck on. Error message after this PR: ```console ---- [ui] tests/ui/impl-trait/multiple-lifetimes/multiple-lifetimes.rs stdout ---- thread '[ui] tests/ui/impl-trait/multiple-lifetimes/multiple-lifetimes.rs' panicked at 'called `Result::unwrap()` on an `Err` value: failed to create output base directory /git/rust/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/multiple-lifetimes/multiple-lifetimes Caused by: File exists (os error 17)', src/tools/compiletest/src/runtest.rs:139:10 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` Now I was able to run `rm build/x86_64-unknown-linux-gnu/test/ui/impl-trait/multiple-lifetimes/multiple-lifetimes` and unblock myself. Seems to be related to #109509 moving *tests/ui/impl-trait/multiple-lifetimes.rs* to *tests/ui/impl-trait/multiple-lifetimes/multiple-lifetimes.rs*.
2023-05-16add lib module to `src/tool/compiletest`ozkanonur-1135/+1141
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-05-16Auto merge of #111472 - djkoloski:compiletest_cfg_current_target, ↵bors-5/+84
r=compiler-errors Get current target config from` --print=cfg` Compiletest was switched to querying all targets using `--print=all-target-specs-json` and `--print=target-spec-json` in #108905. This unintentionally prevented codegen flags like `-Cpanic` from being reflected in the current target configuration. This change gets the current compiletest target config using `--print=cfg` like it was previously while still using the faster prints for getting information on all other targets. Fixes #110850. `@jyn514` might be interested in reviewing since they commented on the issue. cc `@tmandry` since this issue is affecting Fuchsia.
2023-05-14Include better context for "already exists" error in compiletestDavid Tolnay-1/+7
2023-05-11Get current target config from` --print=cfg`David Koloski-5/+84
Compiletest was switched to querying all targets using `--print=all-target-specs-json` and `--print=target-spec-json` in #108905. This unintentionally prevented codegen flags like `-Cpanic` from being reflected in the current target configuration. This change gets the current compiletest target config using `--print=cfg` like it was previously while still using the faster prints for getting information on all other targets. Fixes #110850.
2023-05-09bump windows crate 0.46 -> 0.48 in workspaceklensy-1/+1
2023-05-06Rollup merge of #111251 - mj10021:issue-109502-follow-up, r=oli-obkYuki Okushi-13/+21
Issue 109502 follow up, remove unnecessary Vec::new() from compile_test() As mentioned in comment on PR #110773 , adding a separate function to pass the test passes into the `dump-mir` is a bit nicer
2023-05-06Rollup merge of #109677 - dpaoliello:rawdylib, r=michaelwoerister,wesleywiserYuki Okushi-5/+31
Stabilize raw-dylib, link_ordinal, import_name_type and -Cdlltool This stabilizes the `raw-dylib` feature (#58713) for all architectures (i.e., `x86` as it is already stable for all other architectures). Changes: * Permit the use of the `raw-dylib` link kind for x86, the `link_ordinal` attribute and the `import_name_type` key for the `link` attribute. * Mark the `raw_dylib` feature as stable. * Stabilized the `-Zdlltool` argument as `-Cdlltool`. * Note the path to `dlltool` if invoking it failed (we don't need to do this if `dlltool` returns an error since it prints its path in the error message). * Adds tests for `-Cdlltool`. * Adds tests for being unable to find the dlltool executable, and dlltool failing. * Fixes a bug where we were checking the exit code of dlltool to see if it failed, but dlltool always returns 0 (indicating success), so instead we need to check if anything was written to `stderr`. NOTE: As previously noted (https://github.com/rust-lang/rust/pull/104218#issuecomment-1315895618) using dlltool within rustc is temporary, but this is not the first time that Rust has added a temporary tool use and argument: https://github.com/rust-lang/rust/pull/104218#issuecomment-1318720482 Big thanks to ``````@tbu-`````` for the first version of this PR (#104218)
2023-05-05add fn compile_test_with_passes()James Dietz-13/+21
2023-05-04add passes to miroptfiles struct and passed to -zdump-mir argsJames Dietz-21/+66
blessed new test
2023-05-02Rollup merge of #108161 - WaffleLapkin:const_param_ty, r=BoxyUwUDylan DPC-2/+5
Add `ConstParamTy` trait This is a bit sketch, but idk. r? `@BoxyUwU` Yet to be done: - [x] ~~Figure out if it's okay to implement `StructuralEq` for primitives / possibly remove their special casing~~ (it should be okay, but maybe not in this PR...) - [ ] Maybe refactor the code a little bit - [x] Use a macro to make impls a bit nicer Future work: - [ ] Actually™ use the trait when checking if a `const` generic type is allowed - [ ] _Really_ refactor the surrounding code - [ ] Refactor `marker.rs` into multiple modules for each "theme" of markers
2023-04-29Rollup merge of #110644 - pietroalbini:pa-json-formatting-tests, ↵Matthias Krüger-5/+37
r=Mark-Simulacrum Update tests for libtest `--format json` This PR makes the test work on beta and stable, and adds a test ensuring the option is not available on beta and stable. Backported these commits from https://github.com/rust-lang/rust/pull/110414.