Skip to content

Commit

Permalink
Migrate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed May 15, 2024
1 parent 3739214 commit 020098e
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 54 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Depends:
Imports:
base64url,
digest (>= 0.6.21),
igraph,
igraph (>= 2.0.0),
methods,
parallel,
rlang (>= 0.2.0),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ importFrom(igraph,make_empty_graph)
importFrom(igraph,set_vertex_attr)
importFrom(igraph,simplify)
importFrom(igraph,topo_sort)
importFrom(igraph,union)
importFrom(igraph,vertex_attr)
importFrom(methods,new)
importFrom(methods,setRefClass)
Expand Down
2 changes: 1 addition & 1 deletion R/create_drake_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ cdg_transitive_edges <- function(vertex, edges, args) {
cdg_finalize_graph <- function(edges, targets, args) {
args$logger$disk("finalize graph edges")
file_out <- edges$to[edges$from %in% targets & is_encoded_path(edges$to)]
to <- union(targets, file_out)
to <- base::union(targets, file_out)
args$logger$disk("create igraph")
graph <- igraph::graph_from_data_frame(edges)
args$logger$disk("trim neighborhoods")
Expand Down
2 changes: 1 addition & 1 deletion R/drake_plan.R
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ drake_bind_rows <- function(...) {
flatten_df_list(args, df_env = df_env)
dfs <- df_env$dfs
cols <- lapply(dfs, colnames)
cols <- Reduce(f = union, x = cols)
cols <- Reduce(f = base::union, x = cols)
dfs <- lapply(dfs, fill_cols, cols = cols)
do.call(rbind, dfs)
}
Expand Down
2 changes: 1 addition & 1 deletion R/dynamic.R
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ register_in_graph <- function(target, subtargets, config) {
name = "imported",
value = FALSE
)
config$envir_graph$graph <- igraph::graph.union(
config$envir_graph$graph <- igraph::union(
config$envir_graph$graph,
subgraph
)
Expand Down
4 changes: 2 additions & 2 deletions R/make.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#' For each target that is still problematic (e.g.
#' `https://github.com/rstudio/gt/issues/297`)
#' you can safely run the command in its own special `callr::r()` process.
#' Example: `https://github.com/rstudio/gt/issues/297#issuecomment-497778735`. # nolin
#' Example: `https://github.com/rstudio/gt/issues/297#issuecomment-497778735`. # nolint
#' @section Cache locking:
#' When `make()` runs, it locks the cache so other processes cannot modify it.
#' Same goes for [outdated()], [vis_drake_graph()], and similar functions
Expand Down Expand Up @@ -397,7 +397,7 @@ drake_set_session_info <- function(
#' })
#' }
do_prework <- function(config, verbose_packages) {
for (package in union(c("methods", "drake"), config$packages)) {
for (package in base::union(c("methods", "drake"), config$packages)) {
expr <- as.call(c(
quote(require),
package = package,
Expand Down
2 changes: 1 addition & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#' @importFrom igraph adjacent_vertices as_ids components delete_vertices
#' degree gorder graph_from_adjacency_matrix igraph_opt igraph_options
#' induced_subgraph is_dag make_empty_graph make_ego_graph set_vertex_attr
#' simplify topo_sort V vertex_attr
#' simplify topo_sort union V vertex_attr
#' @importFrom methods new setRefClass
#' @importFrom parallel mclapply
#' @importFrom rlang dots_list enquo eval_tidy expr quo_squash quos trace_back
Expand Down
2 changes: 1 addition & 1 deletion R/predict_runtime.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ register_subtargets_graph2 <- function(target, subtargets, config) {
name = "imported",
value = FALSE
)
config$graph <- igraph::graph.union(config$graph, subgraph)
config$graph <- igraph::union(config$graph, subgraph)
config
}

Expand Down
11 changes: 2 additions & 9 deletions man/make.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions tests/testthat/test-1-interactive.R
Original file line number Diff line number Diff line change
Expand Up @@ -276,22 +276,6 @@ test_with_dir("clustermq error messages get back to main", {
})
}

if (FALSE) {
test_with_dir("forks + lock_envir = informative warning msg", {
skip_on_cran()
# Don't run this test for real because (1) we would have to add
# furrr to "Suggests" and (2) at some point, base R may be patched
# so forking in the parallel package does not give this warning anyway.
# Also, it needs to run outside the RStudio IDE so we can fork processes.
regexp <- "workaround"
plan <- drake_plan(x = parallel::mclapply(1:2, identity, mc.cores = 2))
expect_warning(
make(plan, envir = globalenv(), lock_envir = TRUE),
regexp = regexp
)
})
}

if (FALSE) {
test_with_dir("clean() in interactive mode", {
skip_on_cran()
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-8-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ test_with_dir("cache log files, gc, and make()", {

test_with_dir("try_build() does not need to access cache", {
skip_on_cran() # CRAN gets essential tests only (check time limits).
config <- drake_config(drake_plan(x = 1), lock_envir = FALSE)
config <- drake_config(drake_plan(x = 1))
meta <- drake_meta_(target = "x", config = config)
config$cache <- config$settings$cache_log_file <- NULL
build <- try_build(target = "x", meta = meta, config = config)
Expand Down
15 changes: 5 additions & 10 deletions tests/testthat/test-9-clustermq.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ test_with_dir("clustermq parallelism", {
caching = caching,
envir = e,
verbose = 1L,
garbage_collection = TRUE,
lock_envir = TRUE
garbage_collection = TRUE
)
expect_equal(outdated_impl(config), character(0))
make(
Expand All @@ -55,8 +54,7 @@ test_with_dir("clustermq parallelism", {
jobs = jobs,
caching = caching,
envir = e,
verbose = 1L,
lock_envir = TRUE
verbose = 1L
)
expect_equal(justbuilt(config), character(0))
e$my_plan$command[[2]] <- as.call(
Expand All @@ -68,8 +66,7 @@ test_with_dir("clustermq parallelism", {
jobs = jobs,
caching = caching,
envir = e,
verbose = 1L,
lock_envir = TRUE
verbose = 1L
)
expect_equal(justbuilt(config), "small")
clean(small, cache = config$cache)
Expand All @@ -79,8 +76,7 @@ test_with_dir("clustermq parallelism", {
jobs = jobs,
caching = caching,
envir = e,
verbose = 1L,
lock_envir = TRUE
verbose = 1L
)
expect_equal(justbuilt(config), "small")
}
Expand Down Expand Up @@ -172,8 +168,7 @@ test_with_dir("Start off with non-HPC targets, then go to HPC targets.", {
jobs = jobs,
envir = e,
verbose = 1L,
garbage_collection = TRUE,
lock_envir = TRUE
garbage_collection = TRUE
)
config <- drake_config(e$my_plan, envir = e)
expect_equal(sort(justbuilt(config)), sort(e$my_plan$target))
Expand Down
15 changes: 5 additions & 10 deletions tests/testthat/test-9-future.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ test_with_dir("future package functionality", {
caching = caching[i],
jobs = 1,
verbose = 0L,
session_info = FALSE,
lock_envir = TRUE
session_info = FALSE
)
config <- drake_config(
e$my_plan,
Expand All @@ -40,8 +39,7 @@ test_with_dir("future package functionality", {
caching = caching[i],
jobs = 1,
verbose = 0L,
session_info = FALSE,
lock_envir = TRUE
session_info = FALSE
)
expect_equal(
outdated_impl(config),
Expand All @@ -57,8 +55,7 @@ test_with_dir("future package functionality", {
caching = caching[i],
jobs = 1,
verbose = 0L,
session_info = FALSE,
lock_envir = TRUE
session_info = FALSE
)
expect_equal(justbuilt(config), "small")
}
Expand All @@ -72,8 +69,7 @@ test_with_dir("future package functionality", {
caching = caching[i],
jobs = 1,
verbose = 0L,
session_info = FALSE,
lock_envir = TRUE
session_info = FALSE
)
config <- drake_config(
e$my_plan,
Expand All @@ -82,8 +78,7 @@ test_with_dir("future package functionality", {
caching = caching[i],
jobs = 1,
verbose = 0L,
session_info = FALSE,
lock_envir = TRUE
session_info = FALSE
)
nobuild(config)
}
Expand Down

0 comments on commit 020098e

Please sign in to comment.