Skip to content

Instantly share code, notes, and snippets.

@statnmap
Last active September 22, 2022 17:49
Show Gist options
  • Save statnmap/5e822ce306fc28bbec92ae052370ec9b to your computer and use it in GitHub Desktop.
Save statnmap/5e822ce306fc28bbec92ae052370ec9b to your computer and use it in GitHub Desktop.
Check: for unstated dependencies in ‘tests’
# When in your package in development
db <- tools:::.read_description("DESCRIPTION")
testdir <- "tests/testthat"
Rinfiles <- list.files(testdir, pattern = "\\.Rin$", full.names = TRUE)
Rfiles <- list.files(testdir, pattern = "\\.[rR]$", full.names = TRUE)
res <- tools:::.check_packages_used_helper(db, c(Rinfiles, Rfiles))
res
repos <- tools:::.get_standard_repository_URLs()
# This is not protected when no Internet connection is available
available <- utils::available.packages(repos = repos)
# This comes from
debugonce(tools:::.check_packages_used_in_tests)
tools:::.check_packages_used_in_tests(dir = ".", testdir = "tests/testthat")
@statnmap
Copy link
Author

Have you face:

Version: 0.3.0
Check: for unstated dependencies in ‘tests’
Result: WARN
    Warning: unable to access index for repository https://bioconductor.org/packages/3.14/bioc/src/contrib:
     cannot open URL 'https://bioconductor.org/packages/3.14/bioc/src/contrib/PACKAGES'
    Warning: unable to access index for repository https://bioconductor.org/packages/3.14/data/annotation/src/contrib:
     cannot open URL 'https://bioconductor.org/packages/3.14/data/annotation/src/contrib/PACKAGES'
    Warning: unable to access index for repository https://bioconductor.org/packages/3.14/data/experiment/src/contrib:
     cannot open URL 'https://bioconductor.org/packages/3.14/data/experiment/src/contrib/PACKAGES'
Flavor: [r-oldrel-windows-ix86+x86_64](https://www.r-project.org/nosvn/R.check/r-oldrel-windows-ix86+x86_64/attachment-00check.html)

This is because the check verify that all dependencies called in your package are registered in DESCRIPTION.
If not, the check search if this package exist in any of the existing repositories to recommend to add it.

But when your package creates fake packages to test that it correctly works, then you may have problems with CRAN.

Indeed, if you're asked to do something to account for users who do not have an Internet connection, then, you can now say that this problem arise because maintainers of {tools} package did not accounted for users without Internet connection. These maintainers are the CRAN Team...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment