From 9f4e420d7d1456d722f9f43af92eec15f56d7ff5 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sun, 31 Mar 2024 21:22:33 +0800 Subject: [PATCH] remove dependency on mockery --- .github/workflows/hook-tests.yaml | 2 +- DESCRIPTION | 1 - inst/update-dependency-graph-existing-packages.R | 4 ++-- tests/testthat/test-impl-hook-roxygenize.R | 12 ++++++------ vignettes/available-hooks.Rmd | 2 +- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index f286bdfbb..2e6bb9cd9 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -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( diff --git a/DESCRIPTION b/DESCRIPTION index 0641480a4..7d0f3871d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,7 +29,6 @@ Suggests: glue, knitr, lintr, - mockery, pkgload, pkgdown, reticulate (>= 1.16), diff --git a/inst/update-dependency-graph-existing-packages.R b/inst/update-dependency-graph-existing-packages.R index d63781cab..a18bc8e63 100644 --- a/inst/update-dependency-graph-existing-packages.R +++ b/inst/update-dependency-graph-existing-packages.R @@ -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)) diff --git a/tests/testthat/test-impl-hook-roxygenize.R b/tests/testthat/test-impl-hook-roxygenize.R index 1c2768ada..eb79361e3 100644 --- a/tests/testthat/test-impl-hook-roxygenize.R +++ b/tests/testthat/test-impl-hook-roxygenize.R @@ -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" @@ -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", "', @@ -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")), @@ -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")) @@ -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( @@ -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" diff --git a/vignettes/available-hooks.Rmd b/vignettes/available-hooks.Rmd index 572fd2e52..47b5720e1 100644 --- a/vignettes/available-hooks.Rmd +++ b/vignettes/available-hooks.Rmd @@ -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.