Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

62 Can no longer pass a list to modules #63

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion R/setupProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ utils::globalVariables(c(
#' Each of these has a sensible default, which will be overridden but any user
#' supplied values.
#' See [setup].
#' @param modules a character string of modules to pass to `getModule`. These
#' @param modules a character vector of modules to pass to `getModule`. These
#' should be one of: simple name (e.g., `fireSense`) which will be searched for locally
#' in the `paths[["modulePath"]]`; or a GitHub repo with branch (`GitHubAccount/Repo@branch` e.g.,
#' `"PredictiveEcology/Biomass_core@development"`); or a character vector that identifies
Expand Down Expand Up @@ -1220,6 +1220,11 @@ setupModules <- function(name, paths, modules, inProject, useGit = getOption("Sp
}

anyfailed <- character()

if(!is(modules, "character")) {
stop("'modules' must be a character vector.")
}

modulesOrig <- modules
modulesOrigPkgName <- extractPkgName(modulesOrig)
modulesOrigNestedName <- extractModName(modulesOrig)
Expand Down
25 changes: 25 additions & 0 deletions tests/testthat/test-setupProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,31 @@ test_that("test setupProject - load packages using require argument", {

})

test_that("test setupProject - pass modules as a list", {
skip_on_cran()
setupTest()
## load packages using `require` argument -- now loads SpaDES.core & reproducible
mess <- capture_messages({
out <- setupProject(
paths = list(projectPath = paste0("testList", .rndstr(1))), # will deduce name of project from projectPath
modules = c("PredictiveEcology/Biomass_speciesData@master",
"PredictiveEcology/Biomass_borealDataPrep@development"))
})

expect_true(all(dir(out$paths$modulePath) %in% Require::extractPkgName(out$modules)))

errs <- capture_error({
out <- setupProject(
paths = list(projectPath = paste0("testList2", .rndstr(1))), # will deduce name of project from projectPath
modules = list("PredictiveEcology/Biomass_speciesData@master",
"PredictiveEcology/Biomass_borealDataPrep@development"))
})

expect_true(length(errs) > 0)
expect_true(grepl("'modules' must be a character vector", errs))
})


test_that("test setupProject - studyArea in lonlat", {
skip_on_cran()
setupTest(c("geodata", "filelock", "reproducible")) # filelock is unnecessary "first time", but errors if run again
Expand Down
Loading