Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not error when src has no functions #537

Open
mpadge opened this issue Jun 23, 2023 · 0 comments
Open

Do not error when src has no functions #537

mpadge opened this issue Jun 23, 2023 · 0 comments

Comments

@mpadge
Copy link
Contributor

mpadge commented Jun 23, 2023

Hi @jimhester - looks like you're the only one left maintaining this package, so sorry to both you 馃槒 I've got an issue with some src C code which contains no actual functions. This fails on the gcov call here:

covr/R/compiled.R

Lines 77 to 79 in caed186

system_check(gcov_path,
args = c(gcov_args, src, "-p", "-o", dirname(src)),
quiet = quiet, echo = !quiet)

because gcov errors when there are no executable lines. Here's a reprex based on this src file:

library (covr)
d <- file.path (tempdir (), "typetracer")
path <- gert::git_clone ("https://github.com/mpadge/typetracer", path = d)
flags <- getOption("covr.flags")
covr:::clean_objects (path)
install_path <- covr:::temp_file("R_LIBS")
dir.create(install_path)
Sys.setenv ("R_LIBS_USER" = file.path (tempdir (), "Library"))
withr::with_makevars(flags, assignment = "+=",
    utils::install.packages(
        repos = NULL,
        lib = install_path,
        path,
        type = "source",
        INSTALL_opts = c("--example",
                         "--install-tests",
                         "--with-keep.source",
                         "--with-keep.parse.data",
                         "--no-staged-install",
                         "--no-multiarch"),
        quiet = TRUE
))

quiet <- FALSE
gcov_path <- getOption("covr.gcov", "")
gcov_args <- NULL
src_path <- covr:::normalize_path(file.path(path, "src"))
gcov_inputs <- list.files(path, pattern = rex::rex(".gcno", end), recursive = TRUE, full.names = TRUE)
print (gcov_inputs)
#> [1] "/tmp/RtmpT9LnNK/typetracer//src/utils.gcno"

# 'run_gcov_one' fn in 'run_gov' with 'src' param:
src <- gcov_inputs
    covr:::system_check(gcov_path,
        args = c(gcov_args, src, "-p", "-o", dirname(src)),
        quiet = quiet, echo = !quiet)
#> '/usr/bin/gcov' '/tmp/RtmpT9LnNK/typetracer//src/utils.gcno' '-p' '-o'  \
#>   '/tmp/RtmpT9LnNK/typetracer//src'
#> Error: Command ''/usr/bin/gcov' '/tmp/RtmpT9LnNK/typetracer//src/utils.gcno' '-p' '-o' '/tmp/RtmpT9LnNK/typetracer//src'' failed (3)

# Re-written to capture actual messages:
args <- c(gcov_args, src, "-p", "-o", dirname(src))
full <- paste(c(shQuote(gcov_path), lapply(args, shQuote)), collapse = " ")
s = system(full, intern = TRUE, ignore.stderr = FALSE, ignore.stdout = FALSE)
#> Warning in system(full, intern = TRUE, ignore.stderr = FALSE, ignore.stdout =
#> FALSE): running command ''/usr/bin/gcov'
#> '/tmp/RtmpT9LnNK/typetracer//src/utils.gcno' '-p' '-o'
#> '/tmp/RtmpT9LnNK/typetracer//src'' had status 3
print (s)
#> [1] "No executable lines"
#> attr(,"status")
#> [1] 3

Created on 2023-06-23 with reprex v2.0.2

Plus the console output of gcov has the extra line

#> '/tmp/RtmpT9LnNK/typetracer//src/utils.gcno:no functions found

There is no way to circumvent this, and thus no way to get package_coverage to succeed on this package, so any help would be appreciated! Just some kind of modification of the system_check shown above to return empty yet still succeed when no functions found?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant