[Rcpp-commits] r2738 - in pkg/RcppClassic/inst/doc: . unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Dec 8 04:33:20 CET 2010


Author: edd
Date: 2010-12-08 04:33:20 +0100 (Wed, 08 Dec 2010)
New Revision: 2738

Added:
   pkg/RcppClassic/inst/doc/RcppClassic-unitTests.Rnw
   pkg/RcppClassic/inst/doc/unitTests-results/
   pkg/RcppClassic/inst/doc/unitTests/
   pkg/RcppClassic/inst/doc/unitTests/RcppClassic-unitTests.R
Modified:
   pkg/RcppClassic/inst/doc/Makefile
Log:
we now have unit tests and a vignette to show for it


Modified: pkg/RcppClassic/inst/doc/Makefile
===================================================================
--- pkg/RcppClassic/inst/doc/Makefile	2010-12-08 03:11:00 UTC (rev 2737)
+++ pkg/RcppClassic/inst/doc/Makefile	2010-12-08 03:33:20 UTC (rev 2738)
@@ -8,14 +8,20 @@
 ## on Ubuntu so for Dirk will insist on pdflatex and this variable helps
 whoami=$(shell whoami)
 
-all: clean index.html RcppClassic.pdf
+all: clean RcppClassic-unitTests.pdf RcppClassic.pdf 
 
 pdfclean:
-	rm -f RcppClassic.pdf
+	rm -f RcppClassic.pdf RcppClassic-unitTests.pdf
 clean:
-	@rm -f index.html
 	@rm -f *.tex *.bbl *.blg *.aux *.out *.log
 
+RcppClassic-unitTests.pdf:
+	rm -fr unitTests-results/*
+	Rscript --vanilla unitTests/RcppClassic-unitTests.R
+	R CMD Sweave RcppClassic-unitTests.Rnw
+	Rscript --vanilla -e "tools::texi2dvi( 'RcppClassic-unitTests.tex', pdf = TRUE, clean = TRUE )"
+	rm -fr RcppClassic-unitTests.tex
+
 RcppClassic.pdf: RcppClassic.Rnw
 	R CMD Sweave RcppClassic.Rnw
 ifneq (,$(findstring edd,$(whoami)))

Added: pkg/RcppClassic/inst/doc/RcppClassic-unitTests.Rnw
===================================================================
--- pkg/RcppClassic/inst/doc/RcppClassic-unitTests.Rnw	                        (rev 0)
+++ pkg/RcppClassic/inst/doc/RcppClassic-unitTests.Rnw	2010-12-08 03:33:20 UTC (rev 2738)
@@ -0,0 +1,33 @@
+\documentclass[10pt]{article}
+%\VignetteIndexEntry{RcppClassic-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( RcppClassic )
+prettyVersion <- packageDescription("RcppClassic")$Version
+prettyDate <- format(Sys.Date(), "%B %e, %Y")
+@
+
+\usepackage[colorlinks]{hyperref}
+\author{Dirk Eddelbuettel \and Romain Fran\c{c}ois}
+\title{\texttt{RcppClassic}: Unit testing results}
+\date{\texttt{RcppClassic} version \Sexpr{prettyVersion} as of \Sexpr{prettyDate}}
+\begin{document}
+\maketitle
+
+\begin{verbatim}
+<<echo=F,results=tex>>=
+results <- "unitTests-results/RcppClassic-unitTests.txt"
+if( file.exists( results ) ){
+	writeLines( readLines( results ) )
+} else{
+	writeLines( "unit test results not available" )
+}
+@
+\end{verbatim}
+
+\end{document}

Added: pkg/RcppClassic/inst/doc/unitTests/RcppClassic-unitTests.R
===================================================================
--- pkg/RcppClassic/inst/doc/unitTests/RcppClassic-unitTests.R	                        (rev 0)
+++ pkg/RcppClassic/inst/doc/unitTests/RcppClassic-unitTests.R	2010-12-08 03:33:20 UTC (rev 2738)
@@ -0,0 +1,36 @@
+pkg <- "RcppClassic"
+
+# 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