Repository navigation
compiletest has some parsing footguns around revisions #123765
Copy link
Copy link
Open
Labels
A-compiletestArea: The compiletest test runnerArea: The compiletest test runnerA-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcC-bugCategory: This is a bug.Category: This is a bug.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Activity
- addedA-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.C-bugCategory: This is a bug.Category: This is a bug.
on Apr 11, 2024 - addedneeds-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
on Apr 11, 2024 - addedP-lowLow priorityLow priorityand removedneeds-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
on Apr 11, 2024 Furthermore, if I remember correctly, in
//@[a,b] xyzthe revision gets parsed as a single revision literally calleda,bwhile in error annotations like//[a,b]~ ERROR message, it gets parsed as the two revisionsaandb.In the first case we should either emit a better error or actually parse multiple revisions, too (it's kinda useful :P).
- moved this from Needs Triage / Backlog to Ready in compiletest maintenance and improvements
on May 29, 2024 - addedA-compiletestArea: The compiletest test runnerArea: The compiletest test runner
on May 29, 2024 - moved this from Ready to In progress in compiletest maintenance and improvements
on May 31, 2024 - moved this from In progress to Ready in compiletest maintenance and improvements
on May 31, 2024 Since revision names have almost no validation, you can do cursed things like this:
//@ no-auto-check-cfg //@ check-pass //@ revisions: rev="ision" #[cfg(rev = "ision")] fn main() {}
And for
{check,build}-failtest files with such kinds of names, it would indeed generate stderr files at paths likedummy.rev="ision".stderr.Very cursed :)
Reacted by 许杰友 Jieyou Xu (Joe)I... yeah.
Metadata
Metadata
Assignees
Labels
A-compiletestArea: The compiletest test runnerArea: The compiletest test runnerA-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcC-bugCategory: This is a bug.Category: This is a bug.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
- StatusShow more project fieldsBacklog
I've chatted with @jieyouxu and we've come to the conclusion that it's worthwhile to track
compiletestissues even though we plan on fully migrating toui_testeventually since that might still take a while.When parsing the
revisionsheader / directive,compiletestnaively splits the payload by whitespace leading to the bizarre situation that//@ revisions: foo, bargets understood as declaring the two revisionsfoo,(notice the trailing comma!) andbar.We should either throw an error (my favored solution) or permit
,to be valid separator next to whitespace (less desirable in my opinion).If we go with the first approach we should probably go all-in and restrict revision names to the regex
[[:alpha:]_\-][[:alnum:]_\-]*(*) (ASCII-only or Unicode, shouldn't matter) and we can probably also emit the hint “commas not permitted, use whitespace” if we stumble upon a comma.(*) Restricting the grammar of revision names also helps with portability. Windows is way stricter about file paths than *nix OSes and since
compiletestgenerates files of the form<STEM>.<REVISION>.<STDSTREAM>revisions containing special characters may lead to tests passing locally for a contributor working on a *nix machine but failing on a Windows machine. CI would catch that but still ^^'Similarly,
compiletestpermits whatever garbage you put between[and]in//@[...] DIRECTIVE, even//@[]is allowed. We should probably restrict the content to be identifier-like, too.