[Rcpp-commits] r1318 - in pkg/RcppGSL: . inst/unitTests tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue May 25 13:32:32 CEST 2010


Author: romain
Date: 2010-05-25 13:32:32 +0200 (Tue, 25 May 2010)
New Revision: 1318

Added:
   pkg/RcppGSL/tests/
   pkg/RcppGSL/tests/doRUnit.R
Modified:
   pkg/RcppGSL/inst/unitTests/runTests.R
Log:
save unit test results in RcppGSL.Rcheck (same as Rcpp) instead of /tmp on R CMD check

Modified: pkg/RcppGSL/inst/unitTests/runTests.R
===================================================================
--- pkg/RcppGSL/inst/unitTests/runTests.R	2010-05-25 11:23:42 UTC (rev 1317)
+++ pkg/RcppGSL/inst/unitTests/runTests.R	2010-05-25 11:32:32 UTC (rev 1318)
@@ -41,26 +41,31 @@
         	}
         }
 
-        # give a chance to the user to customize where he/she wants
-        # the unit tests results to be stored with the --output= command
-        # line argument
-        if( exists( "argv",  globalenv() ) ){
-        	# littler
-        	output <- process_args(argv)
-        } else {
-        	# Rscript
-        	output <- process_args(commandArgs(TRUE))
-        }
-
-        # if it did not work, try to use /tmp
-        if( is.null(output) ){
-        	if( file.exists( "/tmp" ) ){
-        		output <- "/tmp"
-        	} else{
-        		output <- getwd()
+        # R CMD check uses this
+        if( exists( "Rcpp.unit.test.output.dir", globalenv() ) ){
+			output <- Rcpp.unit.test.output.dir
+		} else {
+       
+        	# give a chance to the user to customize where he/she wants
+        	# the unit tests results to be stored with the --output= command
+        	# line argument
+        	if( exists( "argv",  globalenv() ) ){
+        		# littler
+        		output <- process_args(argv)
+        	} else {
+        		# Rscript
+        		output <- process_args(commandArgs(TRUE))
         	}
+        	
+        	# if it did not work, try to use /tmp
+        	if( is.null(output) ){
+        		if( file.exists( "/tmp" ) ){
+        			output <- "/tmp"
+        		} else{
+        			output <- getwd()
+        		}
+        	}
         }
-
         ## Print results
         output.txt  <- file.path( output, sprintf("%s-unitTests.txt", pkg))
         output.html <- file.path( output, sprintf("%s-unitTests.html", pkg))

Added: pkg/RcppGSL/tests/doRUnit.R
===================================================================
--- pkg/RcppGSL/tests/doRUnit.R	                        (rev 0)
+++ pkg/RcppGSL/tests/doRUnit.R	2010-05-25 11:32:32 UTC (rev 1318)
@@ -0,0 +1,33 @@
+#### doRUnit.R --- Run RUnit tests
+####------------------------------------------------------------------------
+
+### borrowed from package fUtilities in RMetrics
+### http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/pkg/fUtilities/tests/doRUnit.R?rev=1958&root=rmetrics&view=markup
+
+### Originally follows Gregor Gojanc's example in CRAN package  'gdata'
+### and the corresponding section in the R Wiki:
+###  http://wiki.r-project.org/rwiki/doku.php?id=developers:runit
+
+### MM: Vastly changed:  This should also be "runnable" for *installed*
+##              package which has no ./tests/
+## ----> put the bulk of the code e.g. in  ../inst/unitTests/runTests.R :
+
+if(require("RUnit", quietly = TRUE)) {
+  pkg <- "RcppGSL"
+                                       
+  require( pkg, character.only=TRUE)
+  
+  path <- system.file("unitTests", package = pkg)
+  
+  stopifnot(file.exists(path), file.info(path.expand(path))$isdir)
+  
+  # without this, we get unit test failures
+  Sys.setenv( R_TESTS = "" )
+  
+  Rcpp.unit.test.output.dir <- getwd()
+  
+  source(file.path(path, "runTests.R"), echo = TRUE)
+  
+} else {
+	print( "package RUnit not available, cannot run unit tests" )
+}                                                                                                 



More information about the Rcpp-commits mailing list