On Mon, 22 Aug 2005, hadley wickham wrote:
> 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)
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.
> 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?
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.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595