| 1 |
|
| 2 |
# R 3.6 appears to have trouble if we try to load and unload |
| 3 |
# different versions of BiocManager in the same session, so |
| 4 |
# we need to use this hack to ensure that promises in the S3 |
| 5 |
# methods table are forced at opportune times |
| 6 |
if (getRversion() < "4.0") { |
| 7 |
|
| 8 |
setHook( |
| 9 |
packageEvent("BiocManager", "onLoad"), |
| 10 |
function(...) renv_patch_methods_table() |
| 11 |
) |
| 12 |
|
| 13 |
setHook( |
| 14 |
packageEvent("BiocManager", "onUnload"), |
| 15 |
function(...) renv_patch_methods_table() |
| 16 |
) |
| 17 |
|
| 18 |
} |
| 19 |
|
| 20 |
test_that("packages can be installed, restored from Bioconductor", { |
| 21 |
|
| 22 |
skip_slow() |
| 23 |
skip_on_os("windows") |
| 24 |
skip_if(getRversion() < "3.5.0") |
| 25 |
skip_if(R.version$nickname == "Unsuffered Consequences") |
| 26 |
|
| 27 |
renv_tests_scope("Biobase") |
| 28 |
local({ |
| 29 |
renv_tests_scope_system_cache() |
| 30 |
install("BiocManager") |
| 31 |
}) |
| 32 |
|
| 33 |
local({ |
| 34 |
renv_scope_options(repos = c(CRAN = "https://cran.r-project.org")) |
| 35 |
suppressMessages( |
| 36 |
BiocManager::install( |
| 37 |
pkgs = "Biobase", |
| 38 |
quiet = TRUE, |
| 39 |
update = FALSE, |
| 40 |
ask = FALSE |
| 41 |
) |
| 42 |
) |
| 43 |
}) |
| 44 |
|
| 45 |
expect_true(renv_package_installed("BiocManager")) |
| 46 |
expect_true(renv_package_installed("BiocVersion")) |
| 47 |
expect_true(renv_package_installed("Biobase")) |
| 48 |
|
| 49 |
snapshot(prompt = FALSE) |
| 50 |
|
| 51 |
lockfile <- snapshot(lockfile = NULL) |
| 52 |
expect_true("Bioconductor" %in% names(lockfile)) |
| 53 |
|
| 54 |
BiocManager <- renv_scope_biocmanager() |
| 55 |
defer(unloadNamespace("BiocManager")) |
| 56 |
expect_equal(lockfile$Bioconductor$Version, format(BiocManager$version())) |
| 57 |
|
| 58 |
records <- renv_lockfile_records(lockfile) |
| 59 |
expect_true("BiocManager" %in% names(records)) |
| 60 |
expect_true("BiocVersion" %in% names(records)) |
| 61 |
expect_true("Biobase" %in% names(records)) |
| 62 |
|
| 63 |
remove("Biobase") |
| 64 |
restore() |
| 65 |
expect_true(renv_package_installed("Biobase")) |
| 66 |
|
| 67 |
}) |
| 68 |
|
| 69 |
test_that("install(<bioc>, rebuild = TRUE) works", { |
| 70 |
|
| 71 |
skip_on_cran() |
| 72 |
skip_on_os("windows") |
| 73 |
skip_if(getRversion() < "3.5.0") |
| 74 |
skip_if(R.version$nickname == "Unsuffered Consequences") |
| 75 |
skip_if_not_installed("BiocManager") |
| 76 |
|
| 77 |
renv_tests_scope() |
| 78 |
defer(unloadNamespace("BiocManager")) |
| 79 |
|
| 80 |
local({ |
| 81 |
renv_tests_scope_system_cache() |
| 82 |
install("bioc::Biobase", rebuild = TRUE) |
| 83 |
}) |
| 84 |
|
| 85 |
expect_true(renv_package_installed("Biobase")) |
| 86 |
|
| 87 |
}) |
| 88 |
|
| 89 |
test_that("bioconductor.version can be used to freeze version", { |
| 90 |
|
| 91 |
project <- renv_tests_scope() |
| 92 |
defer(unloadNamespace("BiocManager")) |
| 93 |
|
| 94 |
settings$bioconductor.version("3.14", project = project) |
| 95 |
expect_equal(renv_bioconductor_version(project = project), "3.14") |
| 96 |
|
| 97 |
}) |
| 98 |
|
| 99 |
test_that("we can restore a lockfile using multiple Bioconductor releases", { |
| 100 |
|
| 101 |
skip_on_cran() |
| 102 |
skip_on_windows() |
| 103 |
skip_if(getRversion()[1, 1:2] != "4.1") |
| 104 |
skip_if_not_installed("BiocManager") |
| 105 |
|
| 106 |
project <- renv_tests_scope() |
| 107 |
defer(unloadNamespace("BiocManager")) |
| 108 |
|
| 109 |
path <- renv_tests_path("resources/bioconductor.lock") |
| 110 |
lockfile <- renv_lockfile_read(path) |
| 111 |
|
| 112 |
status <- restore( |
| 113 |
lockfile = lockfile, |
| 114 |
packages = c("limma", "BiocGenerics"), |
| 115 |
rebuild = TRUE |
| 116 |
) |
| 117 |
|
| 118 |
expect_true(renv_package_version("limma") == "3.50.0") |
| 119 |
expect_true(renv_package_version("BiocGenerics") == "0.38.0") |
| 120 |
|
| 121 |
}) |
| 122 |
|
| 123 |
test_that("Bioconductor packages add BiocManager as a dependency", { |
| 124 |
|
| 125 |
renv_tests_scope() |
| 126 |
defer(unloadNamespace("BiocManager")) |
| 127 |
|
| 128 |
init() |
| 129 |
|
| 130 |
local({ |
| 131 |
renv_tests_scope_system_cache() |
| 132 |
install("bioc::BiocGenerics") |
| 133 |
}) |
| 134 |
|
| 135 |
snapshot() |
| 136 |
writeLines("library(BiocGenerics)", "dependencies.R") |
| 137 |
|
| 138 |
lockfile <- snapshot() |
| 139 |
expect_contains(names(lockfile$Packages), "BiocManager") |
| 140 |
|
| 141 |
# And it goes away when we remove the dependency |
| 142 |
unlink("dependencies.R") |
| 143 |
lockfile <- snapshot() |
| 144 |
records <- renv_lockfile_records(lockfile) |
| 145 |
expect_length(records, 0L) |
| 146 |
|
| 147 |
}) |
| 148 |
|
| 149 |
test_that("remotes which depend on Bioconductor packages can be installed", { |
| 150 |
skip_on_cran() |
| 151 |
|
| 152 |
renv_tests_scope() |
| 153 |
renv_scope_options(repos = c(CRAN = "https://cloud.r-project.org")) |
| 154 |
defer(unloadNamespace("BiocManager")) |
| 155 |
|
| 156 |
# create a dummy package which has a Bioconductor dependency |
| 157 |
pkgdir <- file.path(tempdir(), "bioc.example") |
| 158 |
ensure_directory(pkgdir) |
| 159 |
|
| 160 |
desc <- heredoc(" |
| 161 |
Package: bioc.example |
| 162 |
Version: 1.0.0 |
| 163 |
Imports: Biobase |
| 164 |
biocViews: Biology |
| 165 |
") |
| 166 |
writeLines(desc, con = file.path(pkgdir, "DESCRIPTION")) |
| 167 |
|
| 168 |
# try to install it |
| 169 |
local({ |
| 170 |
renv_tests_scope_system_cache() |
| 171 |
install(pkgdir) |
| 172 |
}) |
| 173 |
|
| 174 |
expect_true(renv_package_installed("Biobase")) |
| 175 |
expect_true(renv_package_installed("BiocGenerics")) |
| 176 |
|
| 177 |
}) |
| 178 |
|
| 179 |
|
| 180 |
test_that("auto-bioc install happens silently", { |
| 181 |
|
| 182 |
# https://github.com/rstudio/renv/actions/runs/5326472190/jobs/9648557761#step:6:295 |
| 183 |
skip_if(renv_platform_windows()) |
| 184 |
|
| 185 |
renv_tests_scope() |
| 186 |
renv_tests_scope_system_cache() |
| 187 |
defer(unloadNamespace("BiocManager")) |
| 188 |
|
| 189 |
install("bioc::BiocGenerics") |
| 190 |
expect_true(renv_package_installed("BiocManager")) |
| 191 |
|
| 192 |
}) |
| 193 |
|
| 194 |
test_that("standard bioc remotes are standardized appropriately", { |
| 195 |
|
| 196 |
contents <- heredoc(' |
| 197 |
Package: BiocVersion |
| 198 |
Version: 3.18.1 |
| 199 |
Title: Set the appropriate version of Bioconductor packages |
| 200 |
Description: This package provides repository information for the appropriate version of Bioconductor. |
| 201 |
Authors@R: c( person("Martin", "Morgan", email = "[email protected]", role = "aut"), person("Marcel", |
| 202 |
"Ramos", email = "[email protected]", role = "ctb"), person("Bioconductor", "Package |
| 203 |
Maintainer", email = "[email protected]", role = c("ctb", "cre"))) |
| 204 |
biocViews: Infrastructure |
| 205 |
Depends: R (>= 4.3.0) |
| 206 |
License: Artistic-2.0 |
| 207 |
Encoding: UTF-8 |
| 208 |
RoxygenNote: 6.0.1 |
| 209 |
git_url: https://git.bioconductor.org/packages/BiocVersion |
| 210 |
git_branch: RELEASE_3_18 |
| 211 |
git_last_commit: 70680b8 |
| 212 |
git_last_commit_date: 2023-11-15 |
| 213 |
Repository: Bioconductor 3.18 |
| 214 |
Date/Publication: 2023-11-18 |
| 215 |
NeedsCompilation: no |
| 216 |
Packaged: 2023-11-18 19:15:45 UTC; biocbuild |
| 217 |
Author: Martin Morgan [aut], Marcel Ramos [ctb], Bioconductor Package Maintainer [ctb, cre] |
| 218 |
Maintainer: Bioconductor Package Maintainer <[email protected]> |
| 219 |
Built: R 4.3.2; ; 2023-11-20 12:36:26 UTC; unix |
| 220 |
RemoteType: standard |
| 221 |
RemotePkgRef: BiocVersion |
| 222 |
RemoteRef: BiocVersion |
| 223 |
RemoteRepos: https://bioconductor.org/packages/3.18/bioc |
| 224 |
RemotePkgPlatform: aarch64-apple-darwin20 |
| 225 |
RemoteSha: 3.18.1 |
| 226 |
') |
| 227 |
|
| 228 |
descfile <- tempfile("biocversion-") |
| 229 |
writeLines(contents, con = descfile) |
| 230 |
|
| 231 |
actual <- renv_snapshot_description(path = descfile) |
| 232 |
expected <- list( |
| 233 |
Package = "BiocVersion", |
| 234 |
Version = "3.18.1", |
| 235 |
Source = "Bioconductor", |
| 236 |
Repository = "Bioconductor 3.18" |
| 237 |
) |
| 238 |
|
| 239 |
expect_identical(actual[names(expected)], expected) |
| 240 |
|
| 241 |
}) |