Skip to content

Commit

Permalink
tests conditional on MASS and foreign (#1079)
Browse files Browse the repository at this point in the history
  • Loading branch information
aronatkins authored May 28, 2024
1 parent 5a79f2e commit 398207e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
1 change: 0 additions & 1 deletion tests/testthat/project-MASS/MASS.R

This file was deleted.

15 changes: 15 additions & 0 deletions tests/testthat/test-bundlePackage.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
test_that("can snapshot deps with renv", {
skip_if_not_installed("foreign")
skip_if_not_installed("MASS")

app_dir <- local_temp_app(list(foo.R = "library(foreign); library(MASS)"))

expect_snapshot(pkgs <- bundlePackages(app_dir))
Expand All @@ -13,6 +16,9 @@ test_that("can snapshot deps with renv", {
})

test_that("can snapshot deps with packrat (option)", {
skip_if_not_installed("foreign")
skip_if_not_installed("MASS")

withr::local_options(rsconnect.packrat = TRUE)

app_dir <- local_temp_app(list(foo.R = "library(foreign); library(MASS)"))
Expand All @@ -28,6 +34,9 @@ test_that("can snapshot deps with packrat (option)", {
})

test_that("can snapshot deps with packrat (env var)", {
skip_if_not_installed("foreign")
skip_if_not_installed("MASS")

withr::local_envvar(RSCONNECT_PACKRAT = "TRUE")

app_dir <- local_temp_app(list(foo.R = "library(foreign); library(MASS)"))
Expand All @@ -43,6 +52,9 @@ test_that("can snapshot deps with packrat (env var)", {
})

test_that("can capture deps from renv lockfile", {
skip_if_not_installed("foreign")
skip_if_not_installed("MASS")

withr::local_options(renv.verbose = FALSE)

app_dir <- local_temp_app(list(foo.R = "library(foreign); library(MASS)"))
Expand All @@ -60,6 +72,9 @@ test_that("can capture deps from renv lockfile", {
})

test_that("can capture deps with packrat even when renv lockfile present", {
skip_if_not_installed("foreign")
skip_if_not_installed("MASS")

withr::local_envvar(RSCONNECT_PACKRAT = "TRUE")
withr::local_options(renv.verbose = FALSE)

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-bundlePackagePackrat.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test_that("uninstalled packages error", {
})

test_that("recommended packages are snapshotted", {
skip_if_not_installed("MASS")
app <- local_temp_app(list("index.Rmd" = c(
"```{r}",
"library(MASS)",
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-bundlePackageRenv.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ test_that("manifest has correct data types", {

test_that("recommended packages are snapshotted", {
skip_on_cran()
skip_if_not_installed("MASS")

withr::local_options(renv.verbose = TRUE)
app <- local_temp_app(list("index.Rmd" = c(
"```{r}",
Expand All @@ -30,6 +32,8 @@ test_that("recommended packages are snapshotted", {

test_that("extra packages are snapshotted", {
skip_on_cran()
skip_if_not_installed("foreign")

withr::local_options(renv.verbose = TRUE)
app <- local_temp_app(list("index.Rmd" = ""))
deps <- snapshotRenvDependencies(app, extraPackages = c("foreign"))
Expand All @@ -39,6 +43,7 @@ test_that("extra packages are snapshotted", {
test_that("works with BioC packages", {
skip_on_cran()
skip_on_ci()

app <- local_temp_app(list("index.R" = c(
"library(Biobase)"
)))
Expand Down Expand Up @@ -68,6 +73,8 @@ test_that("works with BioC packages", {
# https://github.com/rstudio/rsconnect/issues/968
test_that("large directories are analyzed", {
skip_on_cran()
skip_if_not_installed("foreign")

app_dir <- local_temp_app(list("foo.R" = "library(foreign)"))
data_dir <- file.path(app_dir, "data")
dir.create(data_dir)
Expand All @@ -83,6 +90,9 @@ test_that("large directories are analyzed", {
# parseRenvDependencies ---------------------------------------------------

test_that("gets DESCRIPTION from renv & system libraries", {
skip_if_not_installed("foreign")
skip_if_not_installed("MASS")

withr::local_options(renv.verbose = FALSE)

app_dir <- local_temp_app(list("foo.R" = "library(foreign); library(MASS)"))
Expand All @@ -98,6 +108,9 @@ test_that("gets DESCRIPTION from renv & system libraries", {


test_that("errors if library and project are inconsistent", {
skip_if_not_installed("foreign")
skip_if_not_installed("MASS")

withr::local_options(renv.verbose = FALSE)

app_dir <- local_temp_app(list("foo.R" = "library(foreign); library(MASS)"))
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-writeManifest.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ makeManifest <- function(appDir, appPrimaryDoc = NULL, ...) {

test_that("renv.lock is included for renv projects", {
skip_on_cran()
skip_if_not_installed("foreign")
skip_if_not_installed("MASS")

withr::local_options(renv.verbose = FALSE)

Expand All @@ -23,6 +25,8 @@ test_that("renv.lock is included for renv projects", {

test_that("renv.lock is not included for non-renv projects", {
skip_on_cran()
skip_if_not_installed("foreign")
skip_if_not_installed("MASS")

withr::local_options(renv.verbose = FALSE)

Expand Down

0 comments on commit 398207e

Please sign in to comment.