diff --git a/Makefile b/Makefile index d75e432d..023473a4 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 754c4815..46524e55 100755 --- a/inst/tinytest/helpers.R +++ b/inst/tinytest/helpers.R @@ -14,5 +14,15 @@ options("tinysnapshot_device_args" = list( system_fonts = list(symbol = "DejaVu Sans") )) +# 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( + "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 10a667e4..c8265c05 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")