Skip to content

Commit

Permalink
invoke package installation in separate R process
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Aug 12, 2024
1 parent dd5286d commit af66733
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# covr (development version)

* Fixed an issue where attempting to generate code coverage on an already-loaded
package could fail on Windows. (@kevinushey, #574)

* Prevent `covr.record_tests` option from logging duplicate tests when the same
line of testing code is hit repeatedly, as in a loop. (@dgkf, #528)

Expand Down
32 changes: 20 additions & 12 deletions R/covr.R
Original file line number Diff line number Diff line change
Expand Up @@ -441,18 +441,26 @@ package_coverage <- function(path = ".",
if (isTRUE(pre_clean)) clean_objects(pkg$path)

# install the package in a temporary directory
withr::with_makevars(flags, assignment = "+=",
utils::install.packages(repos = NULL,
lib = install_path,
pkg$path,
type = "source",
INSTALL_opts = c("--example",
"--install-tests",
"--with-keep.source",
"--with-keep.parse.data",
"--no-staged-install",
"--no-multiarch"),
quiet = quiet))
withr::with_envvar(
list(R_LIBS = paste(.libPaths(), collapse = .Platform$path.sep)),
withr::with_makevars(flags, assignment = "+=", {
args <- c(
"--vanilla", "CMD", "INSTALL",
"-l", shQuote(install_path),
"--example",
"--install-tests",
"--with-keep.source",
"--with-keep.parse.data",
"--no-staged-install",
"--no-multiarch",
pkg$path
)

name <- if (.Platform$OS.type == "windows") "R.exe" else "R"
path <- file.path(R.home("bin"), name)
system2(path, args)
})
)

# add hooks to the package startup
add_hooks(pkg$package, install_path,
Expand Down

0 comments on commit af66733

Please sign in to comment.