Skip to content

add a series of tests for help completeness - #1023

Merged
AshesITR merged 7 commits into
masterfrom
tag-consistency
Mar 30, 2022
Merged

AshesITR merged 7 commits into
masterfrom
tag-consistency

Conversation

@MichaelChirico

Copy link
Copy Markdown
Collaborator

Closes #916

The tests themselves are a bit of an ugly/unreadable mess. Hopefully the liberal use of info= helps out future readers/devs.

Comment thread tests/testthat/test-linter_tags.R Resolved
Comment on lines +53 to +57
expect_identical(
length(gregexpr(linter_item_regex, linter_help_text)[[1L]]),
nrow(lintr_db),
info = "Count of linter entries in ?linters matches inst/lintr/linters.csv row count"
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Both are sorted, so if we add a capture group for the linter function name, we could use expect_equal() which would provide us with the offending linters. WDYT?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Seems a bit fragile to me since the sorting is coming from different origins.

How about capture group + sort() here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

PTAL. hopefully easier to understand with the new approach. And moreover, it already worked -- it caught that the count for consistency_linters is out of date :)

Comment on lines +71 to +75
expect_identical(
length(gregexpr(tag_item_regex, tag_help_text[[tag]])[[1L]]),
tag_table[[tag]],
info = paste0("Count of linter entries in ?", tag, "_linters matches tags given in inst/lintr/linters.csv")
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ibid.

Comment thread tests/testthat/test-linter_tags.R Outdated
Comment on lines +79 to +80
# NB: matching tags requires reproducing the "platform-independent sort" we do; instead, rely on the other tests
# for matching the tags

@AshesITR AshesITR Mar 29, 2022 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

WDYT about sorting the tags in available_linters()? That would guarantee sortedness (is that even a word?) here and allow rd_tags() to rely on sorted tags. (Could be a separate PR if you want)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I have kind-of been writing the tags in relevance order, which makes more sense to me than alphabetical. Don't think it makes much sense to over-orient ourselves to making the test easier to write.

capture group + sort in the test would be better.

)

db_tag_table <- as.data.frame(
table(tag = unlist(lintr_db$tags)),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Curious: What will happen if we accidentally provide a tag twice in linters.csv?

@AshesITR
AshesITR merged commit ab5ab94 into master Mar 30, 2022
@MichaelChirico
MichaelChirico deleted the tag-consistency branch March 30, 2022 16:25
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.

Create tests for completeness of documentation

2 participants