From d52926094d51d21be79ff3d152278ffb53cb831b Mon Sep 17 00:00:00 2001 From: RichardHooijmaijers Date: Tue, 12 Nov 2024 15:05:27 +0100 Subject: [PATCH] adapted test for CRAN note --- CRAN-SUBMISSION | 4 ++-- tests/testthat/test-fit_plot.R | 5 ++++- tests/testthat/test-gof_plot.R | 4 +++- tests/testthat/test-module_dataexplore.R | 6 +++++- tests/testthat/test-module_metadata.R | 6 +++++- tests/testthat/test-module_report.R | 6 +++++- tests/testthat/test-module_run.R | 6 +++++- tests/testthat/test-module_script.R | 6 +++++- tests/testthat/test-module_settings.R | 6 +++++- tests/testthat/test-par_table.R | 4 +++- tests/testthat/test-run_nmx.R | 6 +++++- tests/testthat/test-shinymixr-01-model-run1.R | 4 +++- tests/testthat/test-shinymixr-02-parameter-table.R | 4 +++- tests/testthat/test-shinymixr-03-create-newmodel.R | 4 +++- tests/testthat/test-tree_overview.R | 4 +++- tests/testthat/test-update_inits.R | 6 +++--- 16 files changed, 62 insertions(+), 19 deletions(-) diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index c9b277d..e64ff55 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ Version: 0.5.0 -Date: 2024-11-08 13:46:24 UTC -SHA: 77cac2504d77bc8301d9c307e501011cad46af71 +Date: 2024-11-11 14:52:47 UTC +SHA: 6383cfbb58ebad20005d83d85265f7f010208320 diff --git a/tests/testthat/test-fit_plot.R b/tests/testthat/test-fit_plot.R index 49c8394..91d3668 100644 --- a/tests/testthat/test-fit_plot.R +++ b/tests/testthat/test-fit_plot.R @@ -37,6 +37,9 @@ test_that("fit_plot works as expected", { expect_true(file.exists(paste0(temp_dir, "/analysis/test_model/fit_plot.html"))) # remove directory - unlink(paste0(temp_dir, "/analysis"), recursive = TRUE) + #unlink(paste0(temp_dir, "/analysis"), recursive = TRUE) + rml <- list.files(temp_dir, recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) + }) \ No newline at end of file diff --git a/tests/testthat/test-gof_plot.R b/tests/testthat/test-gof_plot.R index 37152fa..77d0963 100644 --- a/tests/testthat/test-gof_plot.R +++ b/tests/testthat/test-gof_plot.R @@ -60,6 +60,8 @@ test_that("gof_plot works as expected", { expect_true(file.exists(paste0(temp_dir, "/analysis/test_model/gof_plot.html"))) # remove directory - unlink(paste0(temp_dir, "/analysis"), recursive = TRUE) + #unlink(paste0(temp_dir, "/analysis"), recursive = TRUE) + rml <- list.files(temp_dir, recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) }) diff --git a/tests/testthat/test-module_dataexplore.R b/tests/testthat/test-module_dataexplore.R index e5dd141..7eac47e 100644 --- a/tests/testthat/test-module_dataexplore.R +++ b/tests/testthat/test-module_dataexplore.R @@ -1,4 +1,6 @@ test_that("Can run a data exploration", { + # Don't run these tests on the CRAN build servers + skip_on_cran() temp_dir <- tempdir() @@ -107,6 +109,8 @@ test_that("Can run a data exploration", { }) }) - unlink(paste0(temp_dir, "/files"), recursive = TRUE) + #unlink(paste0(temp_dir, "/files"), recursive = TRUE) + rml <- list.files(temp_dir, recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) }) \ No newline at end of file diff --git a/tests/testthat/test-module_metadata.R b/tests/testthat/test-module_metadata.R index efb88d6..6cd85b4 100644 --- a/tests/testthat/test-module_metadata.R +++ b/tests/testthat/test-module_metadata.R @@ -1,4 +1,6 @@ test_that("Shiny app handles meta data correctly", { + # Don't run these tests on the CRAN build servers + skip_on_cran() temp_dir <- tempdir() @@ -33,5 +35,7 @@ test_that("Shiny app handles meta data correctly", { }) - unlink(paste0(temp_dir, "/files"), recursive = TRUE) + #unlink(paste0(temp_dir, "/files"), recursive = TRUE) + rml <- list.files(temp_dir, recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) }) diff --git a/tests/testthat/test-module_report.R b/tests/testthat/test-module_report.R index a5b0367..b1d1535 100644 --- a/tests/testthat/test-module_report.R +++ b/tests/testthat/test-module_report.R @@ -1,5 +1,7 @@ test_that("Shiny app creates plot and runs report", { + # Don't run these tests on the CRAN build servers + skip_on_cran() temp_dir <- tempdir() @@ -126,6 +128,8 @@ test_that("Shiny app creates plot and runs report", { expect_equal(file.exists(paste0(temp_dir, "/files/analysis/run1/TestReport.html")), TRUE) }) - unlink(paste0(temp_dir, "/files"), recursive = TRUE) + #unlink(paste0(temp_dir, "/files"), recursive = TRUE) + rml <- list.files(temp_dir, recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) }) \ No newline at end of file diff --git a/tests/testthat/test-module_run.R b/tests/testthat/test-module_run.R index b5ef1ab..b8b719b 100644 --- a/tests/testthat/test-module_run.R +++ b/tests/testthat/test-module_run.R @@ -1,4 +1,6 @@ test_that("Shiny app runs model", { + # Don't run these tests on the CRAN build servers + skip_on_cran() temp_dir <- tempdir() @@ -48,6 +50,8 @@ test_that("Shiny app runs model", { expect_true(file.exists(paste0(temp_dir, "/files/shinyMixR/run1.ressum.rds"))) }) - unlink(paste0(temp_dir, "/files"), recursive = TRUE) + #unlink(paste0(temp_dir, "/files"), recursive = TRUE) + rml <- list.files(temp_dir, recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) }) diff --git a/tests/testthat/test-module_script.R b/tests/testthat/test-module_script.R index 0abb09d..231f3bc 100644 --- a/tests/testthat/test-module_script.R +++ b/tests/testthat/test-module_script.R @@ -1,4 +1,6 @@ test_that("Shiny app runs model and returns parameters for run1", { + # Don't run these tests on the CRAN build servers + skip_on_cran() temp_dir <- tempdir() @@ -47,6 +49,8 @@ test_that("Shiny app runs model and returns parameters for run1", { }) - unlink(paste0(temp_dir, "/files"), recursive = TRUE) + #unlink(paste0(temp_dir, "/files"), recursive = TRUE) + rml <- list.files(temp_dir, recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) }) \ No newline at end of file diff --git a/tests/testthat/test-module_settings.R b/tests/testthat/test-module_settings.R index 20df557..560555b 100644 --- a/tests/testthat/test-module_settings.R +++ b/tests/testthat/test-module_settings.R @@ -1,4 +1,6 @@ test_that("Settings are handled correctly", { + # Don't run these tests on the CRAN build servers + skip_on_cran() temp_dir <- tempdir() @@ -22,6 +24,8 @@ test_that("Settings are handled correctly", { expect_true(session$input$fontedt==8) }) - unlink(paste0(temp_dir, "/files"), recursive = TRUE) + #unlink(paste0(temp_dir, "/files"), recursive = TRUE) + rml <- list.files(temp_dir, recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) }) diff --git a/tests/testthat/test-par_table.R b/tests/testthat/test-par_table.R index 7e04626..a1e3294 100644 --- a/tests/testthat/test-par_table.R +++ b/tests/testthat/test-par_table.R @@ -29,6 +29,8 @@ test_that("partable works", { expect_true(file.exists(paste0(tempdir(), "/files/analysis/run1/par_table.html"))) - unlink(paste0(tempdir(), "/files"), recursive = TRUE) + #unlink(paste0(tempdir(), "/files"), recursive = TRUE) + rml <- list.files(tempdir(), recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) }) \ No newline at end of file diff --git a/tests/testthat/test-run_nmx.R b/tests/testthat/test-run_nmx.R index 6550545..7ea5b45 100644 --- a/tests/testthat/test-run_nmx.R +++ b/tests/testthat/test-run_nmx.R @@ -1,4 +1,6 @@ test_that("run_nmx works as expected", { + # Don't run these tests on the CRAN build servers + skip_on_cran() # create project unlink(paste0(tempdir(),"/files"), recursive = TRUE) @@ -39,5 +41,7 @@ test_that("run_nmx works as expected", { expect_true(file.exists(paste0(tempdir(), "/files/shinyMixR/run1.ressum.rds"))) # remove project - unlink(paste0(tempdir(), "/files"), recursive = TRUE) + #unlink(paste0(tempdir(), "/files"), recursive = TRUE) + rml <- list.files(tempdir(), recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) }) diff --git a/tests/testthat/test-shinymixr-01-model-run1.R b/tests/testthat/test-shinymixr-01-model-run1.R index 98519e7..eda75db 100644 --- a/tests/testthat/test-shinymixr-01-model-run1.R +++ b/tests/testthat/test-shinymixr-01-model-run1.R @@ -44,5 +44,7 @@ test_that("Shiny app runs model and returns parameters for run1", { # Stop and clean up app$stop() - unlink(paste0(tempdir(),"/files"), recursive = TRUE) + #unlink(paste0(tempdir(),"/files"), recursive = TRUE) + rml <- list.files(tempdir(), recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) }) diff --git a/tests/testthat/test-shinymixr-02-parameter-table.R b/tests/testthat/test-shinymixr-02-parameter-table.R index 6be705f..ae547b2 100644 --- a/tests/testthat/test-shinymixr-02-parameter-table.R +++ b/tests/testthat/test-shinymixr-02-parameter-table.R @@ -25,5 +25,7 @@ test_that("Shiny app creates correct parameter table", { # Stop and clean up app$stop() - unlink(paste0(tempdir(),"/files"), recursive = TRUE) + #unlink(paste0(tempdir(),"/files"), recursive = TRUE) + rml <- list.files(tempdir(), recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) }) \ No newline at end of file diff --git a/tests/testthat/test-shinymixr-03-create-newmodel.R b/tests/testthat/test-shinymixr-03-create-newmodel.R index 31b9633..718d648 100644 --- a/tests/testthat/test-shinymixr-03-create-newmodel.R +++ b/tests/testthat/test-shinymixr-03-create-newmodel.R @@ -70,5 +70,7 @@ test_that("Shiny app correctly creates new model code", { # Stop and clean up app$stop() - unlink(paste0(temp_dir, "/files"), recursive = TRUE) + #unlink(paste0(temp_dir, "/files"), recursive = TRUE) + rml <- list.files(tempdir(), recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) }) \ No newline at end of file diff --git a/tests/testthat/test-tree_overview.R b/tests/testthat/test-tree_overview.R index 4296b31..e44d133 100644 --- a/tests/testthat/test-tree_overview.R +++ b/tests/testthat/test-tree_overview.R @@ -17,6 +17,8 @@ test_that("tree overview works as expected", { expect_equal(treeview$x$data$children[[1]]$name, "run1") # remove project - unlink(paste0(tempdir(), "/files"), recursive = TRUE) + #unlink(paste0(tempdir(), "/files"), recursive = TRUE) + rml <- list.files(tempdir(), recursive = TRUE, include.dirs = TRUE, full.names = TRUE) + unlink(rml, recursive = TRUE) }) \ No newline at end of file diff --git a/tests/testthat/test-update_inits.R b/tests/testthat/test-update_inits.R index a426980..cd9c146 100644 --- a/tests/testthat/test-update_inits.R +++ b/tests/testthat/test-update_inits.R @@ -6,12 +6,12 @@ test_that("update_inits works as expected", { script <- system.file("other", "run1.r", package = "shinyMixR") res <- system.file("other", "run1.res.rds", package = "shinyMixR") - update_inits(readLines(script), res, paste0(temp_dir, "run2.r")) + update_inits(readLines(script), res, paste0(temp_dir, "/run2.r")) # check if file has been written - expect_true(file.exists(paste0(temp_dir, "run2.r"))) + expect_true(file.exists(paste0(temp_dir, "/run2.r"))) # unlink file - unlink(paste0(temp_dir, "run2.r")) + unlink(paste0(temp_dir, "/run2.r")) }) \ No newline at end of file