Skip to content

Commit

Permalink
Fix #587
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Nov 27, 2018
1 parent b4cec1c commit 69ec117
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
14 changes: 11 additions & 3 deletions R/drake_debug.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#' @title Run a single target's command in debug mode.
#' @description Also load the target's dependencies beforehand.
#' @description `drake_debug()` loads a target's dependencies
#' and then runs its command in debug mode (see `browser()`,
#' `debug()`, and `debugonce()`). This function does not
#' store the target's value in the cache
#' (see <https://github.com/ropensci/drake/issues/587>).
#' @export
#' @seealso [drake_build()]
#' @return The value of the target right after it is built.
Expand Down Expand Up @@ -57,8 +61,12 @@ drake_debug <- function(
jobs = jobs,
replace = replace
)
index <- which(config$plan$target == target)
config$plan$command[[index]] <- debug_command(config$plan$command[[index]])
config$layout[[target]]$command_build <- preprocess_command(
debug_command(config$layout[[target]]$command)
)
# Spoof the cache to avoid storage.
# We still want the error handling in build_store().
config$cache <- storr::storr_environment()
build_store(target = target, config = config)
# nocov end
}
Expand Down
6 changes: 5 additions & 1 deletion man/drake_debug.Rd

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

4 changes: 4 additions & 0 deletions tests/testthat/test-always-skipped.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ test_with_dir("drake_debug()", {
clean(destroy = TRUE)
load_mtcars_example()
config <- make(my_plan)
expect_true(config$cache$exists("small"))
clean(small)
expect_false(config$cache$exists("small"))
out <- drake_debug(small, config = config)
expect_false(config$cache$exists("small"))
expect_true(is.data.frame(out))
}
})
Expand Down

0 comments on commit 69ec117

Please sign in to comment.