- Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathdoRUnit.R
41 lines (31 loc) · 976 Bytes
/
doRUnit.R
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!")
}