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

Review use of expect_snapshot() and friends #2532

Merged
merged 7 commits into from
May 13, 2024
Merged

Review use of expect_snapshot() and friends #2532

merged 7 commits into from
May 13, 2024

Conversation

hadley
Copy link
Member

@hadley hadley commented May 10, 2024

  • Don't use it just to suppress output
  • Convert expect_snapshot_error() to expect_snapshot()

Fixes #2528

* Don't use it just to suppress output
* Convert `expect_snapshot_error()` to `expect_snapshot()`

Fixes #2528
@hadley hadley requested a review from maelle May 10, 2024 16:55
Copy link

github-actions bot commented May 10, 2024

Copy link
Collaborator

@maelle maelle left a comment

Choose a reason for hiding this comment

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

why not put the expect_snapshot_error()/expect_snapshot_warning() in a separate PR/commit? 😉

@@ -45,7 +45,7 @@ test_that("articles don't include header-attrs.js script", {
pkg <- as_pkgdown(test_path("assets/articles"))
withr::defer(clean_site(pkg, quiet = TRUE))

expect_snapshot(path <- build_article("standard", pkg))
suppressMessages(path <- build_article("standard", pkg))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wish there could be an option set with withr, so that the code wouldn't be nested inside supressMessages().

Copy link
Member Author

Choose a reason for hiding this comment

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

We might get there one day, but I think that's still quite a lot of refactoring away.

@@ -66,39 +66,46 @@ test_that("default reference includes all functions", {
})

test_that("errors well when a content entry is empty", {
meta <- yaml::yaml.load( "reference:\n- title: bla\n contents:\n - aname\n - ")
pkg <- as_pkgdown(test_path("assets/reference"), override = meta)
meta <- yaml::yaml.load("reference:\n- title: bla\n contents:\n - aname\n - ")
Copy link
Collaborator

Choose a reason for hiding this comment

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

no need to load, since local_pkgdown_site() can use meta as either character or list.

In another test file I saw

  pkg <- local_pkgdown_site(test_path("assets/articles"), "
    template:
      bootstrap: 5
  ")

which is more readable than the \n, although it might be awkward with the indentation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

if not using the same "style" as above, I think I'd find seeing the list directly more readable than the \n.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah good catch; I forgot to update this older style.

@hadley hadley merged commit 1b2508f into main May 13, 2024
13 checks passed
@hadley hadley deleted the expect-snapshot branch May 13, 2024 15:16
SebKrantz pushed a commit to SebKrantz/pkgdown that referenced this pull request Jun 1, 2024
* Don't use it just to suppress output
* Convert `expect_snapshot_error()` to `expect_snapshot()`

Fixes r-lib#2528
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.

Review uses of expect_snapshot()
2 participants