Skip to content

Commit

Permalink
add test-path-fns to cover sub-dir tests for ropensci-review-tools/ro…
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Nov 11, 2024
1 parent 02eb2c6 commit 3103386
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: pkgcheck
Title: rOpenSci Package Checks
Version: 0.1.2.066
Version: 0.1.2.067
Authors@R: c(
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265")),
Expand Down
4 changes: 2 additions & 2 deletions R/path-fns.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ convert_path <- function (path = ".") {
subdirs <- fs::dir_ls (path, type = "directory")
proj_root <- unlist (lapply (subdirs, function (d) {
tryCatch (
rprojroot::find_package_root_file (path = d),
rprojroot::find_root (rprojroot::is_r_package, path = d),
error = function (e) NULL
)
}))
Expand All @@ -41,5 +41,5 @@ convert_path <- function (path = ".") {
)

Check warning on line 41 in R/path-fns.R

View check run for this annotation

Codecov / codecov/patch

R/path-fns.R#L39-L41

Added lines #L39 - L41 were not covered by tests
}

return (proj_root)
return (fs::path (proj_root))
}
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/pkgcheck",
"issueTracker": "https://github.com/ropensci-review-tools/pkgcheck/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.1.2.066",
"version": "0.1.2.067",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/test-path-fns.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
test_that ("pkgcheck", {

pkgname <- paste0 (
sample (c (letters, LETTERS), 8),
collapse = ""
)
pkg_root <- fs::dir_create (fs::path_temp (), pkgname)
path <- fs::dir_create (pkg_root, "subdir")
f_desc <- fs::path (path, "DESCRIPTION")
desc <- system.file ("DESCRIPTION", package = "pkgcheck")
fs::file_copy (desc, f_desc, overwrite = TRUE)
gert::git_init (pkg_root)

path_conv <- convert_path (pkg_root)
expect_identical (path_conv, path)
})

0 comments on commit 3103386

Please sign in to comment.