-
Notifications
You must be signed in to change notification settings - Fork 13.4k
compiletest: add option for automatically adding annotations #141033
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
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred in src/tools/compiletest cc @jieyouxu |
Error annotation can't be blessed for a reason. They're not intended to be blessed. |
I don't want land this, because I don't want to encourage "auto" error annotations. Agreed w/ error annotations can't be automatically bless is a feature, not a bug. |
I am not seeing the problem. This is not intended as an auto tool. You still have to check that the annotation makes sense. Just like how you're not supposed to bless error output blindly; you still have to check that the error message is what you expect, that nothing disappeared or got mangled or something. |
Also, please don't misunderstand me. I am by no means suggesting that we re-annotate the entire UI suite. It's just an illustration to show that it produces valid output in the vast majority of cases. |
Error annotations are themselves a safeguard against accidental stderr changes from reblessing. That you have to manually specify and scrutinize error annotations strongly nudges PR authors towards making sure error annotations make sense and are what they expect. I don't want to make this process automatic at all, even as an opt-in. Because if you're able to automatically add error annotations, PR authors will pay less attention to error annotations. Furthermore, I believe the property that the test files themselves are not modified by compiletest in place is important. |
As an concrete example, I don't want to encourage the use case in #140948:
IMHO, this is not the right approach, let me elaborate to share what I mean (give me a moment, I need some coffee). |
I wrote down my thoughts on the challenges and caveats on testing attribute positions. Auto-generating error annotations?Looking at the current approach in #140948, even 3 attributes is already proving to be problematic:
Clearly, this doesn't scale. Auto-generating error annotations does not mitigate this maintenance challenge, because once you have |
Still thinking about how to better implement test coverage for #140948, going to be at least tmrw. |
cc @petrochenkov as you were improving error annotations. |
I'm not sure what the definition of "bless" is, but if it means "make the ui test pass" then this is not that. Which is why it is a separate option and not covered under
I think the opposite is true. If I make it easy for others to add annotations that leaves more mental energy for contributors to review their results and check that it is what they expected. Anyway, this is irrelevant for the people who aren't paying attention - if you make the process more tedious for them they're just going to try to pay less attention. At least with this option it'll add the whole error message rather than the bare
I disagree that it doesn't scale. I imagine that maintaining those tests can look like:
Only this last step requires active thinking, which is exactly what you want. That makes it easy to audit the differences.
I'm happy to hear about alternative ideas. However I feel there's a strong consensus we need better test coverage in this area. |
Let me ask other team members for a vibe check. |
I'll gauge the sentiment for this functionality by this Thursday, and then decide to merge this or not. |
Okay. We discussed this in:
At least one team member expressed they'd want sth like this, and there are no strong objections, so I'm fine with landing this experimentally. Note that I might not get to reviewing this today, I scheduled this PR for this Friday. |
I'm fine with this as long as the option is not documented as a recommended way to do things (and maybe documented as non-recommended instead). |
FWIW @RalfJung has a design concern, I'll have to think about this some more. ATM I'm busy on the stage 0 bootstrap redesign work, I'll probably only get to the design of this next week. cf. a related thread: #t-compiler > Are `ERROR` annotations worth it? |
A similar concern is things like opaque types, error messages often mention them like |
This PR adds the option
--try-annotate
to have compiletest write annotations like//~ERROR found Foo, expected Bar
.I need this to automatically generate tests for #140948 (comment) but I realized this is quite useful generally so I have split this up into its own PR.
I have tested this on our test suite by removing all targeted annotations (skipping revision tests and
//~?
and//~v
), which results in 10k failing tests. By then runningall but 24 tests will pass again. Most of these tests either have opaque types (see the instability comment in the PR), involve syntax errors spread over multiple lines (again, see instability) or they are weird and should use a
//~v
annotation.Failing tests
Script for deleting annotations, in case you want to try it out
Also, this PR stops immediately formatting the error messages. It proved quite painful to extract the original error again, so instead I implemented this type which is just formatted when needed.
r? @jieyouxu