diff --git a/R/resolve.R b/R/resolve.R index 0fd85c2..5ebafca 100644 --- a/R/resolve.R +++ b/R/resolve.R @@ -475,13 +475,18 @@ query_sysreqs <- function(rang, os = "ubuntu-20.04") { } pkgs <- .memo_search_bioc(bioc_version = "release") raw_sys_reqs <- pkgs$SystemRequirements[pkgs$Package %in% handles] - baseurl <- "https://sysreqs.r-hub.io/map/" singleline_sysreqs <- paste0(raw_sys_reqs[!is.na(raw_sys_reqs)], collapse = ", ") singleline_sysreqs <- gsub("\\n", " ", singleline_sysreqs) + .query_singleline_sysreqs(singleline_sysreqs = singleline_sysreqs, arch = arch) +} + +.query_singleline_sysreqs <- function(singleline_sysreqs, arch = "DEB") { + baseurl <- "https://sysreqs.r-hub.io/map/" url <- utils::URLencode(paste0(baseurl, singleline_sysreqs)) - checkable_cmds <- vapply(jsonlite::read_json(url), .extract_sys_package, character(1), arch = arch) + query_res <- jsonlite::read_json(url) + checkable_cmds <- vapply(query_res, .extract_sys_package, character(1), arch = arch) uncheckable_cmds <- .extract_uncheckable_sysreqs(singleline_sysreqs, arch = arch) - return(c(checkable_cmds, uncheckable_cmds)) + c(checkable_cmds[!is.na(checkable_cmds)], uncheckable_cmds) } ## Not everything can be check from sysreqs DB, especially Bioc packages @@ -506,6 +511,9 @@ query_sysreqs <- function(rang, os = "ubuntu-20.04") { } else { sys_pkg <- output[["buildtime"]] } + if (is.null(sys_pkg)) { + return(NA_character_) + } if (arch == "DEB") { return(paste0("apt-get install -y ", sys_pkg)) } diff --git a/tests/testdata/sysreqs_gmp.RDS b/tests/testdata/sysreqs_gmp.RDS new file mode 100644 index 0000000..ffc98ab Binary files /dev/null and b/tests/testdata/sysreqs_gmp.RDS differ diff --git a/tests/testthat/test_resolve.R b/tests/testthat/test_resolve.R index ddb6918..c34950b 100644 --- a/tests/testthat/test_resolve.R +++ b/tests/testthat/test_resolve.R @@ -225,10 +225,20 @@ test_that(".query_sysreqs_bioc with uncheckable info", { expect_true("apt-get install -y libbz2-dev" %in% x) ## uncheckable expect_true("apt-get install -y liblzma-dev" %in% x) expect_true("apt-get install -y make" %in% x) ## checkable + expect_false("apt-get install -y" %in% x) ## the null response from C++ x <- .query_sysreqs_bioc("Rhtslib", "centos-7") expect_true("yum install -y libbz2-devel" %in% x) expect_true("yum install -y xz-devel" %in% x) expect_true("yum install -y make" %in% x) + expect_false("yum install -y" %in% x) ## the null response from C++ + x <- .query_singleline_sysreqs("libxml2", "DEB") + expect_equal(x, "apt-get install -y libxml2-dev") + x <- .query_singleline_sysreqs("C++", "DEB") + expect_equal(x, character(0)) + x <- readRDS("../testdata/sysreqs_gmp.RDS") + ## buildtime / runtime requirements + expect_equal(.extract_sys_package(x[[1]], arch = "DEB"), + "apt-get install -y libgmp-dev") }) test_that("issue 89", {