Skip to content

Commit

Permalink
detach pkg_skeletons in tests before unlinking
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Oct 7, 2024
1 parent 24a310e commit fd94f8d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: srr
Title: 'rOpenSci' Review Roclets
Version: 0.1.3.014
Version: 0.1.3.015
Authors@R:
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/ropensci-review-tools/srr",
"issueTracker": "https://github.com/ropensci-review-tools/srr/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.1.3.014",
"version": "0.1.3.015",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-pkg-skeleton.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ test_that ("dummy package", {
expect_true (any (grepl ("\\s\\*\\s\\[RE4\\.4\\]", x)))
expect_true (grep ("\\s\\*\\s\\[RE4\\.4\\]", x) [1] >
grep ("@srrstatsTODO standards \\(", x) [1])

# detach is critical here, because testthat uses `utils::sessionInfo()`,
# which checks namespaces and tries to load DESC file from pkg location.
pos <- match (paste0 ("package:", pkg_name), search ())
if (!is.na (pos)) {
detach (pos = pos, unload = TRUE)
}
unlink (d, recursive = TRUE)
})

Expand All @@ -45,5 +52,9 @@ test_that ("skeleton errors", {
paste0 ("The path \\[", d, "\\] is not empty")
)
}
p <- paste0 ("package:", pkg_name)
if (p %in% search ()) {
detach (p, unload = TRUE)
}
unlink (d, recursive = TRUE)
})

0 comments on commit fd94f8d

Please sign in to comment.