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

test suite: ERROR and WARN annotations are not mandatory in UI tests #55596

Closed
petrochenkov opened this issue Nov 1, 2018 · 12 comments · Fixed by #66213
Closed

test suite: ERROR and WARN annotations are not mandatory in UI tests #55596

petrochenkov opened this issue Nov 1, 2018 · 12 comments · Fixed by #66213
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@petrochenkov
Copy link
Contributor

Example: ui/parser/if-in-in.rs.
The test has errors and has corresponding .stderr file, but has no //~ ERROR annotations and it still passes.
This should not happen, //~ ERROR and //~ WARN annotations must be mandatory even if none of them are written in the test yet.

@petrochenkov petrochenkov added A-testsuite Area: The testsuite used to check the correctness of rustc E-help-wanted Call for participation: Help is requested to fix this issue. labels Nov 1, 2018
@pnkfelix
Copy link
Member

pnkfelix commented Nov 6, 2018

I had thought this was deliberate, in the sense that if you didn’t have any such annotation, then the output wasn’t checked?

@petrochenkov
Copy link
Contributor Author

From what I've seen no annotations usually mean forgotten annotations.

Annotations also make compile-fail tests readable - you can see what the test is testing, what lines have issues. Otherwise you have to compare the source and the output side-by-side and that's hard and unreliable, especially given that line numbers in .stderr files are partially anonymized.

I'd prefer to keep this minor annotation burden to avoid tests that are accidentally wrong or unreadable.

@pnkfelix
Copy link
Member

pnkfelix commented Nov 8, 2018

I personally agree that no annotations usually mean forgotten (or at least unanticipated) annotations.

And I'm certainly a strong proponent of using annotations when one really wants to ensure that daagnostics are actually associated with particular points in the code.

Personally I think we should require them for ERROR (*)

But I don't want to require them in all cases for NOTE or HELP; that would make the annotation burden for test writers too extreme.

And I don't know what to think about whether to require it for WARN or not.

That dilemma is what I think got us to where we are today, where (in principle), if you write a single annotation of a certain kind, then you get checking for all annotations and diagnostics of that kind for the given test.


(*): The fact that currently we don't is probably a holdover from the categorization of the tests into ui/compile-fail/run-pass directories. (In hindsight, maybe everything would have been better doing the same thing to compile-fail that I did to run-pass: namely, make all the tests there use the ui infrastructure.)

@pnkfelix
Copy link
Member

pnkfelix commented Nov 8, 2018

Lets discuss this at the compiler meeting.

@pnkfelix pnkfelix added I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 8, 2018
@pnkfelix
Copy link
Member

pnkfelix commented Nov 8, 2018

Discussed at T-compiler meeting.

The general consensus was that we should do what @petrochenkov suggests (in that we should require tests in the ui (and run-pass) suite to have accurate //~ ERROR and //~ WARN annotations.

My main hesitation about this was about the barrier this would introduce for test authors. But then I was reminded that if a test wants to opt out, it can just add #![allow(warnings)]. That was enough to convince me that @petrochenkov is absolutely correct here.

@petrochenkov
Copy link
Contributor Author

if a test wants to opt out, it can just add #![allow(warnings)].

Beside that, UI tests allow(unused) by default via compiletest, so if warning happens it usually means something actually needs attention.

@RalfJung
Copy link
Member

RalfJung commented Nov 13, 2018

then I was reminded that if a test wants to opt out, it can just add #![allow(warnings)].

This will also remove warnings from the stderr file though. Currently one can test warnings via the stderr file only, that would no longer be possible. Any test that adds allow(warnings) because of this is a test that tests fewer things than it does right now.

@petrochenkov
Copy link
Contributor Author

petrochenkov commented Nov 13, 2018

With unused allowed by default warnings are rare and can be easily annotated with //~ WARN, no need to allow(warnings).

We should actually make a pass through tests and remove allow(...) annotations when possible.
There are few exceptions, like some test checking name resolution conflicts may want to disable the noise from non_camel_case_... and similar lints.

@petrochenkov
Copy link
Contributor Author

A somewhat opposite issue - #56277.

@saleemjaffer
Copy link
Contributor

@petrochenkov I would like to help with this. I am a newbie to rust.

@petrochenkov
Copy link
Contributor Author

#65759 (comment) tells how to resolve this issue.

@petrochenkov petrochenkov added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Oct 26, 2019
@petrochenkov
Copy link
Contributor Author

@saleemjaffer
Sorry, I never noticed your comment.
If you are still interested, there's now an instruction.
x.py test --bless --stage 1 src/test/ui will run the tests and update their outputs.

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 E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants