Skip to content

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

Closed

Description

@jieyouxu

View all comments

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.

Activity

  1. added
    A-testsuiteArea: The testsuite used to check the correctness of rustc
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    A-compiletestArea: The compiletest test runner
    on May 31, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 31, 2024
  3. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 31, 2024
  4. GuillaumeGomez commented on May 31, 2024

    @GuillaumeGomez
    Member

    Gonna take a look at it.

  5. fmease commented on May 31, 2024

    @fmease
    Member

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

  6. jieyouxu commented on May 31, 2024

    @jieyouxu
    MemberAuthor

    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

  7. jieyouxu commented on May 31, 2024

    @jieyouxu
    MemberAuthor

    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

  8. ChrisDenton commented on May 31, 2024

    @ChrisDenton
    Member

    That seems confusing? Could that be changed?

  9. GuillaumeGomez commented on May 31, 2024

    @GuillaumeGomez
    Member

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

  10. fmease commented on May 31, 2024

    @fmease
    Member

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

  11. 13 remaining items

  12. jieyouxu commented on May 31, 2024

    @jieyouxu
    MemberAuthor

    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

  13. workingjubilee commented on Jun 1, 2024

    @workingjubilee
    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.

  14. added 4 commits that reference this issue on Jun 22, 2024
  15. added a commit that references this issue on Jul 19, 2024
  16. added
    E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.
    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
    and removed
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Oct 17, 2024
  17. self-assigned this
    on Nov 7, 2026
  18. added a commit that references this issue on Nov 7, 2026
  19. added a commit that references this issue on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-compiletestArea: The compiletest test runnerA-testsuiteArea: The testsuite used to check the correctness of rustcC-bugCategory: This is a bug.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions