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

compiletest: don't register predefined MSVC/NONMSVC FileCheck prefixes #134463

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Dec 18, 2024

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.:

//@ 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

@jieyouxu jieyouxu added the A-compiletest Area: The compiletest test runner label Dec 18, 2024
@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 Dec 18, 2024
@jieyouxu jieyouxu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 18, 2024
@jieyouxu
Copy link
Member Author

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 18, 2024
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
@bors
Copy link
Contributor

bors commented Dec 18, 2024

⌛ Trying commit 2b41c9d with merge 48416db...

@rust-log-analyzer

This comment has been minimized.

Comment on lines 1964 to 1970
// 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.
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

@jieyouxu jieyouxu Dec 19, 2024

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:

  1. Use revisions but ONLY for compiletest directive purposes.
  2. Use revisions but ONLY for filecheck prefix purposes.
  3. Use revisions for BOTH.

You are saying, that we should actually properly have an orthogonal set, something like //@ filecheck-prefixes: MSVC NONMSVC etc. right?

Copy link
Member Author

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.

Copy link
Member Author

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.

@jieyouxu
Copy link
Member Author

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 18, 2024
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
@bors
Copy link
Contributor

bors commented Dec 18, 2024

⌛ Trying commit 2b41c9d with merge 1ec0d13...

@bors
Copy link
Contributor

bors commented Dec 18, 2024

☀️ Try build successful - checks-actions
Build commit: 1ec0d13 (1ec0d13e414e1cfd2cc727c342eb86a7e0326e3a)

@jieyouxu
Copy link
Member Author

Rebased to add clarifying comments as requested in #134463 (comment), no functional changes.

@jieyouxu
Copy link
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 19, 2024
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.
@jieyouxu
Copy link
Member Author

Trimmed the comment down and just stole ur comment instead. The nuisance can be left to the discussions in the linked issue.

@Zalathar
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Dec 19, 2024

📌 Commit 5415f06 has been approved by Zalathar

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 Dec 19, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 19, 2024
…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
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 19, 2024
…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
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 19, 2024
…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
@bors bors merged commit b978498 into rust-lang:master Dec 20, 2024
6 checks passed
@rustbot rustbot added this to the 1.85.0 milestone Dec 20, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 20, 2024
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
@jieyouxu jieyouxu deleted the filecheck-prefix branch December 20, 2024 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc 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.

5 participants