File: Rcpp-unitTests.R

package info (click to toggle)
rcpp 0.11.3-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 9,948 kB
  • ctags: 16,427
  • sloc: ansic: 42,692; cpp: 34,078; makefile: 32; sh: 21
file content (56 lines) | stat: -rw-r--r-- 2,097 bytes parent folder | download
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
### R code from vignette source 'Rcpp-unitTests.Rnw'

###################################################
### code chunk number 1: Rcpp-unitTests.Rnw:13-17
###################################################
require(Rcpp)
prettyVersion <- packageDescription("Rcpp")$Version
prettyDate <- format(Sys.Date(), "%B %e, %Y")
library(RUnit)


###################################################
### code chunk number 2: unitTesting
###################################################
pkg <- "Rcpp"

if( Sys.getenv( "TRAVIS" ) == "true" ){
  writeLines( "not running any tests as part of checking the vignette when doing continuous integration with travis" )
} else {  
  
  ## Check the environemnt variable to see if all tests should be run
  if (Sys.getenv("RunAllRcppTests") != "yes") {
      writeLines("The environment variable 'RunAllRcppTests' was not set to 'yes', so skipping some tests.")
  }
  
  if (file.exists("unitTests-results")) unlink("unitTests-results", recursive = TRUE)
  dir.create("unitTests-results")
  path <- system.file("unitTests", package=pkg)
  testSuite <- defineTestSuite(name=paste(pkg, "unit testing"), dirs=path)
  tests <- runTestSuite(testSuite)
  err <- getErrors(tests)
  if (err$nFail > 0) stop(sprintf("unit test problems: %d failures", err$nFail))
  if (err$nErr > 0) stop( sprintf("unit test problems: %d errors", err$nErr))
  printHTMLProtocol(tests, fileName=sprintf("unitTests-results/%s-unitTests.html", pkg))
  printTextProtocol(tests, fileName=sprintf("unitTests-results/%s-unitTests.txt" , pkg))
  
  #if (file.exists("/tmp")) {
  #    invisible(sapply(c("txt", "html"), function(ext) {
  #        fname <- sprintf("unitTests-results/%s-unitTests.%s", pkg, ext)
  #        file.copy(fname, "/tmp", overwrite=TRUE)
  #    }))
  #}
}


###################################################
### code chunk number 3: importResults
###################################################
results <- "unitTests-results/Rcpp-unitTests.txt"
if (file.exists(results)) {
    writeLines(readLines(results))
} else{
    writeLines("Unit test results not available")
}