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: warn if we see a // @<directive-name> #125813

Open
jieyouxu opened this issue May 31, 2024 · 20 comments
Open

compiletest: warn if we see a // @<directive-name> #125813

jieyouxu opened this issue May 31, 2024 · 20 comments
Labels
A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@jieyouxu
Copy link
Member

Realized in #125808 (comment).

A test writer might accidentally write

// @ignore-cross-compile

which is parsed as a normal comment not a compiletest directive because compiletest directives require that the line starts with //@.

This typo is hard to spot: both by PR authors and the reviewers. It might not fail in PR CI -- it might not even fail in full build CI, but then explode when the conditions are just right.

We should detect these and issue at least warnings from compiletest to help test writers realize the problem.

@jieyouxu jieyouxu added A-testsuite Area: The testsuite used to check the correctness of rustc T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-compiletest Area: The compiletest test runner labels May 31, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 31, 2024
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 31, 2024
@GuillaumeGomez
Copy link
Member

Gonna take a look at it.

@fmease
Copy link
Member

fmease commented May 31, 2024

This should obviously skip tests/rustdoc/ and tests/rustdoc-json/ as // @ (\s@ to be precise) mark the start of {Html,Json}DocCk directives.

@jieyouxu
Copy link
Member Author

Gonna take a look at it.

It might be worth waiting on some directive handling reworks (not concrete design and plan just yet unfortunately) I've been wanting to do

@jieyouxu
Copy link
Member Author

jieyouxu commented May 31, 2024

This should obviously skip tests/rustdoc/ and tests/rustdoc-json/ as // @ (\s@ to be precise) mark the start of {Html,Json}DocCk directives.

Huh, many thanks for the heads up, I was not aware that we had these kind of directives lol

@ChrisDenton
Copy link
Member

That seems confusing? Could that be changed?

@GuillaumeGomez
Copy link
Member

yes, just need someone to do it (I can if you want?).

@fmease
Copy link
Member

fmease commented May 31, 2024

That seems confusing? Could that be changed?

Yes, it can. Coincidentally, I've started rewriting htmldocck.py from Python into Rust (for increased maintainability, extensibility and in order to finally use the latest version of XPath). See #125780.

The easiest solution would be to just register HtmlDocCk & JsonDockCk directives in compiletest and change the syntax accepted by src/tools/{html,json}docck/.

@jieyouxu
Copy link
Member Author

That seems confusing? Could that be changed?

I think that is a symptom of a more general problem: historically compiletest directives used //, so test-mode/test-suite-specific directives had more syntax built upon just regular //. This is also the case for codegen tests: compiletest directives use //@ but filecheck directives (or annotations) use // again because the directives are implemented separately...
I think mir-opt tests(?) or another test suite has test suite specific directives with // yet again...

@fmease
Copy link
Member

fmease commented May 31, 2024

yes, just need someone to do it (I can if you want?).

I will definitely assign myself to the HtmlDocCk side of things given I've been working on it off and on for 3 weeks lol

@jieyouxu
Copy link
Member Author

jieyouxu commented May 31, 2024

An alternative solution is for test-suite-specific directives to also use the new compiletest directive start //@: so tests/rustdoc annotations might be //@ @has which is now unambiguous.

I think this is probably more preferrable, because e.g. it allows filecheck directives to become //@ CHECK-LABEL instead of plain // CHECK-LABEL.

@fmease
Copy link
Member

fmease commented May 31, 2024

The easiest solution would be to just register HtmlDocCk & JsonDockCk directives in compiletest and change the syntax accepted by src/tools/{html,json}docck/.

The cleanest solution (long-term) would be to allow subtools to "register hooks"

@fmease
Copy link
Member

fmease commented May 31, 2024

An alternative solution is for test-suite-specific directives to also use the new compiletest directive start //@: so tests/rustdoc annotations might be //@ @has which is now unambiguous.

that would also be an option, I don't know if I like it visually lol

@jieyouxu
Copy link
Member Author

Yeah, I'm not saying it's the most visually appealing thing ever :3 Having test suites being able to register suite-specific directives via hooks would be very cool, maybe ui_test supports it already? I haven't checked.

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented May 31, 2024

yes, just need someone to do it (I can if you want?).

I will definitely assign myself to the HtmlDocCk side of things given I've been working on it off and on for 3 weeks lol

I completely forgot you were working on it even though we talked about it recently. ><

Then I'll let you handle the html test side.

@fmease
Copy link
Member

fmease commented May 31, 2024

Btw, I don't think we should block "warn if we see a // @<directive-name>" on the hypothetical refactoring of the way we deal with (compiletest-foreign) directives from child test runners.

I'm fine with blocking this enhancement on "some directive handling reworks […] [jieyouxu has] been wanting to do" (#125813 (comment)). Namely #123765 I presume.

@fmease fmease added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label May 31, 2024
@jieyouxu
Copy link
Member Author

Btw, I don't think we should block "warn if we see a // @<directive-name>" on the hypothetical refactoring of the way we deal with (compiletest-foreign) directives from child test runners.

I'm fine with blocking this enhancement on "some directive handling reworks […] [jieyouxu has] been wanting to do" (#125813 (comment)). Namely #123765 I presume.

To be fair, I don't want to block this on that either -- it's okay if someone wanted to improve this, the refactoring can account for this warning too.

@fmease fmease removed the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label May 31, 2024
@jieyouxu
Copy link
Member Author

The progress on that is I'm trying to have a couple reading passes over compiletest to better understand what we currently do and then try to come up with how we can handle directives in a more robust way.

@workingjubilee
Copy link
Member

An alternative solution is for test-suite-specific directives to also use the new compiletest directive start //@: so tests/rustdoc annotations might be //@ @has which is now unambiguous.

I think this is probably more preferrable, because e.g. it allows filecheck directives to become //@ CHECK-LABEL instead of plain // CHECK-LABEL.

the filecheck directives are processed by the filecheck tool itself, for the majority of cases compiletest gives no special instruction here.

@jieyouxu
Copy link
Member Author

An alternative solution is for test-suite-specific directives to also use the new compiletest directive start //@: so tests/rustdoc annotations might be //@ @has which is now unambiguous.

I think this is probably more preferrable, because e.g. it allows filecheck directives to become //@ CHECK-LABEL instead of plain // CHECK-LABEL.

the filecheck directives are processed by the filecheck tool itself, for the majority of cases compiletest gives no special instruction here.

Ah good point, probably better to leave as-is then

@workingjubilee
Copy link
Member

as stated in #125825:

fwiw despite noting the issue, I think the prefix doesn't matter too much: I reviewed FileCheck's code (as much as I understood it, anyways) and it seems FileCheck is very simple. I don't think it is aware of any comment styles itself. I think it literally just scans for the prefix on a line and assumes you won't introduce code that resembles a FileCheck directive.

bors added a commit to rust-lang-ci/rust that referenced this issue Jun 22, 2024
…-syntax, r=fmease,oli-obk

Migrate rustdoc tests syntax to `//@` (for coherency)

Part of rust-lang#125813.

cc `@jieyouxu`
r? `@fmease`
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 23, 2024
…-syntax, r=<try>

Migrate rustdoc tests syntax to `//@` (for coherency)

Part of rust-lang#125813.

cc `@jieyouxu`
r? `@fmease`

try-job: aarch64-apple
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 23, 2024
…-syntax, r=<try>

Migrate rustdoc tests syntax to `//@` (for coherency)

Part of rust-lang#125813.

cc `@jieyouxu`
r? `@fmease`

try-job: aarch64-apple
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 24, 2024
…-syntax, r=fmease,oli-obk

Migrate rustdoc tests syntax to `//@` (for coherency)

Part of rust-lang#125813.

cc `@jieyouxu`
r? `@fmease`

try-job: aarch64-apple
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 19, 2024
…, r=GuillaumeGomez

Update jsondocck directives to follow ui_test-style

Context: Comment chain in rust-lang#125813.
Follow-up to rust-lang#126788.
Use the same temporary approach of "double parsing" until we figure out how we want to support compiletest/ui_test directive "add-ons" for child test runners like HtmlDocCk and JsonDocCk.

I didn't touch much of jsondocck because I want to refactor it some other time (for robustness, maintainability and better diagnostics; basically by following a similar design of my WIP HtmlDocCk-next, cc rust-lang#125780).

r? `@GuillaumeGomez`
@jieyouxu jieyouxu added E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 17, 2024
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 C-bug Category: This is a bug. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
Development

No branches or pull requests

6 participants