Skip to content

Commit

Permalink
Fix find_package_root() for relative paths
Browse files Browse the repository at this point in the history
Paths that need to be normalized were wrong.
  • Loading branch information
gaborcsardi committed Nov 20, 2023
1 parent fd19ffb commit 5762e2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/find-package-root.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ find_package_root <- function(path = ".") {
if (!file.exists(path)) {
stop("Path does not exist: ", path)
}
cur_path <- path
cur_path <- normalizePath(path, winslash = "/")
errmsg <- paste0(
"Could not find R package in `",
path,
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-find-package-root.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ test_that("find_package_root", {
)),
lns
)

wd <- getwd()
on.exit(setwd(wd), add = TRUE)
setwd(file.path(tmp, "a", "b", "c"))
expect_equal(
readLines(file.path(find_package_root("."), "DESCRIPTION")),
lns
)
})

test_that("find_package_root errors", {
Expand Down

0 comments on commit 5762e2f

Please sign in to comment.