Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add support for unit testing from building package (including at GitHub) #18

Merged
merged 3 commits into from

2 participants

@eddelbuettel

Brian,
I am testing most (all?) of my R packages via Travis, and given that Travis relies on Ubuntu, I figured it would useful to have it test against an actual redis server. As I noticed that you already had RUnit tests, I just did the minimal additions to have these tickled -- if and only if an environment variable (currently: RunRRedisTests) is loaded with the right value (currently: yes). So CRAN builds would not get this, heck your own builds would not get it unless you set the variable.
But GitHub commits now trigger checks. I missed the need RUnit at first, but trial 2 succeeded.
Feel free to discard the Pull Request if you find it too invasive, and/or hit me up on Google Chat / email if you have general questions regarding Travis.
Cheers, Dirk

@bwlewis
Owner

Hi Dirk,

I'll review later this week. I think it will be fine. I like the idea of controlling tests with an environment variable.

@bwlewis bwlewis merged commit 7ba9e2d into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
1  .Rbuildignore
@@ -0,0 +1 @@
+.travis.yml
View
1  .Rinstignore
@@ -1 +0,0 @@
-test
View
33 .travis.yml
@@ -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
3  DESCRIPTION
@@ -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
6 inst/test/runTest.R
@@ -1,6 +0,0 @@
-require(rredis)
-require(RUnit)
-runTestFile('basicTest.R')
-runTestFile('zsetTest.R')
-runTestFile('setTest.R')
-runTestFile('endTest.R')
View
0  inst/test/basicTest.R → inst/test/runit.basicTest.R
File renamed without changes
View
0  inst/test/bitopTest.R → inst/test/runit.bitopTest.R
File renamed without changes
View
0  inst/test/endTest.R → inst/test/runit.endTest.R
File renamed without changes
View
0  inst/test/setTest.R → inst/test/runit.setTest.R
File renamed without changes
View
0  inst/test/zsetTest.R → inst/test/runit.zsetTest.R
File renamed without changes
View
42 tests/runUnitTests.R
@@ -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!")
+ }
+}
Something went wrong with that request. Please try again.