I am working on a R package that has some functions that I want to test (locally) on data that I can't distribute, because the data source is proprietary.
I have a folder (paid_projections
) where I'm keeping those files. This caused some initial difficulties when running devtools::test()
and R CMD check, I think because of subtle differences in the working directory that those utilities seen.
I've solved this problem by having my tests make some ad-hoc fixes to the path:
spec_file <- file.path('paid_projections', 'pod_projections.xlsx')
file_loc <- file.path(getwd(), spec_file)
#for CMD check
file_loc <- gsub('.Rcheck', '', file_loc, fixed = TRUE)
#for devtools::test()
file_loc <- gsub('tests/testthat/', '', file_loc, fixed = TRUE)
ex <- read_raw_pod(file_loc)
This... is less than ideal, and kind of makes me want to go take a shower. It does create the behavior that I want (I can run these tests in the console, via devtools::test()
, or R CMD check), but it doesn't feel like the correct solution.
There's a devtools::wd()
command that seems like it might be helpful here, but I couldn't quite make sense of how that might replace the eyesore above. Would love any suggestions!