Skip to content

Commit

Permalink
fix: Removing covr::report() from inflate() since it will necessit DT…
Browse files Browse the repository at this point in the history
… and htmltools dependencies.

#256
  • Loading branch information
Yohann Mansiaux committed Jun 12, 2024
1 parent dfb2add commit 00bd7c3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 74 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ importFrom(cli,cli_alert_info)
importFrom(cli,cli_alert_success)
importFrom(cli,cli_alert_warning)
importFrom(covr,package_coverage)
importFrom(covr,report)
importFrom(devtools,check)
importFrom(glue,glue)
importFrom(magrittr,"%>%")
Expand Down
25 changes: 2 additions & 23 deletions R/inflate.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ regex_example <- paste(regex_example_vec, collapse = "|")
#' @importFrom utils getFromNamespace
#' @importFrom glue glue
#' @importFrom methods formalArgs
#' @importFrom covr package_coverage report
#' @importFrom covr package_coverage
#'
#' @return
#' Package structure. Return path to current package.
Expand Down Expand Up @@ -82,10 +82,6 @@ inflate <- function(pkg = ".", flat_file,
clean = "ask",
update_params = TRUE,
codecov = FALSE,
codecov_fun = c(
"package_coverage",
"report"
),
...) {
if (!is.null(list(...)[["name"]])) {
stop(paste0(
Expand Down Expand Up @@ -371,26 +367,9 @@ inflate <- function(pkg = ".", flat_file,
)

if (codecov) {
codecov_fun <- try(
match.arg(
codecov_fun,
c("package_coverage", "report"),
several.ok = FALSE
),
silent = TRUE
)
if (inherits(codecov_fun, "try-error")) {
cli::cli_abort("codecov_fun must be either 'package_coverage' or 'report'")
}

cli::cli_alert_info("Computing code coverage - it might take some time")

print(
get(
sprintf(
"%s", codecov_fun[1]
)
)()
covr::package_coverage()
)
}

Expand Down
1 change: 0 additions & 1 deletion man/inflate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 2 additions & 49 deletions tests/testthat/test-inflate-part3.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,6 @@ usethis::with_project(dummypackage, {
)
})

test_that("inflate fails if a wrong function to compute coverage is used", {
expect_error(
inflate(
pkg = dummypackage,
flat_file = dev_file1,
vignette_name = "Get started",
check = FALSE,
open_vignette = FALSE,
document = TRUE,
overwrite = "yes",
codecov = TRUE,
codecov_fun = "wrong"
),
"codecov_fun must be either 'package_coverage' or 'report'"
)
})

capture.output(
inflate(
Expand All @@ -76,15 +60,14 @@ usethis::with_project(dummypackage, {
open_vignette = FALSE,
document = TRUE,
overwrite = "yes",
codecov = TRUE,
codecov_fun = "package_coverage"
codecov = TRUE
),
file = console_output_file,
type = "message"
)


test_that("inflate outputs compute codecov if asked and if codecov_fun = package_coverage", {
test_that("inflate outputs compute codecov if asked", {
res <- readLines(console_output_file)

expect_true(
Expand Down Expand Up @@ -129,36 +112,6 @@ usethis::with_project(dummypackage, {
file = console_output_file,
type = "message"
)


test_that("inflate does not output compute codecov if asked and if codecov_fun = report", {
res <- readLines(console_output_file)

expect_true(
any(grepl(
pattern = "Computing code coverage - it might take some time",
x = res
))
)

expect_false(
any(grepl(
pattern = "R/flat1_rmd.R: 0.00%",
x = res
))
)


expect_false(
any(grepl(
pattern = paste(
basename(dummypackage),
"Coverage: 0.00%"
),
x = res
))
)
})
})

unlink(console_output_file)
Expand Down

0 comments on commit 00bd7c3

Please sign in to comment.