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

Tidy check for test revisions that are mentioned but not declared #124706

Merged
merged 3 commits into from
May 9, 2024

Conversation

Zalathar
Copy link
Contributor

@Zalathar Zalathar commented May 4, 2024

If a [revision] name appears in a test header directive or error annotation, but isn't declared in the //@ revisions: header, that is almost always a mistake.

In cases where a revision needs to be temporarily disabled, adding it to an //@ unused-revision-names: header will suppress these checks for that name.

Adding the wildcard name * to the unused list will suppress these checks for the entire file.

(None of the tests actually use *; it's just there because it was easy to add and could be handy as an escape hatch when dealing with other problems.)


Most of the existing problems discovered by this check were fairly straightforward to fix (or ignore); the trickiest cases are in borrowck tests.

@rustbot
Copy link
Collaborator

rustbot commented May 4, 2024

r? @estebank

rustbot has assigned @estebank.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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-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. labels May 4, 2024
@rustbot
Copy link
Collaborator

rustbot commented May 4, 2024

Some changes occurred in src/tools/compiletest

cc @jieyouxu

Some changes occurred in tests/ui/check-cfg

cc @Urgau

@Zalathar Zalathar force-pushed the revision-checker branch 2 times, most recently from 1ec1f55 to c341740 Compare May 4, 2024 12:12
@Zalathar
Copy link
Contributor Author

Zalathar commented May 4, 2024

It would be nice to have a variant of this for Filecheck directives as well, but that's probably trickier because they're more freeform and thus harder to identify reliably.

@bors
Copy link
Contributor

bors commented May 4, 2024

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

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

I feel like the long-term solution to revision-related funny business is to rework how compiletest directive collection, parsing and validation is done. This would include adding validation for revisions that are used but not declared (i.e. the problem this PR is trying to solve), duplicate, invalid (incl. invalid characters and such), etc.

I think having a tidy check in the meantime (before compiletest directive rework, which I plan to start work on towards the end of this month) is reasonable though. It just feels like it should be the job of compiletest rather than a tidy check.

@jieyouxu
Copy link
Member

jieyouxu commented May 4, 2024

I'll roll a bootstrap reviewer as well because this mostly concerns tidy which falls under the purview of bootstrap. I think this PR is definitely rightfully addressing a "wtf moment" when writing and reading tests, I'm just not sure if it should be tidy's responsibility.

r? bootstrap

@rustbot rustbot assigned Mark-Simulacrum and unassigned estebank May 4, 2024
@Zalathar
Copy link
Contributor Author

Zalathar commented May 4, 2024

Yeah, my original implementation was integrated into compiletest, but it felt like I was adding more mess that would make future cleanups even trickier. So I decided to try a more self-contained tidy-based version instead.

So I’m fine with this being seen as a relatively temporary solution, to eventually be replaced with better checks inside compiletest itself.

@jieyouxu
Copy link
Member

jieyouxu commented May 4, 2024

@Mark-Simulacrum
Copy link
Member

r? jieyouxu -- tidy seems like a reasonable place

@rustbot rustbot assigned jieyouxu and unassigned Mark-Simulacrum May 4, 2024
@Zalathar Zalathar force-pushed the revision-checker branch 2 times, most recently from 436b20f to f8b392b Compare May 5, 2024 01:27
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

The implementation for this looks good to me. One minor nit about maybe leaving a FIXME for the tidy check to not forget to replace it with proper handling in compiletest in the long term.

Copy link
Member

Choose a reason for hiding this comment

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

Should we leave a FIXME here (feel free to FIXME(jieyouxu)) to remind people (well, mostly me) that ideally we would have these checks as part of compiletest directive and revision handling?

@jieyouxu
Copy link
Member

jieyouxu commented May 8, 2024

Feel free to r=me with or without the FIXME.

@bors delegate=Zalathar

@bors
Copy link
Contributor

bors commented May 8, 2024

✌️ @Zalathar, you can now approve this pull request!

If @jieyouxu told you to "r=me" after making some further change, please make that change, then do @bors r=@jieyouxu

@Zalathar Zalathar force-pushed the revision-checker branch from f8b392b to 80b67c8 Compare May 9, 2024 04:44
If a `[revision]` name appears in a test header directive or error annotation,
but isn't declared in the `//@ revisions:` header, that is almost always a
mistake.

In cases where a revision needs to be temporarily disabled, adding it to an
`//@ unused-revision-names:` header will suppress these checks for that name.

Adding the wildcard name `*` to the unused list will suppress these checks for
the entire file.
Most of these changes either add revision names that were apparently missing,
or explicitly mark a revision name as currently unused.
@Zalathar Zalathar force-pushed the revision-checker branch from 80b67c8 to 14d56e8 Compare May 9, 2024 04:52
@Zalathar
Copy link
Contributor Author

Zalathar commented May 9, 2024

Rebased and added FIXME (diff).

@bors r=jieyouxu

@bors
Copy link
Contributor

bors commented May 9, 2024

📌 Commit 14d56e8 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 9, 2024
@bors
Copy link
Contributor

bors commented May 9, 2024

⌛ Testing commit 14d56e8 with merge 8c7c151...

@bors
Copy link
Contributor

bors commented May 9, 2024

☀️ Test successful - checks-actions
Approved by: jieyouxu
Pushing 8c7c151 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 9, 2024
@bors bors merged commit 8c7c151 into rust-lang:master May 9, 2024
7 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 9, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8c7c151): comparison URL.

Overall result: ❌✅ regressions and 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.4% [0.3%, 0.5%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.4%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

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

Cycles

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

Binary size

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

Bootstrap: 673.446s -> 674.785s (0.20%)
Artifact size: 315.79 MiB -> 315.96 MiB (0.05%)

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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

8 participants