about summary refs log tree commit diff
path: root/src/tools/compiletest
AgeCommit message (Collapse)AuthorLines
2025-01-13Rollup merge of #135386 - lolbinarycat:bootstrap-test-cleanup, r=jieyouxuJacob Pratt-9/+9
clean up code related to the rustdoc-js test suite r? `@jieyouxu`
2025-01-12Auto merge of #135402 - matthiaskrgr:rollup-cz7hs13, r=matthiaskrgrbors-3/+34
Rollup of 6 pull requests Successful merges: - #129259 (Add inherent versions of MaybeUninit methods for slices) - #135374 (Suggest typo fix when trait path expression is typo'ed) - #135377 (Make MIR cleanup for functions with impossible predicates into a real MIR pass) - #135378 (Remove a bunch of diagnostic stashing that doesn't do anything) - #135397 (compiletest: add erroneous variant to `string_enum`s conversions error) - #135398 (add more crash tests) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-12add error message to `string_enum!`s string conversionsRémy Rakic-4/+4
2025-01-12add test for `string_enum`Rémy Rakic-0/+31
2025-01-12rename run_js_doc_test to run_rustdoc_js_testbinarycat-4/+4
2025-01-12compiletest: include stage0-sysroot libstd dylib in recipe dylib search path许杰友 Jieyou Xu (Joe)-1/+10
To fix some of the failures in `COMPILETEST_FORCE_STAGE0=1 ./x test run-make --stage 0`.
2025-01-11rename 'js-doc-test' to 'rustdoc-js' in compiletestbinarycat-7/+7
2025-01-07Avoid naming variables `str`Josh Triplett-7/+7
This renames variables named `str` to other names, to make sure `str` always refers to a type. It's confusing to read code where `str` (or another standard type name) is used as an identifier. It also produces misleading syntax highlighting.
2025-01-04Rollup merge of #134925 - DavisRayM:130982-deny-special-filecheck-prefixes, ↵Jubilee-0/+65
r=jieyouxu deny usage of special FileCheck prefixes as revision names Adds a check that ensures special FileCheck prefixes are not used as revision names. Fix #130982
2025-01-02limit special `FileCheck` revision checksDavis Muro-11/+51
2025-01-02Make the `test` cfg a "userspace" check-cfgUrgau-2/+3
2024-12-30deny usage of FileCheck prefixes as revision namesDavis Muro-0/+25
2024-12-29Simplify `DebuggerCommands::parse_from` to only take one prefixZalathar-20/+11
2024-12-29Remove the unused `cdbg-*` debugger directive prefixZalathar-7/+1
There are no tests in `tests/debuginfo` that use this prefix.
2024-12-28compiletest: Make a FIXME for escaped newlines less confusingZalathar-1/+3
The old FIXME implies that we don't support escaped newlines, but in fact it was added in the same patch that added support for escaped newlines. The new FIXME makes it clear that we do currently support this, and that the FIXME is for doing so in a less ad-hoc way.
2024-12-28compiletest: Only pass the post-colon value to `parse_normalize_rule`Zalathar-21/+22
2024-12-27Rollup merge of #134809 - clubby789:nocapture, r=jieyouxuMatthias Krüger-1/+7
Add `--no-capture`/`--nocapture` as bootstrap arguments I often try `x test ... --nocapture` => 'unknown argument' => `x test ... -- --nocapture`. As we forward several other compiletest flags, let's recognise this one in bootstrap as well.
2024-12-27Rollup merge of #134808 - clubby789:compiletest-remove-stderr, r=jieyouxuMatthias Krüger-37/+81
compiletest: Remove empty 'expected' files when blessing Fixes #134793 Fixes #134196 This also refactors `compare_output` to return an enum; returning a usize was done for convenience but is misleading
2024-12-27compiletest: Remove/don't write empty 'expected' filesclubby789-37/+81
2024-12-27compiletest: Replace `--nocapture` with `--no-capture`clubby789-1/+7
2024-12-27Remove the `-test` suffix from normalize directivesZalathar-4/+4
2024-12-27Don't use `parse_cfg_name_directive` for normalize directivesZalathar-16/+49
This is a little more verbose, but also more explicit, and avoids invoking the full condition engine when only the pointer-width conditions are used.
2024-12-25Auto merge of #134738 - clubby789:forbid-output-ui, r=jieyouxubors-2/+4
compiletest: Support `forbid-output` in UI tests The `forbid-output` directive is currently only run in incremental tests (although no incremental tests use it). There are some UI tests 'using' it, but it's doing nothing 😄 Let's fix this Will also PR the dev guide to note this. dev-guide PR: https://github.com/rust-lang/rustc-dev-guide/pull/2171
2024-12-25compiletest: Support `forbid-output` in UI testsclubby789-2/+4
2024-12-24chore: fix typosoliveredget-1/+1
2024-12-23Rollup merge of #134659 - jieyouxu:recursive-remove, r=ChrisDentonTrevor Gross-30/+7
test-infra: improve compiletest and run-make-support symlink handling I was trying to implement #134656 to port `tests/run-make/incr-add-rust-src-component.rs`, but found some blockers related to symlink handling, so in this PR I tried to resolve them by improving symlink handling in compiletest and run-make-support (particularly for native windows msvc environment). Key changes: - I needed to copy symlinks (duplicate a symlink pointing to the same file), so I pulled out the copy symlink logic and re-exposed it as `run_make_support::rfs::copy_symlink`. This helper correctly accounts for the Windows symlink-to-file vs symlink-to-dir distinction (hereafter "Windows symlinks") when copying symlinks. - `recursive_remove`: - I needed a way to remove symlinks themselves (no symlink traversal). `std::fs::remove_dir_all` handles them, but only if the root path is a directory. So I wrapped `std::fs::remove_dir_all` to also handle when the root path is a non-directory entity (e.g. file or symlink). Again, this properly accounts for Windows symlinks. - I wanted to use this for both compiletest and run-make-support, so I put the implementation and accompanying tests in `build_helper`. - In this sense, it's a reland of #129302 with proper test coverage. - It's a thin wrapper around `std::fs::remove_dir_all` (`remove_dir_all` correctly handles read-only entries on Windows). The helper has additional permission-setting logic for when the root path is a non-dir entry on Windows to handle read-only non-dir entry. Fixes #126334.
2024-12-23compiletest: use `recursive_remove` instead of `aggressive_rm_rf`Jieyou Xu-30/+7
`aggressive_rm_rf` does not correctly handle distinction between symlink-to-file vs symlink-to-dir on Windows.
2024-12-21compiletest: Allow using a specific debugger when running debuginfo testsclubby789-6/+23
2024-12-19compiletest: don't register `MSVC`/`NONMSVC` FileCheck prefixes许杰友 Jieyou Xu (Joe)-10/+10
This was fragile as it was based on host target passed to compiletest, but the user could cross-compile and run test for a different target (e.g. cross from linux to msvc, but msvc won't be set on the target). Furthermore, it was also very surprising as normally revision names (other than `CHECK`) was accepted as FileCheck prefixes.
2024-12-18Auto merge of #134443 - joshtriplett:use-field-init-shorthand, ↵bors-1/+1
r=lqd,tgross35,nnethercote Use field init shorthand where possible Field init shorthand allows writing initializers like `tcx: tcx` as `tcx`. The compiler already uses it extensively. Fix the last few places where it isn't yet used. EDIT: this PR also updates `rustfmt.toml` to set `use_field_init_shorthand = true`.
2024-12-17Use field init shorthand where possibleJosh Triplett-1/+1
Field init shorthand allows writing initializers like `tcx: tcx` as `tcx`. The compiler already uses it extensively. Fix the last few places where it isn't yet used.
2024-12-18refactor: replace &PathBuf with &Path to enhance generalityIntegral-7/+6
2024-12-14show which test the `rmake` process belongs tojyn-2/+15
2024-12-14Fix `--nocapture` for run-make testsjyn-21/+30
This was confusing because there are three layers of output hiding. 1. libtest shoves all output into a buffer and does not print it unless the test fails or `--nocapture` is passed. 2. compiletest chooses whether to print the output from any given process. 3. run-make-support chooses what output to print. This modifies 2 and 3. - compiletest: Don't require both `--verbose` and `--nocapture` to show the output of run-make tests. - compiletest: Distinguish rustc and rmake stderr by printing the command name (e.g. "--stderr--" to "--rustc stderr--"). - run-make-support: Unconditionally print the needle/haystack being searched. Previously this was only printed on failure. Before: ``` $ x t tests/run-make/linker-warning --force-rerun -- --nocapture running 1 tests . test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 377 filtered out; finished in 281.64ms $ x t tests/run-make/linker-warning --force-rerun -v -- --nocapture 2>&1 | wc -l 1004 $ x t tests/run-make/linker-warning --force-rerun -v -- --nocapture | tail -n40 running 1 tests ------stdout------------------------------ ------stderr------------------------------ warning: unused import: `std::path::Path` --> /home/jyn/src/rust2/tests/run-make/linker-warning/rmake.rs:1:5 | 1 | use std::path::Path; | ^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused import: `run_make_support::rfs::remove_file` --> /home/jyn/src/rust2/tests/run-make/linker-warning/rmake.rs:3:5 | 3 | use run_make_support::rfs::remove_file; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: 2 warnings emitted ------------------------------------------ test [run-make] tests/run-make/linker-warning ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 377 filtered out; finished in 285.89ms ``` After: ``` Testing stage1 compiletest suite=run-make mode=run-make (x86_64-unknown-linux-gnu) running 1 tests ------rmake stdout------------------------------ ------rmake stderr------------------------------ assert_contains_regex: === HAYSTACK === error: linking with `./fake-linker` failed: exit status: 1 | = note: LC_ALL="C" PATH="/home/jyn/src/rust2/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin:...:/bin" VSLANG="1033" "./fake-linker" "-m64" "/tmp/rustcYqdAZT/symbols.o" "main.main.d17f5fbe6225cf88-cgu.0.rcgu.o" "main.2uoctswmurc6ir5rvoay0p9ke.rcgu.o" "-Wl,--as-needed" "-Wl,-Bstatic" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-B/home/jyn/src/rust2/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/jyn/src/rust2/build/x86_64-unknown-linux-gnu/test/run-make/linker-warning/rmake_out" "-L" "/home/jyn/src/rust2/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "main" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "run_make_error" = note: error: baz error: aborting due to 1 previous error === NEEDLE === fake-linker.*run_make_error assert_not_contains_regex: === HAYSTACK === === NEEDLE === fake-linker.*run_make_error ------------------------------------------ . test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 377 filtered out; finished in 314.81ms ```
2024-12-12Revert "Rollup merge of #134040 - clubby789:bootstrap-eprintln, r=jieyouxu"许杰友 Jieyou Xu (Joe)-57/+57
This reverts commit b282774aaf0aa05b4a9855d973b67e7e424c2136, reversing changes made to e0f3db0056288a06b1ae36cdd70741a4e0b3584a.
2024-12-09compiletest: `print{,ln}!` -> `eprint{,ln}!`clubby789-57/+57
Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
2024-12-09Auto merge of #134052 - matthiaskrgr:rollup-puxwqrk, r=matthiaskrgrbors-5/+12
Rollup of 7 pull requests Successful merges: - #133567 (A bunch of cleanups) - #133789 (Add doc alias 'then_with' for `then` method on `bool`) - #133880 (Expand home_dir docs) - #134036 (crash tests: use individual mir opts instead of mir-opt-level where easily possible) - #134045 (Fix some triagebot mentions paths) - #134046 (Remove ignored tests for hangs w/ new solver) - #134050 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-08improve `--compare-mode` error handlingRémy Rakic-5/+12
- show the erroneous value - show the valid values
2024-12-07compiletest: show the difference between the normalized output and the ↵jyn-35/+119
actual output for lines which didn't match example output: ``` failures: ---- [ui] tests/ui/layout/enum.rs stdout ---- diff of stderr: - error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: $PREF_ALIGN } + error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: $PREF_ALIN } 2 --> $DIR/enum.rs:9:1 3 | 4 LL | enum UninhabitedVariantAlign { Note: some mismatched output was normalized before being compared - error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: Align(8 bytes) } - --> /home/jyn/src/rust2/tests/ui/layout/enum.rs:9:1 + error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: $PREF_ALIN } ```
2024-12-05Revert "Rollup merge of #133817 - clubby789:bootstrap-eprintln, r=jieyouxu"Jieyou Xu-54/+54
This reverts commit 0585134e709de4a14e509158662fa569c155c195, reversing changes made to 5530869e0ff21d69e0eef1a4c4fd1f25bcbe7fbf. The PR unfortunately only converted the `ln!` instances, meaning that test output was messed up because stdout/stderr output interleaved when some `println!` instances were converted to `eprintln!` instances, while some `println!` instances remain unchanged.
2024-12-04Rollup merge of #133817 - clubby789:bootstrap-eprintln, r=jieyouxuMatthias Krüger-54/+54
Use `eprintln` instead of `println` in bootstrap/compiletest/tidy A big unconditional CTRL-F replace to start with to check if there's anything that CI expects to be on stdout r? `@jieyouxu`
2024-12-03compiletest: `println!` -> `eprintln!`clubby789-54/+54
2024-12-03compiletest: explain that UI tests are expected not to compile by defaultclubby789-4/+7
2024-12-02Rollup merge of #133710 - Urgau:target_feature-merge-conflitcs, r=jieyouxuGuillaume Gomez-0/+2
Reducing `target_feature` check-cfg merge conflicts It was rightfully pointed in https://github.com/rust-lang/rust/pull/133099#discussion_r1862490542 that the expected values for the `target_feature` cfg are regularly updated and unfortunately the check-cfg tests for it are very merge-conflict prone. This PR aims at drastically reducing the likely-hood of those, by normalizing the "and X more" diagnostic, as well as making the full expected list multi-line instead of being on a single one. cc `@RalfJung` r? `@jieyouxu`
2024-12-02Rollup merge of #133736 - jieyouxu:needs-target-has-atomic, r=compiler-errorsGuillaume Gomez-5/+106
Add `needs-target-has-atomic` directive Before this PR, the test writer has to specify platforms and architectures by hand for targets that have differing atomic width support. `#[cfg(target_has_atomic="...")]` is not quite the same because (1) you may have to specify additional matchers manually which has to be maintained individually, and (2) the `#[cfg]` blocks does not communicate to compiletest that a test would be ignored for a given target. This PR implements a `//@ needs-target-has-atomic` directive which admits a comma-separated list of required atomic widths that the target must satisfy in order for the test to run. ``` //@ needs-target-has-atomic: 8, 16, ptr ``` See <https://github.com/rust-lang/rust/issues/87377>. This PR supersedes #133095 and is co-authored by `@kei519,` because it was somewhat subtle, and it turned out easier to implement than to review. rustc-dev-guide docs PR: https://github.com/rust-lang/rustc-dev-guide/pull/2154
2024-12-02Add `needs-target-has-atomic` directive许杰友 Jieyou Xu (Joe)-5/+106
Before this commit, the test writer has to specify platforms and architectures by hand for targets that have differing atomic width support. `#[cfg(target_has_atomic)]` is not quite the same because (1) you may have to specify additional matchers manually which has to be maintained individually, and (2) the `#[cfg]` blocks does not communicate to compiletest that a test would be ignored for a given target. This commit implements a `//@ needs-target-has-atomic` directive which admits a comma-separated list of required atomic widths that the target must satisfy in order for the test to run. ``` //@ needs-target-has-atomic: 8, 16, ptr ``` See <https://github.com/rust-lang/rust/issues/87377>. Co-authored-by: kei519 <masaki.keigo.q00@kyoto-u.jp>
2024-12-01Remove `//@ compare-output-lines-by-subset`jyn-18/+4
There was only ever one test which used this flag, and it was removed in https://github.com/rust-lang/rust/pull/132244. I think this is a bad flag that should never have been added; comparing by subset makes the test failures extremely hard to debug. Any test that needs complicated output filtering like this should just use run-make instead. Note that this does not remove the underlying comparison code, because it's still used if `runner` is set. I don't quite understand what's going on there, but since we still test on other platforms and in CI that the full output is accurate, I think it will be easier to debug than a test that uses compare-by-subset unconditionally.
2024-12-01compiletest: un-escape new-line in normalize replacement stringUrgau-0/+2
2024-11-27Compiletest: Add proc-macro headerEric Huss-23/+66
This adds a proc-macro header to make it easier to depend on a proc-macro, and remove some of the boilerplate necessary.
2024-11-26compiletest: remove `pretty-expanded` directive and infraJieyou Xu-22/+0
Foreword ======== Let us begin the journey to rediscover what the `//@ pretty-expanded` directive does, brave traveller -- "My good friend, [..] when I wrote that passage, God and I knew what it meant. It is possible that God knows it still; but as for me, I have totally forgotten." -- Johann Paul Friedrich Richter, 1826 We must retrace the steps of those before us, for history shall guide us in the present and inform us of the future. The Past ======== Originally there was some effort to introduce more test coverage for `-Z unpretty=expanded` (in 2015 this was called `--pretty=expanded`). In [Make it an error to not declare used features #23598][pr-23598], there was a flip from `//@ no-pretty-expanded` (opt-out of `-Z unpretty=expanded` test) to `//@ pretty-expanded` (opt-in to `-Z unpretty=expanded` test). This was needed because back then the dedicated `tests/pretty` ("pretty") test suite did not existed, and the pretty tests were grouped together under `run-pass` tests (I believe `ui` test suite didn't exist back then either). Unfortunately, in this process the replacement `//@ pretty-expanded` directives contained a `FIXME #23616` linking to [There are very few tests for `-Z unpretty` expansion #23616][issue-23616]. But this was arguably backwards and somewhat misleading, as noted in <https://github.com/rust-lang/rust/issues/23616#issuecomment-484999901>: The attribute is off by default and things just work if you don't test it, people have not been adding the `pretty-expanded` annotation to new tests even if it would work. Which basically renders this useless. The Present =========== As of Nov 2024, we have a dedicated `pretty` test suite, and some time over the years the split between `run-pass` into `ui` and `pretty` test suites caused all of the `//@ pretty-expanded` in `ui` tests to do absolutely nothing -- the compiletest logic for `pretty-expanded` only triggered in the *pretty* test suite, but none of the pretty tests use it. Oops. The Future ========== Nobody remembers this, nobody uses this, it's misleading in ui tests. Let's get rid of this directive altogether. [pr-23598]: https://github.com/rust-lang/rust/pull/23598 [issue-23616]: https://github.com/rust-lang/rust/issues/23616