From Martin Maechler <maechler@stat.math.ethz.ch>  Mon Mar 15 09:40:14 1999
From: Martin Maechler <maechler@stat.math.ethz.ch> (Martin Maechler)
Date: Mon, 15 Mar 1999 10:40:14 +0100
Subject: R packages and test code
In-Reply-To: <87pv6b9vqn.fsf@alpha.cfas.washington.edu>
 (rossini@biostat.washington.edu)
References: <87pv6b9vqn.fsf@alpha.cfas.washington.edu>
Message-ID: <199903150940.KAA09497@sophie.ethz.ch>

>>>>> "tony" == A J Rossini <rossini@biostat.washington.edu> writes:

    tony> Where is the best place to put evaluation/test code in creating
    tony> an R package?  I thought about a test subdirectory, but might it
    tony> be better to put in the R directory?  I guess I'm more concerned
    tony> about the output used for evaluating the success of the test,
    tony> rather than the test code and data, itself.

Good question.  
This hasn't been done yet in a formal general way.
MASS comes with the  scripts subdirectory, 
but there's no "make check" and comparison of desired and actual output.

1) "THE" basic test is running all the examples from all the *.Rd files.
  You can do this with contributed packages by

       R CMD check [options] [-l lib] pkg_1 ... pkg_n

  However, this just runs the examples 
	   (those *not* within a \dontrun{.} clause)
  and produces an  <pkg>-Ex.Rout  file.
  You still have to check yourself if the *.Rout file has the proper output

2) I assume the thing you desire is something like 
   what the distributed R does in  ./tests/  where there are
   foobar.R  and foobar.Rout.save  files 
	     for (foobar in c("is-things", "simple-tests", "eval-etc",
			      ...)) :
      R --vanilla < foobar.R > foobar.Rout
   is run 
   and a somewhat "tolerant" diff between  foobar.Rout and foobar.Rout.save
   is made. "SUCCESS" (actually `Ok') is reported when there are no
   (nontrivial) diffs.

   Try  "make check" with your R distribution if you don't know what I mean.

It shouldn't be hard to add this to the  "R INSTALL" scripts  :

   If there's  <pkg-src>/tests/
   for all pairs foobar.R and foobar.Rout.save (in that directory) 
   do the above test.

Tony, could you try to add this feature (to the relevant R scripts)
yourself?  or anyone else?
[it would be nice of course, if the identical scripts were used for 
 "base R"'s  ``make check''  and for the contributed packages's  
 "R CMD check .. pkg" or (preferably) "R INSTALL pkg ..."
]

Martin



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


R packages and test code
Martin Maechler