Skip to content

Commit

Permalink
* tests/testthat/test-ablation-cmdline.R: move contents to...
Browse files Browse the repository at this point in the history
 * tests/testthat/test-ablation.R: ... here. Avoid 'empty test'.
  • Loading branch information
MLopez-Ibanez committed Dec 25, 2024
1 parent ecae935 commit ccb5c1f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
15 changes: 0 additions & 15 deletions tests/testthat/test-ablation-cmdline.R

This file was deleted.

27 changes: 20 additions & 7 deletions tests/testthat/test-ablation.R
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit ccb5c1f

Please sign in to comment.