Skip to content

Commit

Permalink
* tests/testthat/test-target-runner-dummy.R: Run more tests on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
MLopez-Ibanez committed Jan 23, 2025
1 parent d779074 commit 52d3cc0
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tests/testthat/test-target-runner-dummy.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ withr::with_output_sink("test-target-runner-dummy.Rout", {
skip_if_not(nzchar(iraceexe), "Not run because 'irace' is not installed")
expect_true(file.exists(iraceexe))
# FIXME: For some reason, this does not generate any output on Windows
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")
output <- expect_silent(runexe(iraceexe, "--help"))
expected_output <- if (system_os_is_windows()) "^$"
else "irace: An implementation in R.*called with: --help"
expect_match(paste(collapse="", output), expected_output)
})

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))
# FIXME: For some reason, this does not generate any output on Windows
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")
output <- expect_silent(runexe(ablationexe, "--help"))
expected_output <- if (system_os_is_windows()) "^$"
else "ablation: An implementation in R of Ablation Analysis.*called with: --help"
expect_match(paste(collapse="", output), expected_output)
})

run_cmdline <- function(parameters, args) {
Expand All @@ -65,7 +65,7 @@ withr::with_output_sink("test-target-runner-dummy.Rout", {
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", {
expect_warning(
run_cmdline(paste0('p_int "--p_int " i (1, 10)\n',
Expand All @@ -91,7 +91,7 @@ withr::with_output_sink("test-target-runner-dummy.Rout", {
'capping "--opt-time " c (1)\n'),
'--max-time 1000 --bound-max 100 --capping 1'),
"is too large"),
"No scenario file given")
"No scenario file given")
})
test_that("--capping", {
expect_warning(
Expand Down Expand Up @@ -120,7 +120,7 @@ withr::with_output_sink("test-target-runner-dummy.Rout", {
'capping "--opt-time " c (1)\n'),
'--max-time 500 --bound-max 1 --capping 1 '),
"With the current settings and estimated time per run"),
"No scenario file given")
"No scenario file given")
})
test_that("Error cost time", {
expect_error(
Expand Down Expand Up @@ -151,5 +151,5 @@ withr::with_output_sink("test-target-runner-dummy.Rout", {
'--min-experiments 50'),
"No scenario file given"))
})

}) # withr::with_output_sink()

0 comments on commit 52d3cc0

Please sign in to comment.