[Rcpp-commits] r2894 - in pkg/RcppGSL/inst/doc: . unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Feb 11 17:51:18 CET 2011


Author: edd
Date: 2011-02-11 17:51:18 +0100 (Fri, 11 Feb 2011)
New Revision: 2894

Added:
   pkg/RcppGSL/inst/doc/RcppGSL-unitTests.Rnw
   pkg/RcppGSL/inst/doc/unitTests-results/
   pkg/RcppGSL/inst/doc/unitTests/
   pkg/RcppGSL/inst/doc/unitTests/RcppGSL-unitTests.R
Modified:
   pkg/RcppGSL/inst/doc/Makefile
Log:
added unitTest vignette


Modified: pkg/RcppGSL/inst/doc/Makefile
===================================================================
--- pkg/RcppGSL/inst/doc/Makefile	2011-02-11 03:18:09 UTC (rev 2893)
+++ pkg/RcppGSL/inst/doc/Makefile	2011-02-11 16:51:18 UTC (rev 2894)
@@ -8,12 +8,20 @@
 ## on Ubuntu so for Dirk will insist on pdflatex and this variable helps
 whoami=$(shell whoami)
 
-all: clean RcppGSL.pdf
+all: clean RcppGSL-unitTests.pdf RcppGSL.pdf
 
 clean:
 	rm -f RcppGSL.Rnw 
 	cp RcppGSL/RcppGSL-fake.Rnw RcppGSL.Rnw
 
+
+RcppGSL-unitTests.pdf:
+	rm -fr unitTests-results/*
+	Rscript --vanilla unitTests/RcppGSL-unitTests.R
+	R CMD Sweave RcppGSL-unitTests.Rnw
+	Rscript --vanilla -e "tools::texi2dvi( 'RcppGSL-unitTests.tex', pdf = TRUE, clean = TRUE )"
+	rm -fr RcppGSL-unitTests.tex
+
 RcppGSL.pdf: RcppGSL/RcppGSL.Rnw
 	cp -f RcppGSL/RcppGSL.Rnw .
 	Rscript --vanilla -e "require(highlight); driver <- HighlightWeaveLatex(boxes = TRUE); Sweave( 'RcppGSL.Rnw', driver = driver ); "

Added: pkg/RcppGSL/inst/doc/RcppGSL-unitTests.Rnw
===================================================================
--- pkg/RcppGSL/inst/doc/RcppGSL-unitTests.Rnw	                        (rev 0)
+++ pkg/RcppGSL/inst/doc/RcppGSL-unitTests.Rnw	2011-02-11 16:51:18 UTC (rev 2894)
@@ -0,0 +1,33 @@
+\documentclass[10pt]{article}
+%\VignetteIndexEntry{RcppGSL-unitTests}
+\usepackage{vmargin}
+\setmargrb{0.75in}{0.75in}{0.75in}{0.75in}
+
+\RequirePackage{ae,mathpple}    % ae as a default font pkg works with Sweave
+\RequirePackage[T1]{fontenc}
+
+<<echo=FALSE,print=FALSE>>=
+require( RcppGSL )
+prettyVersion <- packageDescription("RcppGSL")$Version
+prettyDate <- format(Sys.Date(), "%B %e, %Y")
+@
+
+\usepackage[colorlinks]{hyperref}
+\author{Dirk Eddelbuettel \and Romain Fran\c{c}ois}
+\title{\texttt{RcppGSL}: Unit testing results}
+\date{\texttt{RcppGSL} version \Sexpr{prettyVersion} as of \Sexpr{prettyDate}}
+\begin{document}
+\maketitle
+
+\begin{verbatim}
+<<echo=F,results=tex>>=
+results <- "unitTests-results/RcppGSL-unitTests.txt"
+if( file.exists( results ) ){
+	writeLines( readLines( results ) )
+} else{
+	writeLines( "unit test results not available" )
+}
+@
+\end{verbatim}
+
+\end{document}

Added: pkg/RcppGSL/inst/doc/unitTests/RcppGSL-unitTests.R
===================================================================
--- pkg/RcppGSL/inst/doc/unitTests/RcppGSL-unitTests.R	                        (rev 0)
+++ pkg/RcppGSL/inst/doc/unitTests/RcppGSL-unitTests.R	2011-02-11 16:51:18 UTC (rev 2894)
@@ -0,0 +1,37 @@
+
+pkg <- "RcppGSL"
+
+# load this package
+require( pkg, character.only = TRUE )
+require( inline )
+
+if( compareVersion( packageDescription( "inline" )[["Version"]], "0.3.4.4" ) < 0 ){
+    stop( "RcppClassic unit tests need at least the version 0.3.4.4 of inline" )
+}
+
+cppfunction <- function( ... ){
+    cxxfunction( ..., plugin = pkg )
+}
+
+## load RUnit
+runit <- "RUnit" ; require( runit, character.only = TRUE )
+if( file.exists( "unitTests-results" ) ){ unlink("unitTests-results", recursive = TRUE ) }
+dir.create( "unitTests-results" )
+
+path <- system.file("unitTests", package = pkg)
+testSuite <- defineTestSuite(name=paste(pkg, "unit testing"), dirs = path)
+tests <- runTestSuite(testSuite)
+err <- getErrors(tests)
+if( err$nFail > 0) {
+    stop(sprintf( "unit test problems: %d failures", err$nFail))
+}
+if( err$nErr > 0) {
+    stop( sprintf( "unit test problems: %d errors", err$nErr) )
+}
+printHTMLProtocol(tests, fileName= sprintf( "unitTests-results/%s-unitTests.html" , pkg ) )
+printTextProtocol(tests, fileName= sprintf( "unitTests-results/%s-unitTests.txt"  , pkg ) )
+if( file.exists( "/tmp" ) ){
+	file.copy( sprintf( "unitTests-results/%s-unitTests.txt" , pkg ) , "/tmp", overwrite = TRUE )
+	file.copy( sprintf( "unitTests-results/%s-unitTests.html", pkg ) , "/tmp", overwrite = TRUE )
+}
+



More information about the Rcpp-commits mailing list