diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index a69ebfd..4de0d45 100644 --- a/tests/testthat/helper.R +++ b/tests/testthat/helper.R @@ -31,10 +31,14 @@ download_nc_basic <- function() { get_gisbase <- function() { if (Sys.info()["sysname"] == "Linux") { - gisBase <- system2("grass", "--config path", stdout = TRUE) + gisBase <- try(system2("grass", "--config path", stdout = TRUE), silent = TRUE) } else { - gisBase <- Sys.getenv("GRASS_INSTALLATION") + gisBase <- try(Sys.getenv("GRASS_INSTALLATION"), silent = TRUE) } + if (inherits(gisBase, "try-error")) { + message("GRASS GIS not found on PATH") + return(NULL) + } return(gisBase) } diff --git a/tests/testthat/test-initGRASS.R b/tests/testthat/test-initGRASS.R index 6bebb54..363fc37 100644 --- a/tests/testthat/test-initGRASS.R +++ b/tests/testthat/test-initGRASS.R @@ -25,6 +25,8 @@ test_that("testing basic initGRASS", { }) test_that("testing initialization from SpatRaster", { + skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") + meuse_grid <- rast(system.file("ex/meuse.tif", package = "terra")) loc <- initGRASS(gisBase = gisBase, SG = meuse_grid, override = TRUE) expect_s3_class(loc, "gmeta") @@ -51,6 +53,8 @@ test_that("testing remove_GISRC", { }) test_that("testing set/unset.GIS_LOCK", { + skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") + loc <- initGRASS( gisBase = gisBase, gisDbase = testdata$gisDbase, diff --git a/tests/testthat/test-read_VECT.R b/tests/testthat/test-read_VECT.R index e599db0..3a47616 100644 --- a/tests/testthat/test-read_VECT.R +++ b/tests/testthat/test-read_VECT.R @@ -32,6 +32,8 @@ test_that("testing read_VECT", { }) test_that("testing write_VECT", { + skip_if_not(!is.null(gisBase), "GRASS GIS not found on PATH") + shp <- vect(system.file("ex/lux.shp", package = "terra")) elev <- rast(system.file("ex/elev.tif", package = "terra"))