Skip to content

Commit 40122df

Browse files
Better experience of failing package installation (#607)
* use local variable * Add a warning for non-0 return value of R CMD INSTALL * restore * warning->error
1 parent cb4618a commit 40122df

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

R/covr.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ package_coverage <- function(path = ".",
457457

458458
name <- if (.Platform$OS.type == "windows") "R.exe" else "R"
459459
path <- file.path(R.home("bin"), name)
460-
system2(
460+
res <- system2(
461461
path,
462462
args,
463463
stdout = if (quiet) NULL else "",
@@ -466,6 +466,10 @@ package_coverage <- function(path = ".",
466466
})
467467
)
468468

469+
if (res != 0) {
470+
stop("Package installation did not succeed.")
471+
}
472+
469473
# add hooks to the package startup
470474
add_hooks(pkg$package, install_path,
471475
fix_mcexit = should_enable_parallel_mcexit_fix(pkg))
@@ -782,7 +786,7 @@ add_hooks <- function(pkg_name, lib, fix_mcexit = FALSE,
782786
trace_dir <- paste0("Sys.getenv(\"COVERAGE_DIR\", \"", lib, "\")")
783787

784788
load_script <- file.path(lib, pkg_name, "R", pkg_name)
785-
lines <- readLines(file.path(lib, pkg_name, "R", pkg_name))
789+
lines <- readLines(load_script)
786790
lines <- append(lines,
787791
c(paste0("setHook(packageEvent(pkg, \"onLoad\"), function(...) options(covr.record_tests = ", record_tests, "))"),
788792
"setHook(packageEvent(pkg, \"onLoad\"), function(...) covr:::trace_environment(ns))",

0 commit comments

Comments
 (0)