From ccb5c1f87442f4f889a2d974a52adf368b5edd2c Mon Sep 17 00:00:00 2001 From: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com> Date: Tue, 24 Dec 2024 18:19:40 +0100 Subject: [PATCH] * tests/testthat/test-ablation-cmdline.R: move contents to... * tests/testthat/test-ablation.R: ... here. Avoid 'empty test'. --- tests/testthat/test-ablation-cmdline.R | 15 -------------- tests/testthat/test-ablation.R | 27 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 22 deletions(-) delete mode 100644 tests/testthat/test-ablation-cmdline.R diff --git a/tests/testthat/test-ablation-cmdline.R b/tests/testthat/test-ablation-cmdline.R deleted file mode 100644 index 83ecb525..00000000 --- a/tests/testthat/test-ablation-cmdline.R +++ /dev/null @@ -1,15 +0,0 @@ -withr::with_output_sink("test-ablation-cmdline.Rout", { - skip_on_cran() - - test_that("--help", { - expect_no_warning(ablation_cmdline("--help")) - }) - - test_that("--log-file=sann.rda", { - logfile <- system.file(package="irace", mustWork = TRUE, file.path("exdata","sann.rda")) - outfile <- withr::local_tempfile(pattern = "log-ablation", fileext = ".Rdata") - plotfile <- withr::local_tempfile(pattern = "ablation", fileext = ".pdf") - expect_no_warning( - ablation_cmdline(paste0("--log-file=", logfile, " -o ", outfile, " -p ", plotfile))) - }) -}) # withr::with_output_sink() diff --git a/tests/testthat/test-ablation.R b/tests/testthat/test-ablation.R index efa35b0e..b0b487d7 100644 --- a/tests/testthat/test-ablation.R +++ b/tests/testthat/test-ablation.R @@ -1,16 +1,29 @@ withr::with_output_sink("test-ablation.Rout", { skip_on_cran() - + withr::local_options(warn=2) + logfile <- system.file(package="irace", mustWork = TRUE, "exdata", "sann.rda") + outfile <- withr::local_tempfile(pattern = "log-ablation", fileext = ".Rdata") + test_that("ablation('sann.rda')", { - logfile <- system.file(package="irace", mustWork = TRUE, file.path("exdata","sann.rda")) - outfile <- withr::local_tempfile(pattern = "log-ablation", fileext = ".Rdata") - expect_no_warning(res <- ablation(logfile, ablationLogFile = outfile)) + res <- ablation(logfile, ablationLogFile = outfile) + expect_true(res$complete) }) + test_that("ablation('sann.rda') src,target as character", { - logfile <- system.file(package="irace", mustWork = TRUE, file.path("exdata","sann.rda")) - outfile <- withr::local_tempfile(pattern = "log-ablation", fileext = ".Rdata") src_file <- withr::local_tempfile(pattern="src", fileext=".txt", lines=c("tmax temp", "1 1")) target_file <- withr::local_tempfile(pattern="target", fileext=".txt", lines=c("tmax temp", "100 100")) - expect_no_warning(res <- ablation(logfile, ablationLogFile = outfile, src = src_file, target = target_file)) + res <- ablation(logfile, ablationLogFile = outfile, src = src_file, target = target_file) + expect_true(res$complete) + }) + + test_that("--help", { + expect_output(ablation_cmdline("--help")) + }) + + test_that("--log-file=sann.rda", { + plotfile <- withr::local_tempfile(pattern = "ablation", fileext = ".pdf") + res <- ablation_cmdline(paste0("--log-file=", logfile, " -o ", outfile, " -p ", plotfile)) + expect_true(res$complete) }) + }) # withr::with_output_sink()