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

Remove TODOs related to {waldo} update #1518

Merged
merged 10 commits into from
Sep 19, 2022
9 changes: 3 additions & 6 deletions tests/testthat/test-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ test_that("load_cache loads the saved file in a new empty environment", {
save_cache(cache = e1, file = f1, path = d1)
e2 <- load_cache(file = f1, path = d1)

# TODO(michaelchirico): use plain expect_equal after waldo#133 makes it into a CRAN release
expect_equal(as.list(e2, all.names = TRUE), as.list(e1, all.names = TRUE))
expect_equal(e2, e1)
})

test_that("load_cache returns an empty environment if no cache file exists", {
Expand All @@ -73,8 +72,7 @@ test_that("load_cache returns an empty environment if no cache file exists", {
save_cache(cache = e1, file = f1, path = d1)
e2 <- load_cache(file = f2, path = d1)

# TODO(michaelchirico): use plain expect_equal after waldo#133 makes it into a CRAN release
expect_equal(as.list(e2, all.names = TRUE), as.list(e1, all.names = TRUE))
expect_equal(e2, e1)
})

test_that("load_cache returns an empty environment if reading cache file fails", {
Expand Down Expand Up @@ -141,8 +139,7 @@ test_that("save_cache saves all non-hidden objects from the environment", {
e2 <- new.env(parent = emptyenv())
load(file = file.path(d1, fhash(f1)), envir = e2)

# TODO(michaelchirico): use plain expect_equal after waldo#133 makes it into a CRAN release
expect_equal(as.list(e1, all.names = TRUE), as.list(e2, all.names = TRUE))
expect_equal(e2, e1)
})

# `cache_file`
Expand Down
10 changes: 4 additions & 6 deletions tests/testthat/test-with.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,18 @@ test_that("linters_with_defaults warns on unused NULLs", {
test_that("all default linters are tagged default", {
expect_named(linters_with_defaults(), available_linters(tags = "default")$linter)

# TODO(michaelchirico): use plain expect_equal after waldo#133 makes it into a CRAN release
# Here, the environment()s are different because factories use them.
skip_if_not_r_version("4.1.0") # Desired all.equal behaviour only available in >= 4.1
# needed for {waldo} 0.4.0 (containing waldo#133)
skip_if_not_installed("testthat", "3.1.4")
# covr modifies package functions causing differing deparse() results even for identical anonymous functions.
# This happens because default_linters is generated at build time and thus not modifiable by covr, whereas
# linters_with_tags() constructs the linters at runtime.
skip_if(requireNamespace("covr", quietly = TRUE) && covr::in_covr())

# all.equal.default warns on some releases of R if the input is a function, see #1392
expect_silent(result <- all.equal(linters_with_tags("default"), linters_with_defaults()))
expect_true(result)
expect_equal(linters_with_tags("default"), linters_with_defaults())
expect_length(linters_with_tags("default", exclude_tags = "default"), 0L)

# Check that above test also trips on default arguments.
skip_if_not_r_version("4.1.0") # Desired all.equal behaviour only available in >= 4.1
expect_equal(
all.equal(linters_with_tags("default"), linters_with_defaults(line_length_linter(120L))),
'Component "line_length_linter": Component "length": Mean relative difference: 0.5'
Expand Down