-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
compiletest: don't register predefined MSVC
/NONMSVC
FileCheck prefixes
#134463
Conversation
@bors try |
compiletest: don't register predefined `MSVC`/`NONMSVC` FileCheck prefixes This was fragile as it was based on host target passed to compiletest, but the user could cross-compile and run test for a different target (e.g. cross from linux to msvc, but msvc won't be set on the target). Furthermore, it was also very surprising as normally revision names (other than `CHECK`) was accepted as FileCheck prefixes. This partially reverts the `MSVC`/`NONMSVC` predefined FileCheck prefix registration introduced in rust-lang#120656 for some codegen tests. This makes some codegen tests more verbose since they now need to explicitly introduce `MSVC`/`NONMSVC` revisions, but I think that's less surprising, e.g.: ```rs //@ revisions: MSVC NONMSVC //`@[MSVC]` only-msvc //`@[NONMSVC]` ignore-msvc ``` Note that revisions are not *only* FileCheck prefixes in FileCheck-based test suites, as they also can be used to conditionally apply certain compiletest directives. r? `@Zalathar` (or reroll a `r/? compiletest` reviewer) try-job: x86_64-msvc try-job: i686-msvc try-job: x86_64-mingw try-job: i686-mingw
This comment has been minimized.
This comment has been minimized.
src/tools/compiletest/src/runtest.rs
Outdated
// Tests are allowed to use a revision name as a check prefix. | ||
if let Some(rev) = self.revision { | ||
filecheck.arg("--check-prefix").arg(rev); | ||
} | ||
|
||
// Some tests also expect either the MSVC or NONMSVC prefix to be defined. | ||
let msvc_or_not = if self.config.target.contains("msvc") { "MSVC" } else { "NONMSVC" }; | ||
filecheck.arg("--check-prefix").arg(msvc_or_not); | ||
|
||
// The filecheck tool normally fails if a prefix is defined but not used. | ||
// However, we define several prefixes globally for all tests. | ||
// The filecheck tool normally fails if a prefix is defined but not used. However, sometimes | ||
// revisions are used to specify *compiletest* directives which are not FileCheck concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: If we're revising these comments, I think they should acknowledge that auto-registering revision names as check prefix is a bit sketchy, and that having to pass --allow-unused-prefix
is an unfortunate side-effect of not knowing whether the test author actually wanted revision-specific check prefixes or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll update the docs here to better reflect the behavior after I try to run some test jobs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason I haven't tried to fix this yet is that there are quite a few tests affected, and in tests that use both CHECK and revision-specific prefixes, there's a risk of accidentally only checking the CHECK ones and silently ignoring all the revision ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. I'll think about this a bit more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason I haven't tried to fix this yet is that there are quite a few tests affected, and in tests that use both CHECK and revision-specific prefixes, there's a risk of accidentally only checking the CHECK ones and silently ignoring all the revision ones.
Don't we register the revisions via
if let Some(rev) = self.revision {
filecheck.arg("--check-prefix").arg(rev);
}
?
EDIT: nvm I see what you mean -- we can't distinguish between whether the author wanted to:
- Use revisions but ONLY for compiletest directive purposes.
- Use revisions but ONLY for filecheck prefix purposes.
- Use revisions for BOTH.
You are saying, that we should actually properly have an orthogonal set, something like //@ filecheck-prefixes: MSVC NONMSVC
etc. right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added comments back + further clarified the current situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #134510 to track this and backlinked from comments.
@bors try |
compiletest: don't register predefined `MSVC`/`NONMSVC` FileCheck prefixes This was fragile as it was based on host target passed to compiletest, but the user could cross-compile and run test for a different target (e.g. cross from linux to msvc, but msvc won't be set on the target). Furthermore, it was also very surprising as normally revision names (other than `CHECK`) was accepted as FileCheck prefixes. This partially reverts the `MSVC`/`NONMSVC` predefined FileCheck prefix registration introduced in rust-lang#120656 for some codegen tests. This makes some codegen tests more verbose since they now need to explicitly introduce `MSVC`/`NONMSVC` revisions, but I think that's less surprising, e.g.: ```rs //@ revisions: MSVC NONMSVC //`@[MSVC]` only-msvc //`@[NONMSVC]` ignore-msvc ``` Note that revisions are not *only* FileCheck prefixes in FileCheck-based test suites, as they also can be used to conditionally apply certain compiletest directives. r? `@Zalathar` (or reroll a `r/? compiletest` reviewer) try-job: x86_64-msvc try-job: i686-msvc try-job: x86_64-mingw-1 try-job: i686-mingw
☀️ Try build successful - checks-actions |
2b41c9d
to
de837ce
Compare
Rebased to add clarifying comments as requested in #134463 (comment), no functional changes. |
de837ce
to
3e2aa53
Compare
@rustbot ready |
This was fragile as it was based on host target passed to compiletest, but the user could cross-compile and run test for a different target (e.g. cross from linux to msvc, but msvc won't be set on the target). Furthermore, it was also very surprising as normally revision names (other than `CHECK`) was accepted as FileCheck prefixes.
3e2aa53
to
5415f06
Compare
Trimmed the comment down and just stole ur comment instead. The nuisance can be left to the discussions in the linked issue. |
@bors r+ |
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#134463 (compiletest: don't register predefined `MSVC`/`NONMSVC` FileCheck prefixes) - rust-lang#134487 (Add reference annotations for the `coverage` attribute) - rust-lang#134497 (coverage: Store coverage source regions as `Span` until codegen (take 2)) - rust-lang#134502 (Update std libc version to 0.2.169) - rust-lang#134506 (Remove a duplicated check that doesn't do anything anymore.) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#134463 (compiletest: don't register predefined `MSVC`/`NONMSVC` FileCheck prefixes) - rust-lang#134487 (Add reference annotations for the `coverage` attribute) - rust-lang#134497 (coverage: Store coverage source regions as `Span` until codegen (take 2)) - rust-lang#134502 (Update std libc version to 0.2.169) - rust-lang#134506 (Remove a duplicated check that doesn't do anything anymore.) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#134463 (compiletest: don't register predefined `MSVC`/`NONMSVC` FileCheck prefixes) - rust-lang#134487 (Add reference annotations for the `coverage` attribute) - rust-lang#134497 (coverage: Store coverage source regions as `Span` until codegen (take 2)) - rust-lang#134502 (Update std libc version to 0.2.169) - rust-lang#134506 (Remove a duplicated check that doesn't do anything anymore.) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#134463 - jieyouxu:filecheck-prefix, r=Zalathar compiletest: don't register predefined `MSVC`/`NONMSVC` FileCheck prefixes This was fragile as it was based on host target passed to compiletest, but the user could cross-compile and run test for a different target (e.g. cross from linux to msvc, but msvc won't be set on the target). Furthermore, it was also very surprising as normally revision names (other than `CHECK`) was accepted as FileCheck prefixes. This partially reverts the `MSVC`/`NONMSVC` predefined FileCheck prefix registration introduced historically for some codegen tests. This makes some codegen tests more verbose since they now need to explicitly introduce `MSVC`/`NONMSVC` revisions, but I think that's less surprising, e.g.: ```rs //@ revisions: MSVC NONMSVC //`@[MSVC]` only-msvc //`@[NONMSVC]` ignore-msvc ``` Note that revisions are not *only* FileCheck prefixes in FileCheck-based test suites, as they also can be used to conditionally apply certain compiletest directives. r? `@Zalathar` (or reroll a `r/? compiletest` reviewer) try-job: x86_64-msvc try-job: i686-msvc try-job: x86_64-mingw-1 try-job: i686-mingw
This was fragile as it was based on host target passed to compiletest,
but the user could cross-compile and run test for a different target
(e.g. cross from linux to msvc, but msvc won't be set on the target).
Furthermore, it was also very surprising as normally revision names
(other than
CHECK
) was accepted as FileCheck prefixes.This partially reverts the
MSVC
/NONMSVC
predefined FileCheckprefix registration introduced historically for some codegen tests.
This makes some codegen tests more verbose since they now need to
explicitly introduce
MSVC
/NONMSVC
revisions, but I think that'sless surprising, e.g.:
Note that revisions are not only FileCheck prefixes in
FileCheck-based test suites, as they also can be used
to conditionally apply certain compiletest directives.
r? @Zalathar (or reroll a
r/? compiletest
reviewer)try-job: x86_64-msvc
try-job: i686-msvc
try-job: x86_64-mingw-1
try-job: i686-mingw