Skip to content

Commit 4c944a4

Browse files
committed
test: replace here::here() with system.file() so tests resolve under R CMD check
here::here("DESCRIPTION") doesn't anchor to the package when R CMD check copies it to a temp dir lacking project markers, causing get_description, get_hex, and infer_biocviews tests to fail. system.file() works in both devtools::test() (source tree) and R CMD check (installed copy).
1 parent c34eeaa commit 4c944a4

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

tests/testthat/test-get_description.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ test_that("get_description works", {
2222
paths="typo")
2323
d6 <- get_description(refs=NULL,
2424
paths="typo")
25-
d7 <- get_description(refs=NULL,
26-
paths=here::here("DESCRIPTION")
25+
d7 <- get_description(refs=NULL,
26+
paths=system.file("DESCRIPTION", package="rworkflows")
2727
)
2828
d8 <- get_description(refs=c("stats","data.table"),
2929
paths=NULL)

tests/testthat/test-get_hex.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ test_that("get_hex works", {
88
testthat::expect_equal(hex2$rworkflows,
99
hex1$`neurogenomics/rworkflows`)
1010
#### When DESCRIPTION path provided ####
11-
hex3 <- get_hex(refs=NULL,
12-
paths=here::here("DESCRIPTION"))
11+
hex3 <- get_hex(refs=NULL,
12+
paths=system.file("DESCRIPTION", package="rworkflows"))
1313
testthat::expect_equal(hex3[[1]],
1414
hex1[[1]])
1515
#### When neither refs nor paths provided ####

tests/testthat/test-infer_biocviews.R

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
test_that("infer_biocviews works", {
22
if (!is_gha()) testthat::skip_if_offline(host = "bioconductor.org")
33

4-
# Don't run simply bc biocViews::recommendBiocViews is unable
5-
## to find the DESCRIPTION file when running examples.
6-
# biocviews1 <- infer_biocviews(pkgdir = "../../")
7-
# testthat::expect_equal(biocviews1,"Software")
8-
9-
testthat::expect_equal(infer_biocviews(include_branch = FALSE),
4+
# Resolve a pkgdir that contains DESCRIPTION in both devtools::test()
5+
# (source dir) and R CMD check (installed copy in temp library), since
6+
# here::here() doesn't anchor to the package under R CMD check.
7+
pkgdir <- dirname(system.file("DESCRIPTION", package = "rworkflows"))
8+
9+
testthat::expect_equal(infer_biocviews(pkgdir = pkgdir,
10+
include_branch = FALSE),
1011
c("Software","WorkflowManagement"))
1112
biocviews_manual = c("Software","Genetics","Transcriptomics")
12-
testthat::expect_equal(infer_biocviews(biocviews = biocviews_manual),
13+
testthat::expect_equal(infer_biocviews(pkgdir = pkgdir,
14+
biocviews = biocviews_manual),
1315
c(biocviews_manual,"WorkflowManagement"))
1416

1517
#### Errors ####

0 commit comments

Comments
 (0)