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 silently fails on a name-value directive with a known name but missing colon but does not report an error #123760

Open
jieyouxu opened this issue Apr 10, 2024 · 5 comments
Assignees
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jieyouxu
Copy link
Member

jieyouxu commented Apr 10, 2024

compiletest expects that a name-value directive, like //@ revisions: foo, to have the colon :

pub fn parse_name_value_directive(&self, line: &str, directive: &str) -> Option<String> {
let colon = directive.len();
if line.starts_with(directive) && line.as_bytes().get(colon) == Some(&b':') {
let value = line[(colon + 1)..].to_owned();
debug!("{}: {}", directive, value);
Some(expand_variables(value, self))
} else {
None
}
}

If the name-value directive contains a known directive name like revisions but does not have the colon (i.e. //@ revisions foo), then:

  • compiletest known directive check accepts the known directive name revisions
  • parse_name_value_directive expects revisions: but only got revisions, so parsing fails
  • no other compiletest directive parsing rules accept revisions directive name
  • no errors raised yet there is no effect (no revisions in this example).

compiletest should not silently fail here because it's very surprising and a pain to debug unless you know exactly what's wrong.

@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. labels Apr 10, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 10, 2024
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 10, 2024
@jieyouxu jieyouxu changed the title compiletest silently accepts a name-value directive with a known name but missing colon compiletest silently accepts a name-value directive with a known name but missing colon but does nothing Apr 10, 2024
@jieyouxu jieyouxu changed the title compiletest silently accepts a name-value directive with a known name but missing colon but does nothing compiletest silently fails on a name-value directive with a known name but missing colon but does not report an error Apr 10, 2024
@jieyouxu
Copy link
Member Author

I think an actual ui test has this problem?

@jieyouxu
Copy link
Member Author

Wait if I change it to //@ revisions: YES NO which actually enables the compile-flags directives, this test still passes. What is this test actually checking then? Maybe it just doesn't actually need the compile-flags?

@fmease
Copy link
Member

fmease commented Apr 10, 2024

Wait if I change it to //@ revisions: YES NO which actually enables the compile-flags directives, this test still passes. What is this test actually checking then? Maybe it just doesn't actually need the compile-flags?

Well, the test “needs” the compile-flags because it's checking that cfg ub_checks is equivalent to cfg debug_assertions for all values of debug_assertions, i.e., yes and no (under the assumption that -Zub-checks wasn't passed which holds). If you remove the flags the test covers fewer cases.

cc #123411 &

"emit runtime checks for Undefined Behavior (default: -Cdebug-assertions)"),

@jieyouxu
Copy link
Member Author

Yeah, I talked to Saethlin, makes sense. It's just compiletest silently failing here is awful 😆

@jieyouxu
Copy link
Member Author

jieyouxu commented Apr 11, 2024

I briefly looked at this, the easy fix is trivial, but the error handling is entirely not maintainable and involves propagating a poisoned: &mut bool status bool through many callsites. The easy fix is like

8mg8j6

I think the directive parsing is long past due for a rework. The error handling needs to not rely on passing a &mut bool around everywhere.

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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
Status: In progress
Development

No branches or pull requests

3 participants