Skip to content

Commit

Permalink
try only skipping on r-oldrel
Browse files Browse the repository at this point in the history
  • Loading branch information
jgabry committed Jun 26, 2024
1 parent 0752e7c commit c244c27
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 78 deletions.
26 changes: 20 additions & 6 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
# used to skip visual tests of SVGs on r-devel and r-oldrel
# because they can be slightly different than r-release occasionally
skip_if_not_r_release <- function() {
# first try just skipping on devel
testthat::skip_if(isTRUE(Sys.getenv("R_VERSION_TYPE") == "devel"))
# Used if necessary to skip visual tests of SVGs (using vdiffr)
# on different R versions because they can be slightly different

#testthat::skip_if_not(isTRUE(Sys.getenv("R_VERSION_TYPE") == "release"))
# R_VERSION_TYPE is set in the R-CMD-check.yaml GitHub Actions workflow file

on_r_devel <- function() {
isTRUE(Sys.getenv("R_VERSION_TYPE") == "devel")
}
on_r_oldrel <- function() {
isTRUE(Sys.getenv("R_VERSION_TYPE") == "oldrel")
}

skip_on_r_devel <- function() {
testthat::skip_if(on_r_devel())
}
skip_on_r_oldrel <- function() {
testthat::skip_if(on_r_oldrel())
}
skip_if_not_on_r_release <- function() {
skip_on_r_devel()
skip_on_r_oldrel()
}
2 changes: 1 addition & 1 deletion tests/testthat/test-aesthetics.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ color_scheme_set()
test_that("color_scheme_view renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

color_scheme_set()
p_default <- color_scheme_view()
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-mcmc-diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ test_that("mcmc_acf & mcmc_acf_bar throw correct errors", {
test_that("mcmc_rhat renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

rhats <- seq(from = 1, to = 1.20, length.out = 10)

Expand All @@ -123,7 +123,7 @@ test_that("mcmc_rhat renders correctly", {
test_that("mcmc_rhat_hist renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

rhats <- seq(from = 1, to = 1.20, length.out = 10)

Expand All @@ -138,7 +138,7 @@ test_that("mcmc_rhat_hist renders correctly", {
test_that("mcmc_neff renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

neffs <- seq(from = 0, to = 1, length.out = 20)

Expand All @@ -149,7 +149,7 @@ test_that("mcmc_neff renders correctly", {
test_that("mcmc_neff_hist renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

neffs <- seq(from = 0, to = 1, length.out = 20)

Expand All @@ -163,7 +163,7 @@ test_that("mcmc_neff_hist renders correctly", {
test_that("mcmc_acf renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_acf(vdiff_dframe)
vdiffr::expect_doppelganger("mcmc_acf (default)", p_base)
Expand All @@ -175,7 +175,7 @@ test_that("mcmc_acf renders correctly", {
test_that("mcmc_acf_bar renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_acf_bar(vdiff_dframe)
vdiffr::expect_doppelganger("mcmc_acf_bar (default)", p_base)
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-mcmc-distributions.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ test_that("mcmc_* throws error if 1 chain but multiple chains required", {
test_that("mcmc_hist renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_hist(vdiff_dframe, binwidth = 0.1)
vdiffr::expect_doppelganger("mcmc_hist (default)", p_base)
Expand All @@ -139,7 +139,7 @@ test_that("mcmc_hist renders correctly", {
test_that("mcmc_dens renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_dens(vdiff_dframe)
vdiffr::expect_doppelganger("mcmc_dens (default)", p_base)
Expand All @@ -151,7 +151,7 @@ test_that("mcmc_dens renders correctly", {
test_that("mcmc_dens_overlay renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_dens_overlay(vdiff_dframe_chains)
vdiffr::expect_doppelganger("mcmc_dens_overlay (default)", p_base)
Expand All @@ -160,7 +160,7 @@ test_that("mcmc_dens_overlay renders correctly", {
test_that("mcmc_dens_chains renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_dens_chains(vdiff_dframe_chains)
vdiffr::expect_doppelganger("mcmc_dens_chains (default)", p_base)
Expand All @@ -169,7 +169,7 @@ test_that("mcmc_dens_chains renders correctly", {
test_that("mcmc_hist_by_chain renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_hist_by_chain(vdiff_dframe_chains, binwidth = 0.5)
vdiffr::expect_doppelganger("mcmc_hist_by_chain (default)", p_base)
Expand All @@ -178,7 +178,7 @@ test_that("mcmc_hist_by_chain renders correctly", {
test_that("mcmc_violin renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_violin(vdiff_dframe_chains)
vdiffr::expect_doppelganger("mcmc_violin (default)", p_base)
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-mcmc-intervals.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ test_that("inconsistent probabilities raise warning (#138)", {
test_that("mcmc_intervals renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_intervals(vdiff_dframe)
vdiffr::expect_doppelganger("mcmc_intervals (default)", p_base)
Expand Down Expand Up @@ -206,7 +206,7 @@ test_that("mcmc_intervals renders correctly", {
test_that("mcmc_areas renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_areas(vdiff_dframe)
vdiffr::expect_doppelganger("mcmc_areas (default)", p_base)
Expand Down Expand Up @@ -240,7 +240,7 @@ test_that("mcmc_areas renders correctly", {
test_that("mcmc_areas_ridges renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_areas_ridges(vdiff_dframe)
vdiffr::expect_doppelganger("mcmc_areas_ridges (default)", p_base)
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-mcmc-nuts.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ source(test_path("data-for-mcmc-tests.R"))
test_that("mcmc_nuts_acceptance renders correctly", {
skip_on_cran()
skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_nuts_acceptance(vdiff_dframe_chains_np, vdiff_dframe_chains_lp)
vdiffr::expect_doppelganger("mcmc_nuts_acceptance (default)", p_base)
Expand All @@ -109,7 +109,7 @@ test_that("mcmc_nuts_acceptance renders correctly", {
test_that("mcmc_nuts_divergence renders correctly", {
skip_on_cran()
skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_nuts_divergence(vdiff_dframe_chains_np, vdiff_dframe_chains_lp)
vdiffr::expect_doppelganger("mcmc_nuts_divergence (default)", p_base)
Expand All @@ -121,7 +121,7 @@ test_that("mcmc_nuts_divergence renders correctly", {
test_that("mcmc_nuts_treedepth renders correctly", {
skip_on_cran()
skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_nuts_treedepth(vdiff_dframe_chains_np, vdiff_dframe_chains_lp)
vdiffr::expect_doppelganger("mcmc_nuts_treedepth (default)", p_base)
Expand All @@ -133,7 +133,7 @@ test_that("mcmc_nuts_treedepth renders correctly", {
test_that("mcmc_nuts_stepsize renders correctly", {
skip_on_cran()
skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_nuts_stepsize(vdiff_dframe_chains_np, vdiff_dframe_chains_lp)
vdiffr::expect_doppelganger("mcmc_nuts_stepsize (default)", p_base)
Expand All @@ -145,7 +145,7 @@ test_that("mcmc_nuts_stepsize renders correctly", {
test_that("mcmc_nuts_energy renders correctly", {
skip_on_cran()
skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_nuts_energy(vdiff_dframe_chains_np, vdiff_dframe_chains_lp, binwidth = 10)
vdiffr::expect_doppelganger("mcmc_nuts_energy (default)", p_base)
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-mcmc-recover.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ test_that("mcmc_recover_hist returns a ggplot object", {
test_that("mcmc_recover_hist renders correctly", {
skip_on_cran()
skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_recover_hist(draws, true, binwidth = 0.01)
vdiffr::expect_doppelganger("mcmc_recover_hist (default)", p_base)
Expand All @@ -115,7 +115,7 @@ test_that("mcmc_recover_hist renders correctly", {
test_that("mcmc_recover_intervals renders correctly", {
skip_on_cran()
skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_recover_intervals(draws, true)
vdiffr::expect_doppelganger("mcmc_recover_intervals (default)", p_base)
Expand All @@ -127,7 +127,7 @@ test_that("mcmc_recover_intervals renders correctly", {
test_that("mcmc_recover_scatter renders correctly", {
skip_on_cran()
skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_recover_scatter(draws, true)
vdiffr::expect_doppelganger("mcmc_recover_scatter (default)", p_base)
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-mcmc-scatter-and-parcoord.R
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ test_that("parcoord_style_np throws correct errors", {
test_that("mcmc_scatter renders correctly", {
skip_on_cran()
skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_scatter(vdiff_dframe_chains)
vdiffr::expect_doppelganger("mcmc_scatter (default)", p_base)
Expand All @@ -396,7 +396,7 @@ test_that("mcmc_hex renders correctly", {
skip_on_cran()
skip_if_not_installed("vdiffr")
skip_if_not_installed("hexbin")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_hex(vdiff_dframe, pars = c("V1", "V2"))
vdiffr::expect_doppelganger("mcmc_hex (default)", p_base)
Expand All @@ -412,7 +412,7 @@ test_that("mcmc_hex renders correctly", {
test_that("mcmc_parcoord renders correctly", {
skip_on_cran()
skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_parcoord(vdiff_dframe_chains)
vdiffr::expect_doppelganger("mcmc_parcoord (default)", p_base)
Expand All @@ -430,7 +430,7 @@ test_that("mcmc_pairs renders correctly", {
skip_on_cran()
skip_if_not_installed("vdiffr")
skip_if_not_installed("hexbin")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_pairs(vdiff_dframe_chains)
vdiffr::expect_doppelganger("mcmc_pairs (default)", p_base)
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-mcmc-traces.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ test_that("mcmc_trace 'np' argument works", {
test_that("mcmc_trace renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_trace(vdiff_dframe_chains, pars = c("V1", "V2"))
p_one_param <- mcmc_trace(vdiff_dframe_chains, pars = "V1")
Expand All @@ -139,7 +139,7 @@ test_that("mcmc_trace renders correctly", {
test_that("mcmc_rank_overlay renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_rank_overlay(vdiff_dframe_chains, pars = c("V1", "V2"))
p_base_ref <- mcmc_rank_overlay(
Expand Down Expand Up @@ -169,7 +169,7 @@ test_that("mcmc_rank_overlay renders correctly", {
test_that("mcmc_rank_hist renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_rank_hist(vdiff_dframe_chains, pars = c("V1", "V2"))
p_base_ref <- mcmc_rank_hist(
Expand Down Expand Up @@ -202,7 +202,7 @@ test_that("mcmc_rank_hist renders correctly", {
test_that("mcmc_trace_highlight renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_trace_highlight(
vdiff_dframe_chains,
Expand Down Expand Up @@ -231,7 +231,7 @@ test_that("mcmc_trace_highlight renders correctly", {
test_that("mcmc_rank_ecdf renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_rank_ecdf(vdiff_dframe_chains, pars = c("V1", "V2"))
p_one_param <- mcmc_rank_ecdf(vdiff_dframe_chains, pars = "V1")
Expand Down Expand Up @@ -260,7 +260,7 @@ test_that("mcmc_rank_ecdf renders correctly", {
test_that("mcmc_trace with 'np' renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- mcmc_trace(
vdiff_dframe_chains,
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-ppc-censoring.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test_that("ppc_km_overlay renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_installed("ggfortify")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- ppc_km_overlay(vdiff_y2, vdiff_yrep2, status_y = vdiff_status_y2)
vdiffr::expect_doppelganger("ppc_km_overlay (default)", p_base)
Expand All @@ -50,7 +50,7 @@ test_that("ppc_km_overlay_grouped renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_installed("ggfortify")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- ppc_km_overlay_grouped(vdiff_y2, vdiff_yrep2, vdiff_group2,
status_y = vdiff_status_y2)
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-ppc-discrete.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ test_that("ppc_rootogram errors if y/yrep not counts", {
test_that("ppc_bars renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- ppc_bars(vdiff_y2, vdiff_yrep2)
vdiffr::expect_doppelganger("ppc_bars (default)", p_base)
Expand Down Expand Up @@ -138,7 +138,7 @@ test_that("ppc_bars renders correctly", {
test_that("ppc_bars_grouped renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- ppc_bars_grouped(vdiff_y2, vdiff_yrep2, vdiff_group2)
vdiffr::expect_doppelganger("ppc_bars_grouped (default)", p_base)
Expand All @@ -160,7 +160,7 @@ test_that("ppc_bars_grouped renders correctly", {
test_that("ppc_rootogram renders correctly", {
testthat::skip_on_cran()
testthat::skip_if_not_installed("vdiffr")
skip_if_not_r_release()
skip_on_r_oldrel()

p_base <- ppc_rootogram(vdiff_y2, vdiff_yrep2)
vdiffr::expect_doppelganger("ppc_rootogram (default)", p_base)
Expand Down
Loading

0 comments on commit c244c27

Please sign in to comment.