Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/update testrunner #10

Merged
merged 4 commits into from
Oct 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
^\.Rproj\.user$
.travis.yml
vignettes/jss
^local
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: RcppGSL
Type: Package
Title: 'Rcpp' Integration for 'GNU GSL' Vectors and Matrices
Version: 0.3.0
Date: 2015-08-30
Version: 0.3.0.1
Date: 2016-10-01
Author: Dirk Eddelbuettel and Romain Francois
Maintainer: Dirk Eddelbuettel <edd@debian.org>
Description: 'Rcpp' integration for 'GNU GSL' vectors and matrices
Expand Down
File renamed without changes.
File renamed without changes.
66 changes: 37 additions & 29 deletions tests/doRUnit.R
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
#### doRUnit.R --- Run RUnit tests
####------------------------------------------------------------------------
## doRUnit.R --- Run RUnit tests
##
## with credits to package fUtilities in RMetrics
## which credits Gregor Gojanc's example in CRAN package 'gdata'
## as per the (now deceased) R Wiki http://wiki.r-project.org/rwiki/doku.php?id=developers:runit
## and changed further by Martin Maechler
## and usage across several Rcpp* package
## and more changes by Murray Stokely in HistogramTools
##
## Dirk Eddelbuettel, 2010 - 2016

### 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
stopifnot(require("RUnit", quietly=TRUE))
stopifnot(require("RcppGSL", quietly=TRUE))

### 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
## Set a seed to make the test deterministic
set.seed(42)

### 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 :
## Define tests
testSuite <- defineTestSuite(name="RcppGSL Unit Tests",
dirs=system.file("unitTests", package = "RcppGSL"),
testFuncRegexp = "^[Tt]est.+")

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" )
}
## without this, we get (or used to get) unit test failures
Sys.setenv("R_TESTS"="")

## Run tests
tests <- runTestSuite(testSuite)

## Print results
printTextProtocol(tests)

## Return success or failure to R CMD CHECK
if (getErrors(tests)$nFail > 0) {
stop("TEST FAILED!")
}
if (getErrors(tests)$nErr > 0) {
stop("TEST HAD ERRORS!")
}
if (getErrors(tests)$nTestFunc < 1) {
stop("NO TEST FUNCTIONS RUN!")
}