Skip to content

Commit

Permalink
update test-target-runner-dummy
Browse files Browse the repository at this point in the history
  • Loading branch information
MLopez-Ibanez committed Sep 20, 2024
1 parent af0baf0 commit 6ccc26c
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions tests/testthat/test-target-runner-dummy.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
withr::with_output_sink("test-target-runner-dummy.Rout", {
skip_on_cran()

get_executable <- function(filename, src_dir = NULL) {
get_executable <- function(filename) {
filename <- paste0(filename, if (system_os_is_windows()) ".exe" else "")
p <- if (.Platform$r_arch == "") file.path( "bin", filename) else file.path("bin", .Platform$r_arch, filename)
res <- system.file(p, package="irace", mustWork = FALSE)
cat("res is null: ", p, "\n")
if (res == "" && !is.null(src_dir)) {
res <- test_path(file.path(src_dir, filename))
list.files(system.file(package="irace", mustWork = FALSE), recursive = TRUE)
cat("res is null and src_dir is given: ", res, "\n")
}
res
system.file(p, package="irace", mustWork = FALSE)
}
runexe <- function(exe, args) {
err <- NULL
Expand Down Expand Up @@ -39,20 +32,22 @@ withr::with_output_sink("test-target-runner-dummy.Rout", {
iraceexe <- get_executable("irace")
skip_if_not(nzchar(iraceexe), "Not run because 'irace' is not installed")
expect_true(file.exists(iraceexe))
skip_on_os("windows")
# FIXME: For some reason, this does not generate any output on Windows
expect_match(paste(collapse="", system2(iraceexe, "--help", stdout = TRUE, stderr = TRUE)),
output <- expect_silent(system2(iraceexe, "--help", stdout = TRUE, stderr = TRUE))
skip_on_os("windows")
expect_match(paste(collapse="", output),
"irace: An implementation in R of.*called with: --help")
})

test_that("ablation exe works", {
ablationexe <- get_executable("ablation")
skip_if_not(nzchar(ablationexe), "Not run because 'ablation' is not installed")
expect_true(file.exists(ablationexe))
skip_on_os("windows")
# FIXME: For some reason, this does not generate any output on Windows
expect_match(paste(collapse="", system2(ablationexe, "--help", stdout = TRUE, stderr = TRUE)),
"ablation: An implementation in R of Ablation Analysis.*called with: --help")
output <- expect_silent(system2(ablationexe, "--help", stdout = TRUE, stderr = TRUE))
skip_on_os("windows")
expect_match(paste(collapse="", output),
"ablation: An implementation in R of Ablation Analysis.*called with: --help")
})

run_cmdline <- function(parameters, args) {
Expand All @@ -67,7 +62,8 @@ withr::with_output_sink("test-target-runner-dummy.Rout", {
' --target-runner=', target_runner_dummy))
}

target_runner_dummy <- get_executable("target-runner-dummy", "../../src/dummy")
target_runner_dummy <- get_executable("target-runner-dummy")
skip_if_not(nzchar(target_runner_dummy), "Not run because 'target-runner-dummy' is not installed")
expect_true(file.exists(target_runner_dummy))

test_that("--check", {
Expand Down Expand Up @@ -156,4 +152,4 @@ withr::with_output_sink("test-target-runner-dummy.Rout", {
"No scenario file given"))
})

}) # withr::with_output_sink()
#}) # withr::with_output_sink()

0 comments on commit 6ccc26c

Please sign in to comment.