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

Fix #75 #77

Merged
merged 1 commit into from
Feb 24, 2023
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
34 changes: 21 additions & 13 deletions R/installation.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@
} else {
lib_as_character <- paste0("\"", lib, "\"")
}
if(!is.null(rang$bioc_version)){
if(!is.null(rang$bioc_version)) {
bioc_txt <- paste0(", bioc_mirror = \"", bioc_mirror,rang$bioc_version,"/","\"")
} else{
} else {
bioc_txt <- NULL
}
writeLines(paste0("## rang::export_rang(rang = rang, path = \"", path, "\", verbose = ",
Expand Down Expand Up @@ -226,7 +226,7 @@
source = source, uid = uid,
cache_dir = cache_dir, verbose = verbose)
}
if(source == "bioc"){
if(source == "bioc") {
.cache_pkg_bioc(x = x, version = version, cache_dir = cache_dir,
bioc_mirror = bioc_mirror,bioc_version = rang$bioc_version, verbose = verbose)
}
Expand Down Expand Up @@ -268,16 +268,16 @@
return(dockerfile_content)
}

.generate_docker_readme <- function(output_dir,image){
file.create(file.path(output_dir,"README"))
con <- file(file.path(output_dir,"README"), open="w")
readme <- readLines(system.file("readme_template.txt", package = "rang"))
readme <- gsub("__DATE__",Sys.Date(),readme)
readme <- gsub("__OUTPUT__",output_dir,readme)
readme <- gsub("__IMAGE__",image,readme)
writeLines(readme,file.path(output_dir,"README"))
close(con)
invisible(readme)
.generate_docker_readme <- function(output_dir,image) {
file.create(file.path(output_dir,"README"))
con <- file(file.path(output_dir,"README"), open="w")
readme <- readLines(system.file("readme_template.txt", package = "rang"))
readme <- gsub("__DATE__",Sys.Date(),readme)
readme <- gsub("__OUTPUT__",output_dir,readme)
readme <- gsub("__IMAGE__",image,readme)
writeLines(readme,file.path(output_dir,"README"))
close(con)
invisible(readme)
}

#' Export The Resolved Result As Installation Script
Expand Down Expand Up @@ -314,6 +314,10 @@ export_rang <- function(rang, path, rang_as_comment = TRUE, verbose = TRUE, lib
if (utils::compareVersion(rang$r_version, "2.1") == -1) {
stop("`export_rang` doesn't support this R version (yet).")
}
if (length(rang$ranglets) == 0) {
warning("Nothing to export.")
return(invisible(NULL))
}
cran_mirror <- .normalize_url(cran_mirror)
if (isTRUE(check_cran_mirror)) { ## probably need to stop this also if #17 is implemented
if (isFALSE(.query_mirror_validity(cran_mirror))) {
Expand Down Expand Up @@ -381,6 +385,10 @@ dockerize <- function(rang, output_dir, materials_dir = NULL, image = c("r-ver",
rang_as_comment = TRUE, cache = FALSE, verbose = TRUE, lib = NA,
cran_mirror = "https://cran.r-project.org/", check_cran_mirror = TRUE,
bioc_mirror = "https://bioconductor.org/packages/") {
if (length(rang$ranglets) == 0) {
warning("Nothing to dockerize.")
return(invisible(NULL))
}
if (missing(output_dir)) {
stop("You must provide `output_dir`.", call. = FALSE)
}
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test_dockerize.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ test_that("defensive programming", {
expect_error(dockerize(graph, output_dir = tempdir()))
})

test_that("empty rang dockerize #75", {
graph <- readRDS("../testdata/rang_ok.RDS")
graph$ranglets <- list()
expect_warning(x <- dockerize(graph, output_dir = .generate_temp_dir()))
expect_equal(x, NULL)
})

test_that("integration of #13 in dockerize()", {
rang_ok <- readRDS("../testdata/rang_ok.RDS")
temp_dir <- .generate_temp_dir()
Expand Down
13 changes: 10 additions & 3 deletions tests/testthat/test_expost_rang.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,16 @@ test_that("issue #38", {
})

test_that("Bioconductor <2.0",{
expect_error(.bioc_package_history(bioc_version = "1.9"))
expect_error(.bioc_package_history(bioc_version = "1.9"))
})

test_that("Bioconductor new release",{
expect_equal(.query_biocver("2023-01-01")$version,"3.16")
})
expect_equal(.query_biocver("2023-01-01")$version,"3.16")
})

test_that("empty rang export, #75", {
graph <- readRDS("../testdata/rang_ok.RDS")
graph$ranglets <- list()
expect_warning(x <- export_rang(graph, path = tempfile()))
expect_equal(x, NULL)
})