metrumresearchgroup / mrgvalprep

Helpers for prepping inputs to mrgvalidate
https://metrumresearchgroup.github.io/mrgvalprep
Other
1 stars 0 forks source link

Fix validate_tests() to not load package deps into global environment #2

Closed seth127 closed 2 years ago

seth127 commented 3 years ago

Something is causing sessionInfo() (optionally called from inside get_sys_info()) to fail any time after validate_tests() has been called in a given session. My hunch (based on the error below) is that it's something to do with devtools::install() loading the dependencies of the package being validated, and then those not being present in .libPaths() when sessionInfo() is called. I tried a few things, notably wrapping it in callr::r() but nothing has working yet.

Reprex

# Restart R session
Sys.setenv(GITHUB_PAT = "your PAT")

# this should pass
devtools::test() 

# now run it again and sessionInfo() errors
devtools::test()

...
x |  11 1 6   | get-sys-info                                                                                                    
──────────
Warning (test-get-sys-info.R:35:3): get_sys_info() captures sessionInfo
DESCRIPTION file of package 'colorspace' is missing or broken
Backtrace:
  1. mrgvalprep::get_sys_info(session = TRUE) test-get-sys-info.R:35:2
  8. utils::sessionInfo()
  9. base::lapply(loadedOnly, packageDescription)
 10. utils:::FUN(X[[i]], ...)

Warning (test-get-sys-info.R:35:3): get_sys_info() captures sessionInfo
DESCRIPTION file of package 'scales' is missing or broken
Backtrace:
  1. mrgvalprep::get_sys_info(session = TRUE) test-get-sys-info.R:35:2
  8. utils::sessionInfo()
  9. base::lapply(loadedOnly, packageDescription)
 10. utils:::FUN(X[[i]], ...)

Warning (test-get-sys-info.R:35:3): get_sys_info() captures sessionInfo
DESCRIPTION file of package 'mrgvalidatetestreference' is missing or broken
Backtrace:
  1. mrgvalprep::get_sys_info(session = TRUE) test-get-sys-info.R:35:2
  8. utils::sessionInfo()
  9. base::lapply(loadedOnly, packageDescription)
 10. utils:::FUN(X[[i]], ...)

Warning (test-get-sys-info.R:35:3): get_sys_info() captures sessionInfo
DESCRIPTION file of package 'ggplot2' is missing or broken
Backtrace:
  1. mrgvalprep::get_sys_info(session = TRUE) test-get-sys-info.R:35:2
  8. utils::sessionInfo()
  9. base::lapply(loadedOnly, packageDescription)
 10. utils:::FUN(X[[i]], ...)

Warning (test-get-sys-info.R:35:3): get_sys_info() captures sessionInfo
DESCRIPTION file of package 'munsell' is missing or broken
Backtrace:
  1. mrgvalprep::get_sys_info(session = TRUE) test-get-sys-info.R:35:2
  8. utils::sessionInfo()
  9. base::lapply(loadedOnly, packageDescription)
 10. utils:::FUN(X[[i]], ...)

Warning (test-get-sys-info.R:35:3): get_sys_info() captures sessionInfo
DESCRIPTION file of package 'gtable' is missing or broken
Backtrace:
  1. mrgvalprep::get_sys_info(session = TRUE) test-get-sys-info.R:35:2
  8. utils::sessionInfo()
  9. base::lapply(loadedOnly, packageDescription)
 10. utils:::FUN(X[[i]], ...)

Error (test-get-sys-info.R:35:3): get_sys_info() captures sessionInfo
Error: subscript out of bounds
Backtrace:
  1. mrgvalprep::get_sys_info(session = TRUE) test-get-sys-info.R:35:2
  8. utils:::print.sessionInfo(utils::sessionInfo())
 10. utils:::mkLabel(x, "loadedOnly")
 11. base::sapply(L[[n]], function(x) x[["Version"]])
 12. base::lapply(X = X, FUN = FUN, ...)
 13. utils:::FUN(X[[i]], ...)
──────────────
...

Note: all of these packages are dependencies of the test package we are trying to "validate" in the validate_tests() call in tests/testthat/test-validate-tests.R