Skip to content

Commit

Permalink
remove dependency on mockery
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzwalthert committed Mar 31, 2024
1 parent 15a1ff4 commit 9f4e420
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/hook-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
options(install.packages.compile.from.source = "never", pkgType = "binary")
renv::restore()
# install hook-specific additional_dependencies from .pre-commit-config.yaml
renv::install(c('pkgdown', 'mockery'))
renv::install(c('pkgdown'))
renv::install(getwd(), dependencies = FALSE)
# needed to make sure renv is activated in run_test()
activate <- c(
Expand Down
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Suggests:
glue,
knitr,
lintr,
mockery,
pkgload,
pkgdown,
reticulate (>= 1.16),
Expand Down
4 changes: 2 additions & 2 deletions inst/update-dependency-graph-existing-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ hook_deps <- function(root) {
deps <- desc$get_deps()
dont <- c(
"yaml", "usethis", "withr", "rstudioapi", "precommit",
"pkgdown", "mockery",
"pkgdown",
"httr"
)
out <- c(out, "docopt", "roxygen2", "spelling", "styler", "pkgload", "lintr", "knitr", "desc", "mockery")
out <- c(out, "docopt", "roxygen2", "spelling", "styler", "pkgload", "lintr", "knitr", "desc")
out <- setdiff(c(unique(c(out, deps[deps$type == "Imports", ]$package))), dont)
out <- names(renv:::renv_package_dependencies(out))
return(sort(out))
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-impl-hook-roxygenize.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ test_that("roxygenize works in general", {
local_test_setup(git = FALSE, use_precommit = FALSE, package = TRUE)
writeLines(c("#' This is a title", "#'", "#' More", "#' @name test", "NULL"), "R/blur.R")
# works
mockery::stub(roxygenize_with_cache, "diff_requires_run_roxygenize", TRUE)
local_mocked_bindings(diff_requires_run_roxygenize = function(...) TRUE)
expect_message(
roxygenize_with_cache(list(getwd()), dirs = dirs_R.cache("roxygenize")),
"test\\.Rd"
Expand All @@ -96,7 +96,7 @@ test_that("fails when package is called but not installed in roclets", {
local_test_setup(git = FALSE, use_precommit = FALSE, package = TRUE)
writeLines(c("NULL"), "R/blur.R")
# works
mockery::stub(roxygenize_with_cache, "diff_requires_run_roxygenize", TRUE)
local_mocked_bindings(diff_requires_run_roxygenize = function(...) TRUE)
# when there is a missing package
roxygen_field <- paste0(
'list(markdown = TRUE, roclets = c("rd", "namespace", "collate", "',
Expand All @@ -115,7 +115,7 @@ test_that("fails gratefully when not installed package is called (packageNotFoun
local_test_setup(git = FALSE, use_precommit = FALSE, package = TRUE)
writeLines(generate_uninstalled_pkg_call(), "R/blur.R")
# works
mockery::stub(roxygenize_with_cache, "diff_requires_run_roxygenize", TRUE)
local_mocked_bindings(diff_requires_run_roxygenize = function(...) TRUE)
# when there is a missing package
expect_error(
roxygenize_with_cache(list(getwd()), dirs = dirs_R.cache("roxygenize")),
Expand All @@ -129,7 +129,7 @@ test_that("fails gratefully when not installed package is required according to
desc::desc_set_deps(
tibble::tibble(type = "Imports", package = generate_uninstalled_pkg_name(), version = "*")
)
mockery::stub(roxygenize_with_cache, "diff_requires_run_roxygenize", TRUE)
local_mocked_bindings(diff_requires_run_roxygenize = function(...) TRUE)
expect_error(
suppressWarnings(
roxygenize_with_cache(list(getwd()), dirs = dirs_R.cache("roxygenize"))
Expand All @@ -142,7 +142,7 @@ test_that("fails gratefully when not installed package is required according to
test_that("fails when there is invalid code", {
skip_on_cran()
local_test_setup(git = FALSE, use_precommit = FALSE, package = TRUE)
mockery::stub(roxygenize_with_cache, "diff_requires_run_roxygenize", TRUE)
local_mocked_bindings(diff_requires_run_roxygenize = function(...) TRUE)
# when there is a missing package
writeLines(c("invalid code stuff /3kj"), "R/more.R")
expect_error(
Expand All @@ -154,7 +154,7 @@ test_that("fails when there is invalid code", {
test_that("warns if there is any other warning", {
skip_on_cran()
local_test_setup(git = FALSE, use_precommit = FALSE, package = TRUE)
mockery::stub(roxygenize_with_cache, "diff_requires_run_roxygenize", TRUE)
local_mocked_bindings(diff_requires_run_roxygenize = function(...) TRUE)
writeLines(
c(
"#' This is a title", "#'", "#' More", "#", "NULL"
Expand Down
2 changes: 1 addition & 1 deletion vignettes/available-hooks.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,6 @@ dependencies and system libraries.

For this check, we rely on the the global R package library and require all
development dependencies of the package you want to run this hook for to be
installed, as well as {pkgdown} (without its dependencies) and {mockery}.
installed, as well as {pkgdown} (without its dependencies).

This hook does not modify files. Added in version 0.3.2.9003.

0 comments on commit 9f4e420

Please sign in to comment.