about summary refs log tree commit diff
path: root/src/tools/compiletest
AgeCommit message (Collapse)AuthorLines
2025-01-28Fix tests/codegen/float/f128Alisa Sireneva-0/+1
2025-01-25Shorten linker output even more when `--verbose` is not presentjyn-0/+2
- Don't show environment variables. Seeing PATH is almost never useful, and it can be extremely long. - For .rlibs in the sysroot, replace crate hashes with a `"-*"` string. This will expand to the full crate name when pasted into the shell. - Move `.rlib` to outside the glob. - Abbreviate the sysroot path to `<sysroot>` wherever it appears in the arguments. This also adds an example of the linker output as a run-make test. Currently it only runs on x86_64-unknown-linux-gnu, because each platform has its own linker arguments. So that it's stable across machines, pass BUILD_ROOT as an argument through compiletest through to run-make tests. - Only use linker-flavor=gnu-cc if we're actually going to compare the output. It doesn't exist on MacOS.
2025-01-23compiletest: implement `needs-subprocess` directive许杰友 Jieyou Xu (Joe)-0/+20
2025-01-23Auto merge of #135164 - Kobzol:run-make-test-glibc-symbols, r=jieyouxubors-0/+7
Add test for checking used glibc symbols This test checks that we do not use too new glibc symbols in the compiler on x64 GNU Linux, in order not to break our [glibc promises](https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html). One thing that isn't solved in the PR yet is to make sure that this test will only run on `dist` CI, more specifically on the `dist-x86_64-linux` runner, in the opt-dist post-optimization tests (it can fail elsewhere, that doesn't matter). Any suggestions on how to do that are welcome. Fixes: https://github.com/rust-lang/rust/issues/134037 r? `@jieyouxu`
2025-01-22Rollup merge of #135557 - estebank:wtf8, r=fee1-deadMatthias Krüger-0/+2
Point at invalid utf-8 span on user's source code ``` error: couldn't read `$DIR/not-utf8-bin-file.rs`: stream did not contain valid UTF-8 --> $DIR/not-utf8-2.rs:6:5 | LL | include!("not-utf8-bin-file.rs"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: byte `193` is not valid utf-8 --> $DIR/not-utf8-bin-file.rs:2:14 | LL | let _ = "�|�␂!5�cc␕␂��"; | ^ = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info) ``` When we attempt to load a Rust source code file, if there is a OS file failure we try reading the file as bytes. If that succeeds we try to turn it into UTF-8. If *that* fails, we provide additional context about *where* the file has the first invalid UTF-8 character. Fix #76869.
2025-01-22Run the glibc run-make test in opt-distJakub Beránek-1/+1
2025-01-22Point at invalid utf-8 span on user's source codeEsteban Küber-0/+2
``` error: couldn't read `$DIR/not-utf8-bin-file.rs`: stream did not contain valid UTF-8 --> $DIR/not-utf8-2.rs:6:5 | LL | include!("not-utf8-bin-file.rs"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `[193]` is not valid utf-8 --> $DIR/not-utf8-bin-file.rs:2:14 | LL | let _ = "�|�␂!5�cc␕␂��"; | ^ = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info) ``` When we attempt to load a Rust source code file, if there is a OS file failure we try reading the file as bytes. If that succeeds we try to turn it into UTF-8. If *that* fails, we provide additional context about *where* the file has the first invalid UTF-8 character. Fix #76869.
2025-01-21bumpt compiler and tools to windows 0.59klensy-3/+2
2025-01-21Add test for checking used glibc symbolsJakub Beránek-1/+8
2025-01-18Rollup merge of #135421 - cod10129:warn-tidy-ignore, r=onur-ozkanMatthias Krüger-2/+2
Make tidy warn on unrecognized directives This PR makes it so tidy warns on unrecognized directives, as recommended on [the discussion of #130984](https://github.com/rust-lang/rust/issues/130984#issuecomment-2589284620). This is edited from the previous version of this PR, which only warned on "tidy-ignore" and no other tidy directive typos. Fixes #130984. ``@rustbot`` label A-tidy C-enhancement
2025-01-14add tidy warning for unrecognized directivescod10129-2/+2
This makes tidy warn on the presence of any directives it does not recognize. There are changes in compiletest because that file used "tidy-alphabet" instead of "tidy-alphabetical".
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 } ```