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

Add a test for WARNINGS.md #660

Merged
merged 5 commits into from
Jul 12, 2019
Merged

Add a test for WARNINGS.md #660

merged 5 commits into from
Jul 12, 2019

Conversation

vladmos
Copy link
Member

@vladmos vladmos commented Jun 21, 2019

All warnings contain a link to https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#<category_name>, the new test ensures that all registered warnings are documented in the file (at least that there's a link in the header and an anchor for each warning).

Copy link
Contributor

@laurentlb laurentlb left a comment

Choose a reason for hiding this comment

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

Nice!

LGTM

for _, warning := range AllWarnings {
link := fmt.Sprintf(" * [%s](#%s)", warning, warning)
if !strings.Contains(contents, link) {
t.Errorf("No link found for the warning %q in WARNINGS.md, is it documented?", warning)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit. the error message should include the pattern you match (link).

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.


anchor := fmt.Sprintf(`<a name="%s"></a>`, warning)
if !strings.Contains(contents, anchor) {
t.Errorf("No anchor found for the warning %q in WARNINGS.md, is it documented?", warning)
Copy link
Contributor

Choose a reason for hiding this comment

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

here, include anchor

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@vladmos vladmos merged commit d7ccc55 into bazelbuild:master Jul 12, 2019
@vladmos vladmos deleted the doc_test branch July 12, 2019 11:14
cristiancreteanu pushed a commit to cristiancreteanu/buildtools that referenced this pull request Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants