Skip to content

Commit

Permalink
Test cache invalidation with basename rather than path
Browse files Browse the repository at this point in the history
To avoid these problems on Windows platforms:

```
actual vs expected
- "../../../../../../../../../RCompile/CRANpkg/local/4.3/pkgload.Rcheck/tests/testthat/testHelp/man/foofoo.Rd"
+ "foofoo.Rd"
── Failure ('test-help.R:85'): shim_help and shim_questions works if topic moves ──
rel_rd_path(shim_question("foofoo")) (`actual`) not equal to "foofoo.Rd" (`expected`).

actual vs expected
- "../../../../../../../../../RCompile/CRANpkg/local/4.3/pkgload.Rcheck/tests/testthat/testHelp/man/foofoo.Rd"
+ "foofoo.Rd"
── Failure ('test-help.R:93'): shim_help and shim_questions works if topic moves ──
rel_rd_path(shim_help("foofoo")) (`actual`) not equal to "barbar.Rd" (`expected`).

actual vs expected
- "../../../../../../../../../RCompile/CRANpkg/local/4.3/pkgload.Rcheck/tests/testthat/testHelp/man/barbar.Rd"
+ "barbar.Rd"
── Failure ('test-help.R:94'): shim_help and shim_questions works if topic moves ──
rel_rd_path(shim_question("foofoo")) (`actual`) not equal to "barbar.Rd" (`expected`).

actual vs expected
- "../../../../../../../../../RCompile/CRANpkg/local/4.3/pkgload.Rcheck/tests/testthat/testHelp/man/barbar.Rd"
+ "barbar.Rd"
```
  • Loading branch information
lionel- committed Nov 14, 2022
1 parent b7494dd commit 27c11f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# pkgload (development version)

* Fixes for CRAN checks.


# pkgload 1.3.1

* `dev_topic_find()` is now exported (#215).
Expand Down
12 changes: 5 additions & 7 deletions tests/testthat/test-help.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,19 @@ test_that("shim_help and shim_questions works if topic moves", {
on.exit(unload(test_path('testHelp')))

path_man <- test_path("testHelp/man/")
rel_rd_path <- function(x) {
as.character(fs::path_rel(x$path, path_man))
}
base_rd_path <- function(x) basename(x$path)

expect_equal(rel_rd_path(shim_help("foofoo")), "foofoo.Rd")
expect_equal(rel_rd_path(shim_question("foofoo")), "foofoo.Rd")
expect_equal(base_rd_path(shim_help("foofoo")), "foofoo.Rd")
expect_equal(base_rd_path(shim_question("foofoo")), "foofoo.Rd")

fs::file_move(fs::path(path_man, "foofoo.Rd"), fs::path(path_man, "barbar.Rd"))
on.exit(
fs::file_move(fs::path(path_man, "barbar.Rd"), fs::path(path_man, "foofoo.Rd")),
add = TRUE
)

expect_equal(rel_rd_path(shim_help("foofoo")), "barbar.Rd")
expect_equal(rel_rd_path(shim_question("foofoo")), "barbar.Rd")
expect_equal(base_rd_path(shim_help("foofoo")), "barbar.Rd")
expect_equal(base_rd_path(shim_question("foofoo")), "barbar.Rd")
})

test_that("dev_help works with package and function help with the same name", {
Expand Down

0 comments on commit 27c11f6

Please sign in to comment.