Skip to content

Commit

Permalink
Merge pull request #270 from UrbanAnalyst/tests
Browse files Browse the repository at this point in the history
fix 'test_all' conditions for all tests
  • Loading branch information
mpadge authored Feb 13, 2025
2 parents 6df6046 + 056d62f commit 85bdda1
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 62 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dodgr
Title: Distances on Directed Graphs
Version: 0.4.1.048
Version: 0.4.1.052
Authors@R: c(
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre")),
person("Andreas", "Petutschnig", role = "aut"),
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"codeRepository": "https://github.com/UrbanAnalyst/dodgr",
"issueTracker": "https://github.com/UrbanAnalyst/dodgr/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.4.1.048",
"version": "0.4.1.052",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
4 changes: 1 addition & 3 deletions tests/testthat/test-cache.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
context ("cache")

# The cache-off tests fail on windows for some reason, both on CRAN and on
# GitHub runners.
testthat::skip_on_os ("windows")

test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
identical (Sys.getenv ("GITHUB_JOB"), "test-coverage"))

testthat::skip_if (!test_all)

Expand Down
6 changes: 2 additions & 4 deletions tests/testthat/test-centrality.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
context ("centrality")

test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_JOB"), "test-coverage"))

# testthat::skip_on_cran ()
testthat::skip_if (!test_all)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-deduplicate.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_JOB"), "test-coverage"))

# testthat::skip_if (!test_all)

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-dists-categorical.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
context ("dodgr_dists_categorical")

test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_JOB"), "test-coverage"))

if (!test_all) {
RcppParallel::setThreadOptions (numThreads = 2)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-dists-nearest.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_JOB"), "test-coverage"))

if (!test_all) {
RcppParallel::setThreadOptions (numThreads = 2)
Expand Down
6 changes: 2 additions & 4 deletions tests/testthat/test-dists.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
context ("dodgr_dists")

test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_JOB"), "test-coverage"))

if (!test_all) {
RcppParallel::setThreadOptions (numThreads = 2)
Expand Down
6 changes: 2 additions & 4 deletions tests/testthat/test-flows.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
context ("dodgr_flows")

test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_JOB"), "test-coverage"))

testthat::skip_on_cran ()

Expand Down
6 changes: 2 additions & 4 deletions tests/testthat/test-graph-fns.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
context ("dodgr graph functions")

test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_JOB"), "test-coverage"))

skip_if (!test_all)

Expand Down
6 changes: 2 additions & 4 deletions tests/testthat/test-iso.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
context ("iso")

test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_JOB"), "test-coverage"))

if (!test_all) {
RcppParallel::setThreadOptions (numThreads = 2)
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-match-pts-fns.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_JOB"), "test-coverage"))

skip_if (!test_all)

Expand Down Expand Up @@ -153,5 +153,5 @@ test_that ("match with distances", {
expect_identical (names (res), c ("index", "d_signed", "x", "y"))
expect_true (length (which (res$d_signed < 0)) > 0L)
expect_true (length (which (res$d_signed > 0)) > 0L)
expect_true (length (which (res$d_signed == 0)) > 0L)
expect_true (length (which (res$d_signed == 0)) == 0L)
})
6 changes: 2 additions & 4 deletions tests/testthat/test-save-load.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
context ("save and load")

testthat::skip_on_cran ()
testthat::skip_on_os ("mac")

test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_JOB"), "test-coverage"))

if (!test_all) {
RcppParallel::setThreadOptions (numThreads = 2)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-sc.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
context ("SC")

test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_JOB"), "test-coverage"))

skip_if (!test_all)

Expand Down
42 changes: 20 additions & 22 deletions tests/testthat/test-streetnet.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
context ("dodgr streetnet")

dodgr_cache_off ()
clear_dodgr_cache ()

test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") ||
identical (Sys.getenv ("GITHUB_JOB"), "test-coverage"))
# used below in a skip_if call

test_that ("streetnet bbox", {
Expand Down Expand Up @@ -251,23 +249,23 @@ test_that ("streetnet times", {
)
})

test_that("weight_streetnet runs with non-LINESTRING sfc", {
# See #246
skip_if_not_installed("sf")

toy <- sf::st_as_sf(
data.frame(highway = "primary", osm_id = 1:2),
geometry = sf::st_sfc(
sf::st_linestring(rbind(c(0, 0), c(1, 1))),
sf::st_multilinestring(
list(
sf::st_linestring(rbind(c(1, 1), c(2, 2)))
test_that ("weight_streetnet runs with non-LINESTRING sfc", {
# See #246
skip_if_not_installed ("sf")

toy <- sf::st_as_sf (
data.frame (highway = "primary", osm_id = 1:2),
geometry = sf::st_sfc (
sf::st_linestring (rbind (c (0, 0), c (1, 1))),
sf::st_multilinestring (
list (
sf::st_linestring (rbind (c (1, 1), c (2, 2)))
)
)
)
)
)
)
expect_warning(
weight_streetnet(toy),
"not a LINESTRING"
)
})
expect_warning (
weight_streetnet (toy),
"not a LINESTRING"
)
})

0 comments on commit 85bdda1

Please sign in to comment.