[R-pkg-devel] Testthat environment using sourceCpp

Dirk Eddelbuettel edd at debian.org
Sat Sep 30 15:23:44 CEST 2017


I cannot help you with testthat or devtools, but the very issue of how to get
C++ test files compiled (with the help of Rcpp) and used is deployed in a
number of packages, both ours and other.

To take but one example, RcppArmadillo does it with about half a dozen C++
files it keeps in a subdirectory inst/unitTests/cpp/ --- and those files are
then sourced and compiled from the test setup function of each unit test file
requiring C++.  This generally calls a short helper function passing the
filename; that helper figures our whether to find the file in the installed
or tested package. You can see that helper function here:

I would assume that someone may have cooked up something similar for use with
testthat, and presumably also with devtools. Otherwise maybe you can, and
then blog about it. We had this setup working pretty much before those tools
existed so I never had a reason to switch.


http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org

More information about the R-package-devel mailing list