Skip to content

[Docs] Add a section to Diagnostics.md on -verify mode #27448

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

Merged
merged 1 commit into from
Oct 1, 2019

Conversation

owenv
Copy link
Contributor

@owenv owenv commented Sep 30, 2019

As a follow up to adding column specification to the diagnostics verifier I've been meaning to document the // expected- syntax now that it's gotten a bit more complicated. Even though a lot of this can be determined by inspection, I think it's useful to have a short reference for new contributors and people encountering features like {{none}} and * for the first time.

I suppose this could go in Testing.md, but Diagnostics.md seemed like a better fit since it includes more of the relevant terminology.

@owenv
Copy link
Contributor Author

owenv commented Sep 30, 2019

cc @jrose-apple

@jrose-apple
Copy link
Contributor

Looks good to me. I think you're right about Diagnostics.md too, but maybe you could throw a cross-reference into Testing.md?

@owenv owenv force-pushed the verifier_docs branch 2 times, most recently from 4ec3811 to c847ad3 Compare September 30, 2019 23:41
@owenv
Copy link
Contributor Author

owenv commented Sep 30, 2019

@jrose-apple sounds good to me, done!

@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test and merge

@jrose-apple jrose-apple self-assigned this Sep 30, 2019

- (Required) The expected error message. The message should be enclosed in double curly braces and should not include the `error:`/`warning:`/`note:`/`remark:` prefix. For example, `// expected-error {{invalid redeclaration of 'y'}}` would match an error with that message on the same line. The expected message will match so long as it's a substring of the message which is emitted.

- (Optional) Expected fix-its. These are each enclosed in double curly braces and appear after the expected message. An expected fix-it consists of a column range followed by the text it's expected to be replaced with. For example, `let r : Int i = j // expected-error{{consecutive statements}} {{12-12=;}}` will match a fix-it attached to the consecutive statements error which inserts a semicolon at column 12, just after the 't' in 'Int'. The special {{none}} specifier is also supported, which will cause the diagnostic match to fail if unexpected fix-its are produced.
Copy link
Collaborator

@theblixguy theblixguy Oct 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m still confused about this - the error is consecutive statements on a line must be separated by ';', but it seems you can just enter the first few words to match it. Does it only apply to errors/warnings/notes that are unique (i.e unique prefix perhaps?) or is there something else you need to do for this to work? I think we should document it as well.

Copy link
Contributor Author

@owenv owenv Oct 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I referenced that briefly above: "The expected message will match so long as it's a substring of the message which is emitted.". In practice I think it's only ever used to match a prefix, so I may look into tightening that restriction if it doesn't require updating too many tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I clarified this a little more in the meantime to hopefully avoid confusion though.

Copy link
Collaborator

@theblixguy theblixguy Oct 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think we should match unique prefixes otherwise if you had two or more diagnostics with the same prefix then it won’t be clear which one is being referred to in the tests.

(although I haven’t seen many tests utilising this and the ones that are don’t seem to conflict with other diagnostics so I’m not sure if this is really a problem, at least for now).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's definitely just matching a substring, not a prefix. Sometimes the interesting words in a diagnostic are in the middle, and/or you don't want to copy out a whole type or something when it's not relevant to the test.

@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test

@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test macOS

@jrose-apple jrose-apple merged commit 3afbe31 into swiftlang:master Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants