marioni-group / MethylPipeR

Modular and reproducible pipelines for multi-omics predictors of complex traits.
GNU General Public License v3.0
6 stars 2 forks source link

Tests use hardcoded file locations #2

Closed nathansam closed 1 year ago

nathansam commented 2 years ago

File locations are currently hardcoded eg. https://github.com/marioni-group/MethylPipeR/blob/c6fbb68a8c229d0037c942ed54997e4e9a61960f/tests/testthat/test_fitmprmodel.R#L3

These tests won't pass on CRAN and other people's systems. The easiest approach would be to use tempfile() for files you need to create, such as logs and place any (small) datasets you want to use for tests, but not directly expose to the user, in the inst/ directory. Files places in inst/ are moved to the top-level package directory when the package is installed. This approach is used for this file: https://github.com/ropensci/datefixR/blob/37d528bba49373f77f4fc255e0931fd3b4a90e30/inst/example.xlsx and then system.file() can be used to dynamically get the location of the file. https://github.com/ropensci/datefixR/blob/37d528bba49373f77f4fc255e0931fd3b4a90e30/tests/testthat/test_fix_date_app.R#L10

YipengC commented 1 year ago

Tests no longer use hardcoded file locations.