From e95f303ea2e31e24724599e755caf8b64d8ed72f Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Wed, 9 Sep 2026 08:30:09 -0700 Subject: [PATCH 1/3] snapshot gate --- Makefile | 4 ++-- inst/tinytest/helpers.R | 15 +++++++++++++++ inst/tinytest/test-legend.R | 5 ++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d75e432d2..023473a40 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ help: ## Display this help screen @grep -E '^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}' | sort testall: ## tinytest::build_install_test() - Rscript -e "pkgload::load_all();tinytest::run_test_dir()" + NOT_CRAN=true Rscript -e "pkgload::load_all();tinytest::run_test_dir()" testall-docker: ## run full test suite in a Linux container (native arch) .devcontainer/run-tests.sh @@ -14,7 +14,7 @@ testall-ci: ## as testall-docker, under amd64 to match CI (needed on Apple Silic PLATFORM=linux/amd64 .devcontainer/run-tests.sh testone: install ## make testone testfile="inst/tinytest/test-aaa-warn_once.R" - Rscript -e "pkgload::load_all();tinytest::run_test_file('$(testfile)')" + NOT_CRAN=true Rscript -e "pkgload::load_all();tinytest::run_test_file('$(testfile)')" document: ## devtools::document() Rscript -e "devtools::document()" diff --git a/inst/tinytest/helpers.R b/inst/tinytest/helpers.R index 754c4815b..8f6d6358d 100755 --- a/inst/tinytest/helpers.R +++ b/inst/tinytest/helpers.R @@ -14,5 +14,20 @@ options("tinysnapshot_device_args" = list( system_fonts = list(symbol = "DejaVu Sans") )) +# Mirror of the gate tinysnapshot uses to decide whether plot snapshots run. +# A skipped snapshot never calls the plotting function, so tests that assert on +# a *side effect* of drawing (e.g. a warning) must skip in lockstep, or they +# outlive the thing they depend on and fail for an unrelated-looking reason. +# Mirrors both of tinysnapshot's conditions: the OS check (snapshots are pinned +# to Linux above, so they never run on e.g. macOS) and the skip flag. +snapshots_run = local({ + os = getOption("tinysnapshot_os", default = Sys.info()[["sysname"]]) + skip = getOption( + "tinysnapshot_plot_skip", + default = !interactive() && !identical(Sys.getenv("NOT_CRAN"), "true") + ) + Sys.info()[["sysname"]] %in% os && !skip +}) + # reset theme in every file tinytheme() diff --git a/inst/tinytest/test-legend.R b/inst/tinytest/test-legend.R index 10a667e4b..c8265c056 100644 --- a/inst/tinytest/test-legend.R +++ b/inst/tinytest/test-legend.R @@ -141,7 +141,10 @@ f = function() tinyplot( Temp ~ Day | Month, data = aq, legend = legend(legend = month.abb[5:10]) ) -expect_warning(expect_snapshot_plot(f, label = "legend_user_labs_override")) +# the mismatch warning is only emitted when the plot is actually drawn +if (snapshots_run) { + expect_warning(expect_snapshot_plot(f, label = "legend_user_labs_override")) +} # override default legend margins with tpar("lmar") From e88ad737816a6ba3abb5097e7074b4a49bed5974 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Wed, 9 Sep 2026 08:32:21 -0700 Subject: [PATCH 2/3] simplify comment --- inst/tinytest/helpers.R | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/inst/tinytest/helpers.R b/inst/tinytest/helpers.R index 8f6d6358d..2f8c55959 100755 --- a/inst/tinytest/helpers.R +++ b/inst/tinytest/helpers.R @@ -14,12 +14,7 @@ options("tinysnapshot_device_args" = list( system_fonts = list(symbol = "DejaVu Sans") )) -# Mirror of the gate tinysnapshot uses to decide whether plot snapshots run. -# A skipped snapshot never calls the plotting function, so tests that assert on -# a *side effect* of drawing (e.g. a warning) must skip in lockstep, or they -# outlive the thing they depend on and fail for an unrelated-looking reason. -# Mirrors both of tinysnapshot's conditions: the OS check (snapshots are pinned -# to Linux above, so they never run on e.g. macOS) and the skip flag. +# Mirror of the gate tinysnapshot uses to decide whether plot snapsho snapshots_run = local({ os = getOption("tinysnapshot_os", default = Sys.info()[["sysname"]]) skip = getOption( From 9fc0ee667a0999df1a93441f1a44c426008cf6f2 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Wed, 9 Sep 2026 08:51:05 -0700 Subject: [PATCH 3/3] typo --- inst/tinytest/helpers.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/tinytest/helpers.R b/inst/tinytest/helpers.R index 2f8c55959..46524e55b 100755 --- a/inst/tinytest/helpers.R +++ b/inst/tinytest/helpers.R @@ -14,7 +14,7 @@ options("tinysnapshot_device_args" = list( system_fonts = list(symbol = "DejaVu Sans") )) -# Mirror of the gate tinysnapshot uses to decide whether plot snapsho +# Mirror the gate that tinysnapshot uses to decide whether plot snapshots run snapshots_run = local({ os = getOption("tinysnapshot_os", default = Sys.info()[["sysname"]]) skip = getOption(