From 4df67cf0cf7f97954c34538f57d8830d28fac5ac Mon Sep 17 00:00:00 2001 From: Dorchies David <david.dorchies@irstea.fr> Date: Wed, 15 Jul 2020 10:51:12 +0200 Subject: [PATCH] ci: debug regression tests - distinction between R versions which produce the results to test - add Gitlab artefact instruction for making results available for tests in next jobs in the pipeline Refs #59 --- .gitlab-ci.yml | 4 ++++ tests/testthat/store_examples.R | 6 +++++- tests/testthat/test-regression.R | 9 ++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b17c2029..4b1828ba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,6 +40,10 @@ default: - Rscript -e 'source("tests/testthat/store_examples.R"); StoreRefExampleResults("airGR");' - R CMD INSTALL . - Rscript -e 'source("tests/testthat/store_examples.R"); StoreTestExampleResults("airGR");' + artifacts: + paths: + - tests/tmp/ + expire_in: 1 week .check_not_cran: stage: tests diff --git a/tests/testthat/store_examples.R b/tests/testthat/store_examples.R index ef3632ea..6a7b8e31 100644 --- a/tests/testthat/store_examples.R +++ b/tests/testthat/store_examples.R @@ -4,7 +4,11 @@ StoreRefExampleResults <- function(package, ...) { } StoreTestExampleResults <- function(package, ...) { - StoreExampleResults(package = package, path = "tests/tmp/test", ...) + StoreExampleResults( + package = package, + path = file.path("tests/tmp", Sys.getenv("R_VERSION", "test")), + ... + ) } #' Run examples of a package and store the output variables in RDS files for further testing. diff --git a/tests/testthat/test-regression.R b/tests/testthat/test-regression.R index 1c41c940..866fcdfe 100644 --- a/tests/testthat/test-regression.R +++ b/tests/testthat/test-regression.R @@ -8,7 +8,10 @@ CompareWithRef <- function(refVarFile, testDir, regIgnore) { if(is.null(regIgnore) || all(apply(regIgnore, 1, function(x) {!all(x == v)}))) { test_that(paste("Compare", v$topic, v$var), { skip_on_cran() - testVarFile <- paste0("../tmp/test/", file.path(v$topic, v$var), ".rds") + testVarFile <- paste0( + file.path("../tmp", Sys.getenv("R_VERSION", "test"), v$topic, v$var), + ".rds" + ) expect_true(file.exists(testVarFile)) if(file.exists(testVarFile)) { testVar <- readRDS(testVarFile) @@ -24,8 +27,8 @@ if(dir.exists("../tmp/ref") & dir.exists("../tmp/test")) { regIgnoreFile <- "../../.regressionignore2" if(file.exists(regIgnoreFile)) { regIgnore <- read.table( - file = regIgnoreFile, - sep = " ", header = FALSE, skip = 5, col.names = c("topic", "var"), + file = regIgnoreFile, + sep = " ", header = FALSE, skip = 5, col.names = c("topic", "var"), stringsAsFactors = FALSE ) } else { -- GitLab