Commit b05d5530 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

test(style): minor typo revisions in regression tests

Showing with 12 additions and 15 deletions
+12 -15
...@@ -45,7 +45,7 @@ StoreTopicResults <- function(topic, package, path, run.dontrun = TRUE, run.dont ...@@ -45,7 +45,7 @@ StoreTopicResults <- function(topic, package, path, run.dontrun = TRUE, run.dont
cat("*", topic, "\n") cat("*", topic, "\n")
cat("*******************************\n") cat("*******************************\n")
par(ask=F) #https://stackoverflow.com/questions/34756905/how-to-turn-off-the-hit-return-to-see-next-plot-prompt-plot3d par(ask = FALSE) #https://stackoverflow.com/questions/34756905/how-to-turn-off-the-hit-return-to-see-next-plot-prompt-plot3d
varBefore <- c() varBefore <- c()
varBefore <- ls(envir = globalenv()) varBefore <- ls(envir = globalenv())
...@@ -60,7 +60,7 @@ StoreTopicResults <- function(topic, package, path, run.dontrun = TRUE, run.dont ...@@ -60,7 +60,7 @@ StoreTopicResults <- function(topic, package, path, run.dontrun = TRUE, run.dont
varToSave <- setdiff(varAfter, varBefore) varToSave <- setdiff(varAfter, varBefore)
if(length(varToSave) > 0) { if (length(varToSave) > 0) {
path <- file.path(path, topic) path <- file.path(path, topic)
dir.create(path, showWarnings = FALSE, recursive = TRUE) dir.create(path, showWarnings = FALSE, recursive = TRUE)
lapply(varToSave, function(x) { lapply(varToSave, function(x) {
......
context("Compare example outputs with CRAN") context("Compare example outputs with CRAN")
CompareWithRef <- function(refVarFile, testDir, regIgnore) { CompareWithRef <- function(refVarFile, testDir, regIgnore) {
v <- data.frame( v <- data.frame(topic = basename(dirname(refVarFile)),
topic = basename(dirname(refVarFile)), var = gsub("\\.rds$", "", basename(refVarFile)))
var = gsub("\\.rds$", "", basename(refVarFile)) if (is.null(regIgnore) || all(apply(regIgnore, 1, function(x) !all(x == v)))) {
)
if(is.null(regIgnore) || all(apply(regIgnore, 1, function(x) {!all(x == v)}))) {
test_that(paste("Compare", v$topic, v$var), { test_that(paste("Compare", v$topic, v$var), {
skip_on_cran() skip_on_cran()
testVarFile <- paste0( testVarFile <- paste0(
...@@ -13,7 +11,7 @@ CompareWithRef <- function(refVarFile, testDir, regIgnore) { ...@@ -13,7 +11,7 @@ CompareWithRef <- function(refVarFile, testDir, regIgnore) {
".rds" ".rds"
) )
expect_true(file.exists(testVarFile)) expect_true(file.exists(testVarFile))
if(file.exists(testVarFile)) { if (file.exists(testVarFile)) {
testVar <- readRDS(testVarFile) testVar <- readRDS(testVarFile)
refVar <- readRDS(refVarFile) refVar <- readRDS(refVarFile)
expect_equivalent(testVar, refVar) expect_equivalent(testVar, refVar)
...@@ -22,15 +20,14 @@ CompareWithRef <- function(refVarFile, testDir, regIgnore) { ...@@ -22,15 +20,14 @@ CompareWithRef <- function(refVarFile, testDir, regIgnore) {
} }
} }
if(dir.exists("../tmp/ref") & dir.exists("../tmp/test")) { if (dir.exists("../tmp/ref") & dir.exists("../tmp/test")) {
refVarFiles <- list.files("../tmp/ref", recursive = TRUE, full.names = TRUE) refVarFiles <- list.files("../tmp/ref", recursive = TRUE, full.names = TRUE)
regIgnoreFile <- "../../.regressionignore2" regIgnoreFile <- "../../.regressionignore2"
if(file.exists(regIgnoreFile)) { if (file.exists(regIgnoreFile)) {
regIgnore <- read.table( regIgnore <- read.table(file = regIgnoreFile,
file = regIgnoreFile, sep = " ", header = FALSE, skip = 5,
sep = " ", header = FALSE, skip = 5, col.names = c("topic", "var"), col.names = c("topic", "var"),
stringsAsFactors = FALSE stringsAsFactors = FALSE)
)
} else { } else {
regIgnore <- NULL regIgnore <- NULL
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment