Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate ignore and only compiletest directive, and add human-readable ignore reasons #108905

Merged
merged 28 commits into from
Apr 5, 2023

Conversation

pietroalbini
Copy link
Member

This PR adds strict validation for the ignore and only compiletest directives, failing if an unknown value is provided to them. Doing so uncovered 79 tests in tests/ui that had invalid directives, so this PR also fixes them.

Finally, this PR adds human-readable ignore reasons when tests are ignored due to ignore or only directives, like "only executed when the architecture is aarch64" or "ignored when the operative system is windows". This was the original reason why I started working on this PR and #108659, as we need both of them for Ferrocene.

The PR is a draft because the code is extremely inefficient: it calls rustc --print=cfg --target $target for every rustc target (to gather the list of allowed ignore values), which on my system takes between 4s and 5s, and performs a lot of allocations of constant values. I'll fix both of them in the coming days.

r? @ehuss

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 8, 2023
tests/ui/asm/issue-87802.rs Outdated Show resolved Hide resolved
@@ -1,5 +1,6 @@
// build-pass
// only-x86-windows
// only-x86
// only-windows
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@pietroalbini
Copy link
Member Author

Ok so with --print all-target-specs-json it's now way faster again. Tomorrow I'll look into the test failure, handle "" being inserted into the hashsets, and possibly look if I can speed startup up even more.

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks for putting it together!

compiler/rustc_driver_impl/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_driver_impl/src/lib.rs Outdated Show resolved Hide resolved
@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Mar 10, 2023
@pietroalbini pietroalbini marked this pull request as ready for review March 10, 2023 15:11
@pietroalbini
Copy link
Member Author

Ok I should've fixed everything, this PR is ready now.

@ehuss
Copy link
Contributor

ehuss commented Mar 10, 2023

Looks like it needs to be formatted.

Also, I assume the 10 day period for rust-lang/compiler-team#600 needs to finish?

@bors
Copy link
Contributor

bors commented Mar 14, 2023

☔ The latest upstream changes (presumably #109097) made this pull request unmergeable. Please resolve the merge conflicts.

@pietroalbini
Copy link
Member Author

pietroalbini commented Mar 14, 2023

Rebased and formatted.

@@ -1,7 +1,7 @@
// Tests that the compiler errors if the user tries to turn off unwind tables
// when they are required.
//
// only-x86_64-windows-msvc
// only-x86_64-pc-windows-msvc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that I already did this one in #108809 and it was not enough

@pietroalbini
Copy link
Member Author

Pushed changes to fix the broken annotations in other compiletest suites (in addition to tests/ui).

@pietroalbini
Copy link
Member Author

More than 10 days passed, so the MCP has been approved!

@bors
Copy link
Contributor

bors commented Mar 21, 2023

☔ The latest upstream changes (presumably #108659) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with rebase

I haven't done a thorough review to check which tests will start or stop running with our CI configurations, or that this won't pass/fail on some of the more unusual targets. However, the changes look valid to me on the surface.

Perhaps someone could review the ignore messages in CI, and compare to a previous run, but I think that will be a lot of work.

Comment on lines 433 to 434
dbg!(target, pattern, ignore);
dbg!(config.target_cfgs());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to remove these since they generate a large amount of output.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whelp that wasn't supposed to be left there, I'll remove it tomorrow.

@pietroalbini
Copy link
Member Author

I'll rebase tomorrow!

Perhaps someone could review the ignore messages in CI, and compare to a previous run, but I think that will be a lot of work.

Well, good thing that all the executed tests are now available in the build metrics JSON files since #108659 😂

@pietroalbini pietroalbini force-pushed the pa-compiletest-ignore branch 2 times, most recently from f27d635 to 4fb3e65 Compare March 30, 2023 08:02
@pietroalbini
Copy link
Member Author

"tomorrow"

@bors r=ehuss rollup=never

@bors
Copy link
Contributor

bors commented Mar 30, 2023

📌 Commit 4fb3e65fc436cf70ae995dcb20d148492daa4d02 has been approved by ehuss

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Apr 3, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 3, 2023
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented Apr 5, 2023

⌛ Testing commit bbcbb6f with merge b2b676d...

@scottmcm
Copy link
Member

scottmcm commented Apr 5, 2023

Thanks for making this? I literally just yesterday caught myself making a type in // ignore-!

@bors
Copy link
Contributor

bors commented Apr 5, 2023

☀️ Test successful - checks-actions
Approved by: ehuss
Pushing b2b676d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 5, 2023
@bors bors merged commit b2b676d into rust-lang:master Apr 5, 2023
@rustbot rustbot added this to the 1.70.0 milestone Apr 5, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b2b676d): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.0% [-2.0%, -2.0%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.9% [1.5%, 4.4%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

@pietroalbini pietroalbini deleted the pa-compiletest-ignore branch April 5, 2023 22:10
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 15, 2023
…ehuss

[compiletest] Add more test ignore reasons, `needs-` validation, and improved error messages

This PR makes more improvements to the way compiletest ignoring headers are handled, following up on rust-lang#108905:

* Human-readable ignore reasons have been added for the remaining ignore causes (`needs-*` directives, `*llvm*` directives, and debugger version directives). All ignored tests should now have a human-readable reason.
* The code handling `needs-*` directives has been refactored, and now invalid `needs-*` directive emit errors like `ignore-*` and `only-*`.
* All errors are now displayed at startup (with line numbers) rather than just the first error of the first file.

This PR is best reviewed commit-by-commit.

r? `@ehuss`
djkoloski pushed a commit to djkoloski/rust that referenced this pull request May 11, 2023
Compiletest was switched to querying all targets using
`--print=all-target-specs-json` and `--print=target-spec-json`
in rust-lang#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 rust-lang#110850.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 15, 2023
…target, 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 rust-lang#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 rust-lang#110850.

`@jyn514` might be interested in reviewing since they commented on the issue.
cc `@tmandry` since this issue is affecting Fuchsia.
bors added a commit to rust-lang-ci/rust that referenced this pull request May 16, 2023
…rget, 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 rust-lang#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 rust-lang#110850.

`@jyn514` might be interested in reviewing since they commented on the issue.
cc `@tmandry` since this issue is affecting Fuchsia.
jyn514 added a commit to jyn514/rust that referenced this pull request Jun 3, 2023
This was changed from stage 0 to 1 in rust-lang#108905, but I'm not
sure why. Change it to `top_stage` instead to allow people to choose the stage.

This should save quite a bit of time in the `mingw-check` builder, which explicitly runs `x test --stage 0 compiletest`.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 10, 2023
…mulacrum

Don't compile rustc to self-test compiletest

This was changed from stage 0 to 1 in rust-lang#108905, but I'm not sure why. Change it to `top_stage` instead to allow people to choose the stage.

This should save quite a bit of time in the `mingw-check` builder, which explicitly runs `x test --stage 0 compiletest`.

Note that this also fixes a latent bug that depended on running `x build compiler` before `x doc compiler`, as well as a couple cleanups related to symlinks (which made the latent bug easier to find).

cc `@pietroalbini`
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Jun 11, 2023
Don't compile rustc to self-test compiletest

This was changed from stage 0 to 1 in rust-lang/rust#108905, but I'm not sure why. Change it to `top_stage` instead to allow people to choose the stage.

This should save quite a bit of time in the `mingw-check` builder, which explicitly runs `x test --stage 0 compiletest`.

Note that this also fixes a latent bug that depended on running `x build compiler` before `x doc compiler`, as well as a couple cleanups related to symlinks (which made the latent bug easier to find).

cc `@pietroalbini`
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Apr 7, 2024
Don't compile rustc to self-test compiletest

This was changed from stage 0 to 1 in rust-lang/rust#108905, but I'm not sure why. Change it to `top_stage` instead to allow people to choose the stage.

This should save quite a bit of time in the `mingw-check` builder, which explicitly runs `x test --stage 0 compiletest`.

Note that this also fixes a latent bug that depended on running `x build compiler` before `x doc compiler`, as well as a couple cleanups related to symlinks (which made the latent bug easier to find).

cc `@pietroalbini`
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this pull request Apr 27, 2024
Don't compile rustc to self-test compiletest

This was changed from stage 0 to 1 in rust-lang/rust#108905, but I'm not sure why. Change it to `top_stage` instead to allow people to choose the stage.

This should save quite a bit of time in the `mingw-check` builder, which explicitly runs `x test --stage 0 compiletest`.

Note that this also fixes a latent bug that depended on running `x build compiler` before `x doc compiler`, as well as a couple cleanups related to symlinks (which made the latent bug easier to find).

cc `@pietroalbini`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.