File: doRUnit.R

package info (click to toggle)
r-cran-rcppparallel 5.1.7%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 544 kB
  • sloc: cpp: 1,852; sh: 19; makefile: 11
file content (41 lines) | stat: -rw-r--r-- 976 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
30
31
32
33
34
35
36
37
38
39
40
41
stopifnot(require(RUnit, quietly = TRUE))
stopifnot(require(Rcpp, quietly = TRUE))
stopifnot(require(RcppParallel, quietly = TRUE))

## Set a seed to make the test deterministic
set.seed(42)

## Set a default backend
backend <- Sys.getenv("RCPP_PARALLEL_BACKEND", unset = NA)
if (is.na(backend))
   Sys.setenv(RCPP_PARALLEL_BACKEND = "tinythread")

writeLines(paste("Using backend:", Sys.getenv("RCPP_PARALLEL_BACKEND")))

## Define tests
suite <- defineTestSuite(
   name = "RcppParallel Unit Tests",
   dirs = system.file("tests", package = "RcppParallel")
)

## Based on practice in Rcpp to avoid some test failures
Sys.setenv("R_TESTS" = "")

## Run tests
tests <- runTestSuite(suite)

## 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!")
}