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

Missing snapshots #268

Merged
merged 4 commits into from
Oct 23, 2024
Merged

Missing snapshots #268

merged 4 commits into from
Oct 23, 2024

Conversation

hfrick
Copy link
Member

@hfrick hfrick commented Oct 22, 2024

library(tidyverse)

# https://github.com/r-lib/covr/issues/482
res_tbl <- devtools::test_coverage() |>
  purrr::map(~tibble(
    value = if_else(is.null(.x$value), NA, .x$value), 
    code = as.character(.x$srcref)
  )) |>
  purrr::list_rbind(names_to = "file")

res_tbl |>
  filter(value == 0, str_detect(code, "(cli_abort|cli_warn|cli_inform|abort|warn)")) |>
  arrange(file) |>
  mutate(file = str_extract(file, ".*?:.*?:")) |>
  mutate(file = str_remove(file, ":$")) |>
  pull(file) |>
  cat(sep = "\n")

gives

use.R:130
use.R:134
util.R:17

but the two in use.R are tested in

test_that("`model` can only be a single string", {
expect_snapshot(error = TRUE, create_modeling_package(path = "my/path", model = c("model1", "model2")))
expect_snapshot(error = TRUE, create_modeling_package(path = "my/path", model = 1))
expect_snapshot(error = TRUE, create_modeling_package(path = "my/path", model = "model with space"))
})

and for the one in util.R I opened #267

@hfrick hfrick requested a review from topepo October 22, 2024 19:45
@@ -13,3 +13,14 @@ test_that("`model_matrix()` strips all attributes from the `model.matrix()` resu
# attached "assign" and "contrasts" attributes here
expect_identical(matrix$Speciessetosa, expect)
})

test_that("`contr_one_hot()` input checks", {
expect_snapshot(contr_one_hot(n = 1, sparse = TRUE))
Copy link
Member

Choose a reason for hiding this comment

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

contr_one_hot() is also in parsnip (where it is exported).

There are tests there that are a bit more extensive: https://github.com/tidymodels/parsnip/blob/main/tests/testthat/test-contr_one_hot.R

You can bring those over here and I'll open a parsnip issue about the duplication. hardhat would have to export this function for parsnip to use it.

Copy link
Member

Choose a reason for hiding this comment

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

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 find!! I've opened #271 as a companion to the parsnip issue

@hfrick hfrick merged commit 78cf6d0 into main Oct 23, 2024
11 checks passed
@hfrick hfrick deleted the missing-snapshots branch October 23, 2024 13:04
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.

2 participants