<div dir="ltr">Figured it out.<div><br></div><div>My snippet below does _not_ solve the problem of include paths. The key is to symlink ./inst/include to ./include. After that it works if I call "devtools::tests()". It fails however with "devtools::check(args = c('--as-cran'))".</div><div><br></div><div>THK</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><a href="http://www.keittlab.org/" target="_blank">http://www.keittlab.org/</a></div></div></div>
<br><div class="gmail_quote">On Wed, Jan 25, 2017 at 5:52 PM, JJ Allaire <span dir="ltr"><<a href="mailto:jj.allaire@gmail.com" target="_blank">jj.allaire@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Not 100% sure about this but I think the workaround for using sourceCpp within tests is to define R_TESTS="" (that's what we do in Rcpp and RcppParallel). Here's the code I'm thinking of: <a href="https://github.com/RcppCore/Rcpp/blob/master/tests/doRUnit.R#L42-L43" target="_blank">https://github.com/<wbr>RcppCore/Rcpp/blob/master/<wbr>tests/doRUnit.R#L42-L43</a><div><br></div><div>Note that we use RUnit in both of those packages so there could indeed be some issue with testthat that we're not aware of.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 25, 2017 at 2:33 PM, Tim Keitt <span dir="ltr"><<a href="mailto:tkeitt@utexas.edu" target="_blank">tkeitt@utexas.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I have a package that compiles C++ at runtime using sourceCpp and I would like to use testthat with the package. Its clear that testthat sets up a non-standard environment and so it is difficult to combine it with sourceCpp. The first hurdle was include paths not working.</div><div><br></div><div>This bit of code in the test_ file seemed to fix that:</div><div><br></div><div><div>ccflags = Sys.getenv("CCFLAGS")</div><div>ipath = file.path(getwd(), "inst", "include")</div><div>ccflags = if (nzchar(ccflags)) paste(ccflags, paste0("-I", ipath)) else paste0("-I", ipath)</div><div>Sys.setenv(CCFLAGS = ccflags)</div></div><div><br></div><div>However, once compiled, the object does not load correctly as I cannot call the compiled function. Does anyone have a workaround? (I have searched and not found anything terribly useful.)</div><div><br></div><div>THK</div><br clear="all"><div><div class="m_-546102088534981297m_-5612937150979075769gmail_signature"><div dir="ltr"><a href="http://www.keittlab.org/" target="_blank">http://www.keittlab.org/</a></div></div></div>
</div>
<br>______________________________<wbr>_________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-pro<wbr>ject.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" rel="noreferrer" target="_blank">https://lists.r-forge.r-projec<wbr>t.org/cgi-bin/mailman/listinfo<wbr>/rcpp-devel</a><br></blockquote></div><br></div>
</blockquote></div><br></div>