Skip to content

Commit

Permalink
more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Dec 5, 2024
1 parent 65550da commit dd3f718
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main]
branches: [main, dev]
pull_request:
branches: [main]
branches: [main, dev]

name: test-coverage

Expand Down
41 changes: 25 additions & 16 deletions tests/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,20 @@ connection && .Platform[["OS.type"]] != "windows" && Sys.getenv("NOT_CRAN") == "
test_equal(daemons()[["connections"]], 2L)
test_type("list", res <- mirai_map(c(1,1), rnorm)[.progress])
test_true(res[[1L]] != res[[2L]])
test_equal(stop_daemon(4L), 2L)
Sys.sleep(0.1)
test_zero(daemons()[["connections"]])
test_zero(daemons(0L))
Sys.sleep(1L)
test_zero(daemons(url = "tls+tcp://127.0.0.1:0", dispatcher = "default"))
test_equal(launch_local(1L), 1L)
Sys.sleep(1L)
test_true(grepl("CERTIFICATE", launch_remote(1L), fixed = TRUE))
q <- quote(list2env(list(b = 2), envir = .GlobalEnv))
m <- mirai("Seattle", .timeout = 1000)
if (!is_error_value(m[])) test_equal(m[], "Seattle")
test_class("errorValue", mirai(q(), .timeout = 1000)[])
test_zero(daemons(0))
}
# TLS tests
connection && Sys.getenv("NOT_CRAN") == "true" && {
Expand Down Expand Up @@ -287,18 +300,6 @@ connection && Sys.getenv("NOT_CRAN") == "true" && {
test_equal(length(nextget("urls")), 1L)
test_class("miraiLaunchCmd", launch_remote(1))
test_zero(daemons(0))
Sys.sleep(1L)
test_zero(daemons(url = "tls+tcp://127.0.0.1:0", dispatcher = "default"))
test_equal(launch_local(3L), 3L)
Sys.sleep(1L)
test_true(grepl("CERTIFICATE", launch_remote(1L), fixed = TRUE))
test_equal(stop_daemon(2L), 2L)
q <- quote(list2env(list(b = 2), envir = .GlobalEnv))
m <- mirai("Seattle", .timeout = 1000)
if (!is_error_value(m[])) test_equal(m[], "Seattle")
test_equal(daemons()[["connections"]], 1L)
test_class("errorValue", mirai(q(), .timeout = 1000)[])
test_zero(daemons(0))
}
# additional stress testing
connection && Sys.getenv("NOT_CRAN") == "true" && {
Expand All @@ -319,22 +320,30 @@ connection && Sys.getenv("NOT_CRAN") == "true" && {
Sys.sleep(1L)
option <- 15L
Sys.setenv(R_DEFAULT_PACKAGES = "stats,utils")
test_equal(1L, daemons(1, dispatcher = "process", maxtasks = 10L, timerstart = 1L, walltime = 500L, seed = 1546, token = TRUE, cleanup = option, autoexit = tools::SIGCONT))
test_equal(2L, daemons(2, dispatcher = "process", maxtasks = 10L, timerstart = 1L, walltime = 500L, seed = 1546, token = TRUE, cleanup = option, autoexit = tools::SIGCONT))
Sys.unsetenv("R_DEFAULT_PACKAGES")
Sys.sleep(1L)
mq <- mirai(runif(1L), .timeout = 1000)
test_true(is.numeric(mq[]))
mq <- mirai(Sys.sleep(0.7), .timeout = 500)
test_class("matrix", status()[["daemons"]])
test_type("character", saisei(i = 2L, force = TRUE))
m <- mirai(mirai::daemon(url), url = nextget("urls")[2L])
Sys.sleep(0.1)
test_null(saisei(i = 1L))
test_type("integer", mirai(1L, .timeout = 500)[])
test_zero(daemons(0))
}
# additional legacy interface tests
connection && .Platform[["OS.type"]] != "windows" && Sys.getenv("NOT_CRAN") == "true" && {
Sys.sleep(1L)
test_equal(daemons(url = host_url(ws = TRUE, tls = TRUE), dispatcher = "thread", output = TRUE), 1L)
test_equal(nextget("n"), 1L)
test_equal(length(nextget("urls")), 1L)
Sys.sleep(1L)
test_class("matrix", status()$daemons)
test_null(saisei(i = 0L))
test_print(saisei(i = 1L))
Sys.sleep(0.1)
test_print(saisei(i = 1L, force = TRUE))
test_type("character", saisei(i = 1L))
Sys.sleep(0.1)
test_zero(daemons(0))
}
Expand Down

0 comments on commit dd3f718

Please sign in to comment.