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

Avoid testthat's with_mock function #320

Open
wants to merge 2 commits into
base: cran-backport
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: odin
Title: ODE Generation and Integration
Version: 1.2.6
Version: 1.2.7
Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"),
email = "[email protected]"),
person("Thibaut", "Jombart", role = "ctb"),
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/test-util.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ test_that("Can avoid debug in compile_dll", {
path <- tempfile()
compile_attributes <- TRUE
quiet <- FALSE
res <- with_mock(
"odin::has_user_makevars" = mock_has_user_makevars,
"pkgbuild::compile_dll" = mock_compile_dll,
compile_dll(path, compile_attributes, quiet))
mockery::stub(compile_dll, "has_user_makevars", mock_has_user_makevars)
mockery::stub(compile_dll, "pkgbuild::compile_dll", mock_compile_dll)
res <- compile_dll(path, compile_attributes, quiet)

expect_equal(res[[1]], res[[2]])
expect_equal(normalizePath(dirname(res[[1]])),
Expand All @@ -131,6 +130,7 @@ test_that("Can avoid debug in compile_dll", {

test_that("Don't set envvar if not needed", {
skip_if_not_installed("mockery")
skip_on_cran()

env <- c("R_MAKEVARS_USER" = NA)
cmp <- withr::with_envvar(
Expand All @@ -145,12 +145,12 @@ test_that("Don't set envvar if not needed", {
compile_attributes <- TRUE
quiet <- FALSE

mockery::stub(compile_dll, "has_user_makevars", mock_has_user_makevars)
mockery::stub(compile_dll, "pkgbuild::compile_dll", mock_compile_dll)

res <- withr::with_envvar(
env,
with_mock(
"odin::has_user_makevars" = mock_has_user_makevars,
"pkgbuild::compile_dll" = mock_compile_dll,
compile_dll(path, compile_attributes, quiet)))
compile_dll(path, compile_attributes, quiet))

expect_equal(res[[1]], "")
expect_equal(res[[2]], cmp)
Expand Down
Loading