Permalink
Browse files

Merge pull request #18 from eddelbuettel/master

add support for unit testing from building package (including at GitHub)
  • Loading branch information...
2 parents da97dc7 + 387bb59 commit 7ba9e2d816e1d000f610e6baef75569c9c5833c3 @bwlewis committed Jan 17, 2014
View
@@ -0,0 +1 @@
+.travis.yml
View
@@ -1 +0,0 @@
-test
View
@@ -0,0 +1,33 @@
+# Sample .travis.yml for R projects.
+#
+# See the r-travis repo and its wiki
+# https://github.com/craigcitro/r-travis/wiki
+# https://github.com/eddelbuettel/r-travis/
+
+language: c
+
+env:
+ global:
+ - _R_CHECK_FORCE_SUGGESTS_=FALSE
+ - RunRRedisTests=yes
+
+before_install:
+ - curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh
+ - chmod 755 ./travis-tool.sh
+ - ./travis-tool.sh bootstrap
+
+install:
+ - ./travis-tool.sh install_aptget redis-server
+ - ./travis-tool.sh install_r RUnit
+
+script:
+ - ./travis-tool.sh run_tests
+
+after_failure:
+ - ./travis-tool.sh dump_logs
+
+notifications:
+ email:
+ on_success: change
+ on_failure: change
+
View
@@ -1,10 +1,11 @@
Package: rredis
Type: Package
Title: Redis client for R
-Version: 1.6.8.1
+Version: 1.6.8.2
Date: 2014-01-05
Author: B. W. Lewis
Maintainer: B. W. Lewis <blewis@illposed.net>
Description: An R client for the Redis persistent key-value database available from http://redis.io.
License: Apache License (>= 2.0)
LazyLoad: yes
+Suggests: RUnit
View
@@ -1,6 +0,0 @@
-require(rredis)
-require(RUnit)
-runTestFile('basicTest.R')
-runTestFile('zsetTest.R')
-runTestFile('setTest.R')
-runTestFile('endTest.R')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1,42 @@
+
+## 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 R Wiki http://wiki.r-project.org/rwiki/doku.php?id=developers:runit
+## and changed further by Martin Maechler
+## and more changes by Murray Stokely in HistogramTools
+##
+## Dirk Eddelbuettel, Jan 2014
+
+stopifnot(require(RUnit, quietly=TRUE))
+stopifnot(require(rredis, quietly=TRUE))
+
+## Set a seed to make the test deterministic
+set.seed(42)
+
+## Define tests
+testSuite <- defineTestSuite(name="rredis Unit Tests",
+ dirs=system.file("test", package="rredis"),
+ testFuncRegexp = "^[Tt]est+")
+
+## rredis requires a redis server
+## we cannot always assume one, so default to FALSE
+runTests <- FALSE
+
+## if we a redis server is set up, we can sigmal this
+if (Sys.getenv("RunRRedisTests")=="yes") runTests <- TRUE
+
+## Tests for test run
+if (runTests) {
+ ## 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!")
+ }
+}

0 comments on commit 7ba9e2d

Please sign in to comment.