Skip to content

Commit

Permalink
Use spinners
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Nov 30, 2023
1 parent e2cdeb9 commit b336368
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions tests/backlog/test-seconds_idle.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@ controller$start()
names <- character(0L)
index <- 0L
n_tasks <- 60000L
spinner <- cli::make_spinner()
system.time(
while (index < n_tasks || !(controller$empty())) {
if (index < n_tasks) {
index <- index + 1L
# cat("submit", index, "\n") # nolint
spinner$spin()
controller$push(
name = as.character(index),
command = Sys.sleep(0.005)
)
}
out <- controller$pop()
if (!is.null(out)) {
# cat("collect", out$name, "\n") # nolint
spinner$spin()
names[[length(names) + 1L]] <- out$name
}
}
)
spinner$finish()
testthat::expect_equal(sort(as.integer(names)), seq_len(n_tasks))
controller$launcher$workers$launched <- FALSE
controller$launcher$tally()
Expand Down
6 changes: 4 additions & 2 deletions tests/backlog/test-tasks_max.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@ controller$start()
names <- character(0L)
index <- 0L
n_tasks <- 60000L
spinner <- cli::make_spinner()
system.time(
while (index < n_tasks || !(controller$empty())) {
if (index < n_tasks) {
index <- index + 1L
# cat("submit", index, "\n") # nolint
spinner$spin()
controller$push(
name = as.character(index),
command = TRUE
)
}
out <- controller$pop()
if (!is.null(out)) {
# cat("collect", out$name, "\n") # nolint
spinner$spin()
names[[length(names) + 1L]] <- out$name
}
}
)
spinner$finish()
testthat::expect_equal(sort(as.integer(names)), seq_len(n_tasks))
controller$launcher$workers$launched <- FALSE
controller$launcher$tally()
Expand Down

0 comments on commit b336368

Please sign in to comment.