[Rcpp-devel] How do I run the Rcpp unit tests?

Dirk Eddelbuettel edd at debian.org
Sat Apr 27 21:48:19 CEST 2013


Andre,

On 27 April 2013 at 15:15, Andre Mikulec wrote:
| Hi,
| 
| I am trying to run the Rcpp unit tests.
| 
| system("cmd /c R F://ProgramFiles//R//R-2.15.3//library//Rcpp//unitTests//
| runTests.R --allTests")
| 
| WARNING: unknown option '--allTests'
| 
| 
| 
| F:\Documents and Settings\Administrator>R F:\ProgramFiles\R\R-2.15.3\library\
| Rcpp\unitTests\runTests.R --allTests
| 
| WARNING: unknown option '--allTests'

The comments in that file refer to 'r', not 'R'.  And 'r' is the littler
frontend Jeff Horner and I wrote before Rscript came out.

This still works for me on Linux:

  $ r /usr/local/lib/R/site-library/Rcpp/unitTests/runTests.R --allTests --output=/tmp

at least until it notices that the pathRcppTests variable is unset so it
doesn't find the C++ input files.

You can try the same on Windows but should

  a) adapt the script as Rscript does not use argc[] as r does for
     command-line arguments

  b) see if --output="C:/TEMP" will work

  c) check if the --allTests argument works; CRAN forces us to suppress all
     tests if run time exceed one minute.

So you may have to set the magic variable RunAllRcppTests so that this passes:

  .runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"

What always works is 

  d) R CMD check Rcpp_*.tar.gz   # for whichever version

provided the variable is set.

Lastly, I often just individual unit test files via a little helper script
again deploying r.  I enclose that below; it too can be rewritten to use
Rscript (but I am happy with r so I won;t do it).

Dirk


#!/bin/sh

set -u 
set -e

progname=`basename $0`
options='p:ah?'
 
usage_and_exit()
{
    echo ""
    echo "Usage: $progname [-p package[,package2,..]] [-?|-h]"
    echo "  Run unit test script for R package"
    echo ""
    echo "Options:"
    echo "  -p package[,package2,..]]  load additional package(s)"
    echo "  -h                         show this help"
    echo "  -a                         runAllTests"
    echo ""
    echo "The RUnit and inline packages are automatically loaded."
    echo ""
    exit 0
}

while getopts "$options" i 
do 
    case "$i" in
	p)
	    pkg=",$OPTARG"
	    shift 
	    shift
	    ;;
	a)
	    export RunAllRcppTests="yes"
	    shift
	    ;;
	h|?)
	    usage_and_exit
	    ;;
    esac
done

if [ ! -f $1 ]; then
    echo "Error: No file '$1' found"
    exit 1
fi

file=`pwd`/$1

r -i -t -linline,RUnit${pkg} -e"cppfunction <- function(...) cxxfunction(..., plugin=\"Rcpp\"); runTestFile(\"$file\")"




-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list