|
1 |
| -#### doRUnit.R --- Run RUnit tests |
2 |
| -####------------------------------------------------------------------------ |
3 | 1 |
|
4 |
| -### borrowed from package fUtilities in RMetrics |
5 |
| -### http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/pkg/fUtilities/tests/doRUnit.R?rev=1958&root=rmetrics&view=markup |
| 2 | +if (requireNamespace("tinytest", quietly=TRUE) && |
| 3 | + utils::packageVersion("tinytest") >= "1.0.0") { |
6 | 4 |
|
7 |
| -### Originally follows Gregor Gojanc's example in CRAN package 'gdata' |
8 |
| -### and the corresponding section in the R Wiki: |
9 |
| -### http://wiki.r-project.org/rwiki/doku.php?id=developers:runit |
| 5 | + ## Set a seed to make the test deterministic |
| 6 | + set.seed(42) |
10 | 7 |
|
11 |
| -### MM: Vastly changed: This should also be "runnable" for *installed* |
12 |
| -## package which has no ./tests/ |
13 |
| -## ----> put the bulk of the code e.g. in ../inst/unitTests/runTests.R : |
| 8 | + ## R makes us to this |
| 9 | + Sys.setenv("R_TESTS"="") |
14 | 10 |
|
15 |
| -if(require("RUnit", quietly = TRUE)) { |
16 |
| - pkg <- "RcppEigen" |
17 |
| - |
18 |
| - require( pkg, character.only=TRUE) |
19 |
| - |
20 |
| - path <- system.file("unitTests", package = pkg) |
21 |
| - |
22 |
| - stopifnot(file.exists(path), file.info(path.expand(path))$isdir) |
23 |
| - |
24 |
| - ## without this, we get unit test failures |
25 |
| - Sys.setenv( R_TESTS = "" ) |
26 |
| - |
27 |
| - RcppEigen.unit.test.output.dir <- getwd() |
28 |
| - |
29 |
| - source(file.path(path, "runTests.R"), echo = TRUE) |
30 |
| - |
31 |
| -} else { |
32 |
| - print( "package RUnit not available, cannot run unit tests" ) |
| 11 | + ## there are several more granular ways to test files in a tinytest directory, |
| 12 | + ## see its package vignette; tests can also run once the package is installed |
| 13 | + ## using the same command `test_package(pkgName)`, or by director or file |
| 14 | + tinytest::test_package("RcppEigen", ncpu=getOption("Ncpus", 1)) |
33 | 15 | }
|
0 commit comments