Skip to content

Package tests: best practices

2 messages · Hadley Wickham, Brian Ripley

#
I'm writing some tests for a package and I have a few questions
regarding best practices.  I've read "tests subdirectory" paragraph in
writing R extension, but I'm left wanting more.
Firstly, can I assume that the document root will always be set to the
test directory? (that what a couple of quick tests seemed to show)

Obviously, I want to test the code in my package - how do I load it? 
I assume I can't use library(XXX) because that will load the currently
installed version - should I source in all ../R/*.r instead?

Thanks for your advice,

Hadley
#
On Mon, 22 Aug 2005, hadley wickham wrote:

            
The working directory will be the tests directory as used, and all the 
tests subdirectory in the sources is copied there.

R does not have `document root', AFAIK.
You assume wrong: you should use the version installed for checking by 
library(xxx): R_LIBS is explicitly set to point to it first.

I've added some further comments to R-exts, but it seems that quite a few 
people have worked this out from the existing info and there are several 
examples in the R sources and recommended packages.