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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package_coverage() vs minimal package (on Windows?) #540

Open
jonthegeek opened this issue Sep 18, 2023 · 2 comments
Open

package_coverage() vs minimal package (on Windows?) #540

jonthegeek opened this issue Sep 18, 2023 · 2 comments

Comments

@jonthegeek
Copy link
Contributor

In today's workshop, I made the minimal package available here.

When I check coverage, I get this error:

[main 15:40:52] > devtools:::test_coverage()
ℹ Computing test coverage for workshoppractice
Error in `-stats$Relevant`:
! invalid argument to unary operator
Backtrace:
    ▆
 1. └─devtools:::test_coverage()
 2.   └─covr::report(coverage)
 3.     └─covr:::to_report_data(x)
 4.       └─covr:::sort_file_stats(res$file_stats)
 5.         └─base::order(as.numeric(sub("%", "", stats$Coverage)), -stats$Relevant)

I found that it's specifically here:

coverage <- covr::package_coverage()
length(coverage)
#> 0

If I add a line to check_installed.R above the definition of the function (ie, an irrelevant line), coverage has length 3.
This is probably low priority since it goes away as soon as I do something real, but it was weird.

@jonthegeek
Copy link
Contributor Author

To officially log it: someone mentioned they saw the same behavior on mac, so it isn't a windows-only thing. Could be related to mocking and/or snapshots.

@dragosmg
Copy link

I am getting the same error message when developing a toy package on macOS.

> test_coverage()
ℹ Computing test coverage for packageA
Error in -stats$Relevant : invalid argument to unary operator
Backtrace:1. └─devtools::test_coverage()
 2.   └─covr::report(coverage)
 3.     └─covr:::to_report_data(x)
 4.       └─covr:::sort_file_stats(res$file_stats)
 5.         └─base::order(as.numeric(sub("%", "", stats$Coverage)), -stats$Relevant)
session info:
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.1 (2023-06-16)
#>  os       macOS Sonoma 14.0
#>  system   x86_64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/London
#>  date     2023-11-15
#>  pandoc   3.1.1 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cachem        1.0.8   2023-05-01 [1] CRAN (R 4.3.1)
#>  callr         3.7.3   2022-11-02 [1] CRAN (R 4.3.0)
#>  cli           3.6.1   2023-03-23 [1] CRAN (R 4.3.0)
#>  crayon        1.5.2   2022-09-29 [1] CRAN (R 4.3.0)
#>  devtools      2.4.5   2022-10-11 [1] CRAN (R 4.3.0)
#>  digest        0.6.33  2023-07-07 [1] CRAN (R 4.3.0)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.3.0)
#>  evaluate      0.22    2023-09-29 [1] CRAN (R 4.3.1)
#>  fastmap       1.1.1   2023-02-24 [1] CRAN (R 4.3.0)
#>  fs            1.6.3   2023-07-20 [1] CRAN (R 4.3.1)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.3.0)
#>  htmltools     0.5.6.1 2023-10-06 [1] CRAN (R 4.3.1)
#>  htmlwidgets   1.6.2   2023-03-17 [1] CRAN (R 4.3.0)
#>  httpuv        1.6.11  2023-05-11 [1] CRAN (R 4.3.1)
#>  knitr         1.44    2023-09-11 [1] CRAN (R 4.3.1)
#>  later         1.3.1   2023-05-02 [1] CRAN (R 4.3.1)
#>  lifecycle     1.0.3   2022-10-07 [1] CRAN (R 4.3.0)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.3.0)
#>  memoise       2.0.1   2021-11-26 [1] CRAN (R 4.3.0)
#>  mime          0.12    2021-09-28 [1] CRAN (R 4.3.0)
#>  miniUI        0.1.1.1 2018-05-18 [1] CRAN (R 4.3.0)
#>  pkgbuild      1.4.2   2023-06-26 [1] CRAN (R 4.3.0)
#>  pkgload       1.3.3   2023-09-22 [1] CRAN (R 4.3.0)
#>  prettyunits   1.2.0   2023-09-24 [1] CRAN (R 4.3.1)
#>  processx      3.8.2   2023-06-30 [1] CRAN (R 4.3.1)
#>  profvis       0.3.8   2023-05-02 [1] CRAN (R 4.3.0)
#>  promises      1.2.1   2023-08-10 [1] CRAN (R 4.3.1)
#>  ps            1.7.5   2023-04-18 [1] CRAN (R 4.3.0)
#>  purrr         1.0.2   2023-08-10 [1] CRAN (R 4.3.0)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.3.0)
#>  Rcpp          1.0.11  2023-07-06 [1] CRAN (R 4.3.1)
#>  remotes       2.4.2.1 2023-07-18 [1] CRAN (R 4.3.0)
#>  reprex        2.0.2   2022-08-17 [1] CRAN (R 4.3.0)
#>  rlang         1.1.1   2023-04-28 [1] CRAN (R 4.3.0)
#>  rmarkdown     2.25    2023-09-18 [1] CRAN (R 4.3.0)
#>  rstudioapi    0.15.0  2023-07-07 [1] CRAN (R 4.3.0)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.3.0)
#>  shiny         1.7.5.1 2023-10-14 [1] CRAN (R 4.3.1)
#>  stringi       1.7.12  2023-01-11 [1] CRAN (R 4.3.0)
#>  stringr       1.5.0   2022-12-02 [1] CRAN (R 4.3.0)
#>  urlchecker    1.0.1   2021-11-30 [1] CRAN (R 4.3.0)
#>  usethis       2.2.2   2023-07-06 [1] CRAN (R 4.3.1)
#>  vctrs         0.6.4   2023-10-12 [1] CRAN (R 4.3.0)
#>  withr         2.5.1   2023-09-26 [1] CRAN (R 4.3.0)
#>  xfun          0.40    2023-08-09 [1] CRAN (R 4.3.1)
#>  xtable        1.8-4   2019-04-21 [1] CRAN (R 4.3.0)
#>  yaml          2.3.7   2023-01-23 [1] CRAN (R 4.3.0)
#> 
#>  [1] /Users/dragos/Library/R/x86_64/4.3/library
#>  [2] /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Created on 2023-11-15 with reprex v2.0.2

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

2 participants