-
Notifications
You must be signed in to change notification settings - Fork 13.3k
compiletest: FileCheck-based tests conflate FileCheck prefixes with compiletest revisions #134510
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
Comments
One of the really scary things about trying to make this change is that it can be very difficult to detect cases where the test author intended for a FileCheck directive to be checked, but it actually silently does nothing. Imagine that after requiring opt-in for revision-based prefixes, someone used to the old behaviour writes a new test that looks like this: //@ revisions: FOO BAR
// CHECK: (this is checked in both revisions)
// FOO: (only checked in FOO revision)
// BAR: (only checked in BAR revision) Because the test author forgot to opt in, those FOO and BAR lines are never checked. But because of the CHECK line that is checked in all revisions by default, FileCheck doesn't complain about “no checks found” either. So the test is just silently buggy. (I don't think this danger is a dealbreaker, but is a reason to be very careful when trying to make a change like this.) |
On the flip side, one of the big advantages of not registering revision-based prefixes by default is that we would be able to stop passing the |
Good points. Somewhat related is: #130981 and rust-lang/compiler-team#789, that we might be able to make FileCheck issues easier to detect. One possible idea is to require FileCheck annotations NOT use plain
since FileCheck AFAIK does not care about the comment-style/prefix. |
Actually, I'll phrase my previous comment even more strongly: To me, the main downside of the current situation is that we have to pass |
IIRC FileCheck doesn't even know what a comment is; it's basically just doing a pure substring match (with a little bit of extra logic to prevent different prefixes from overlapping with each other). The comment is just there to make sure that the compiler doesn't see the FileCheck directives. |
I wonder if we could request (or somebody just author) a change to LLVM filecheck so you can pass |
Indeed this would be great to have; we already have tests in the repo that uses non-existent prefixes and hence accidentally don't test anything: rust/tests/codegen/float/f16.rs Line 147 in 57d5f86
What are "filecheck prefixes", other than the ones used for revisions?
That sounds like a great idea. |
TL;DR:
|
Clearly we want to allow specific FileCheck annotations for specific revisions. So I don't think I understand the proposed alternative where compiletest revisions are not used for FileCheck prefix alternatives. What are the "orthogonal concepts" you are talking about in the issue description? |
By that I meant that you may want compiletest revisions, but don't want to forward them as custom The current situation is that we have to pass |
Do you have an example of where that would be useful? So far, whenever I used revisions in a codegen test, it was precisely to have slightly different FileCheck annotations. Otherwise, all we have is different compile flags or so? compiletest revisions for ui tests also allow different |
My memory is a bit hazy on this, I'll double check what happens if I try to remove the |
I assume it complains about the prefixes that are for other revisions. That makes perfect sense from a FileCheck perspective; FileCheck does not understand the "revisions" annotation after all. But we absolutely need the ability to tie FileCheck annotations to a particular revision (to e.g. select things via |
Sure. This was mostly an experimental issue FWIW. I think the proper approach is instead probably to
That way, we'd be able to keep the current compiletest revision => FileCheck custom prefix, yet be able to not have to pass unconditional EDIT: e.g. example from #137142 (comment)
|
With the current scheme where compiletest
//@ revisions
imply FileCheck prefixes of the same names, we can't distinguish between whether the author wanted to:We might want to investigate splitting these orthogonal concepts and have something like
//@ filecheck-prefixes: XXX
register FileCheck prefixes separately.Marked as E-hard as this will take quite a bit of investigation/design, and E-tedious as this probably involves updating a whole bunch of tests, and I don't have the bandwidth to mentor.
The text was updated successfully, but these errors were encountered: