-
Notifications
You must be signed in to change notification settings - Fork 360
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
More robust comment parsing #2332
Conversation
☔ The latest upstream changes (presumably #2335) made this pull request unmergeable. Please resolve the merge conflicts. |
ui_test/src/comments.rs
Outdated
|
||
/// Parse comments in `content`. | ||
/// `path` is only used to emit diagnostics if parsing fails. | ||
pub(crate) fn parse(path: &Path, content: &str) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to keep maintaining all this code.
(or in fact, turn them into errors so that accidental usage of old-style comments will be detected)
If you want to do that, please just use a single regex like // *(compiler?-flag|only-|ignore-)
and warn/error when that matches. We don't need the full parser for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but I want to keep it around until we ported all the tests and only remove it then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the issue with just porting them all now?
I don't like having so many dead code paths here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was assuming it's just a fairly simple global search-and-replace to add all those @
.
But if you prefer I can also live with doing this in steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly because it's very conflict prone and I'd have to rebase too often ^^
ui_test/src/comments.rs
Outdated
this | ||
|
||
if let Some(s) = command.strip_prefix("only-") { | ||
self.only.push(Condition::parse(s)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that Condition::parse
can panic... now that you have error reporting here it'd be nice to also use that for incorrect conditions.
For proper reliable parsing, I think ignore-windows
should become ignore-target-windows
, otherwise we have the same problem again of having some special commands (ignore-debug, ignore-32bit) and then silently falling back to another way of interpreting the command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. For minimal churn I want to change as little as possible until we rip out the old logic and then improve the parser step by step.
The new attribute parsing errors now look like
(plus some terminal coloring for readability) |
I am confused by that error. There are two locations there, which one is it at? And why does error 0 have a filename and line but error 1 not? |
the "Location" is the place in ui testing where the error was raised the list is a sort of backtrace of information. This helps avoid passing down all the information, as each bubbling up can attach information in the failure case instead of pushing information in |
Okay. For user-visible errors I don't think we want to show any of our internal source code locations by default. IMO basically we should either panic ("we don't care, just report the error somehow") or do it properly... going half-way doesn't seem worth the effort? |
☔ The latest upstream changes (presumably #2345) made this pull request unmergeable. Please resolve the merge conflicts. |
done, we show a message about RUST_BACKTRACE, but nothing else by default
it's not multiple errors. this is the "spantrace" for a single error. So whenever we call a function, we can attach some information to the failure-path on that function call. To showcase this, I only added information to the
then we get more entries in that list, telling us exactly how we got to the error. |
… comments in the same files
... that grabs things from the front instead of splitting at spaces and colons and hoping for the best
@bors r+ |
☀️ Test successful - checks-actions |
fixes #2170
I haven't ported the entire test suite yet. Once we've done that, I will remove the old parsing system (or in fact, turn them into errors so that accidental usage of old-style comments will be detected)