File: runUnitTests.R

package info (click to toggle)
r-cran-kutils 1.73%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,648 kB
  • sloc: sh: 13; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 985 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## Run unit tests
## Charlie Redmon
## 20170802

if (!require("RUnit", quietly = TRUE)) {
  warning("Cannot run unit tests. Package RUnit is not available.")
  q('no')
}

library(kutils)

path <- system.file(package="kutils", "unitTests")
stopifnot(file.exists(path), file.info(path.expand(path))$isdir)

testsuite.variableKey <- defineTestSuite("VariableKey",
                                         dirs=path,
                                         testFileRegexp="^runit.+\\.R",
                                         testFuncRegexp="^test.+",
                                         rngKind="Marsaglia-Multicarry",
                                         rngNormalKind="Kinderman-Ramage")

testResult <- runTestSuite(testsuite.variableKey)
printTextProtocol(testResult, showDetails=TRUE)

tmp <- getErrors(testResult)
if (tmp$nFail > 0 | tmp$nErr > 0) {
  stop(paste0("\n\nUnit testing failed (", tmp$nFail, " test failures), ",
              tmp$nErr, " R errors)\n\n"))
}