From bcdcdbc1f8eeb2b15e5110890539cec4edd3cace Mon Sep 17 00:00:00 2001 From: Joshua Zahner Date: Wed, 14 Oct 2026 14:23:53 -0400 Subject: [PATCH 1/9] test: :zap: reduced `convert_output` tests to only run on subset of SS3 models --- tests/testthat/test-convert_output.R | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-convert_output.R b/tests/testthat/test-convert_output.R index 1a546672..7d74a56b 100644 --- a/tests/testthat/test-convert_output.R +++ b/tests/testthat/test-convert_output.R @@ -6,11 +6,21 @@ test_that("convert_output works for SS3", { recursive = FALSE ) + model_names <- c( + "Hake_2018", + "platoons", + "Empirical_wtatage_Age_Selex", + "three_area_nomove", + "BigSkate_2019" + ) + + models_to_test <- all_models[grepl(paste0(model_names, collapse="|"), all_models)] + # Loop through each model directory and check convert_output function - for (i in seq_along(all_models)) { + for (i in seq_along(models_to_test)) { # Ensure no errors occur while converting SS3 output expect_no_error(result <- convert_output( - file = file.path(all_models[i], "Report.sso") + file = file.path(models_to_test[i], "Report.sso") )) # Check that the result has exactly 35 columns From 4ed80d11c96356903e31cdc411ab961f45b1b87a Mon Sep 17 00:00:00 2001 From: Joshua Zahner Date: Wed, 14 Oct 2026 14:29:41 -0400 Subject: [PATCH 2/9] test: :bug: resolve "table_biomass_abundance_catch generates error with incorrect module" test issue Test would fail with original module specification ("SPR_SERIES") because labels were present for the given module. Change to new module ("DERIVED_QUANTITIES") ensures test passes. --- tests/testthat/test-table_biomass_abundance_catch.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-table_biomass_abundance_catch.R b/tests/testthat/test-table_biomass_abundance_catch.R index 82b58464..6e3325cb 100644 --- a/tests/testthat/test-table_biomass_abundance_catch.R +++ b/tests/testthat/test-table_biomass_abundance_catch.R @@ -58,7 +58,7 @@ test_that("table_biomass_abundance_catch generates error with incorrect module", table_biomass_abundance_catch( dat = stockplotr::example_data, interactive = FALSE, - module = "SPR_SERIES", + module = "DERIVED_QUANTITIES", make_rda = FALSE, tables_dir = getwd() ) From 13859eb15fd5b1de94562d69953ba5f6ea600867 Mon Sep 17 00:00:00 2001 From: Joshua Zahner Date: Wed, 14 Oct 2026 14:46:49 -0400 Subject: [PATCH 3/9] test: :zap: set interactive=FALSE on all plotting tests this alleviates users from having to interact with the tests to confirm MODULE choices --- tests/testthat/test-plot_abundance_at_age.R | 12 +++++++++++- tests/testthat/test-plot_biomass.R | 11 +++++++++-- tests/testthat/test-plot_biomass_at_age.R | 12 ++++++++++-- tests/testthat/test-plot_catch_comp.R | 14 ++++++++++++-- tests/testthat/test-plot_index.R | 14 +++++++++++--- tests/testthat/test-plot_landings.R | 14 +++++++++++--- tests/testthat/test-plot_natural_mortality.R | 10 ++++++++-- tests/testthat/test-plot_recruitment.R | 9 +++++++-- .../testthat/test-plot_recruitment_deviations.R | 9 +++++++-- tests/testthat/test-plot_selectivity.R | 11 +++++++---- tests/testthat/test-plot_spawning_biomass.R | 17 +++++++++++++---- tests/testthat/test-plot_stock_recruitment.R | 6 +++++- .../test-table_biomass_abundance_catch.R | 1 + tests/testthat/test-table_index.R | 2 ++ tests/testthat/test-table_landings.R | 2 ++ tests/testthat/test-table_total_catch.R | 2 ++ 16 files changed, 118 insertions(+), 28 deletions(-) diff --git a/tests/testthat/test-plot_abundance_at_age.R b/tests/testthat/test-plot_abundance_at_age.R index 8acaca51..fe225f2f 100644 --- a/tests/testthat/test-plot_abundance_at_age.R +++ b/tests/testthat/test-plot_abundance_at_age.R @@ -1,7 +1,10 @@ test_that("plot_abundance_at_age generates plots without errors", { # expect error-free plot with minimal arguments expect_no_error( - plot_abundance_at_age(stockplotr::example_data) + plot_abundance_at_age( + stockplotr::example_data, + interactive = FALSE + ) ) # expect error-free plot with many arguments @@ -11,6 +14,7 @@ test_that("plot_abundance_at_age generates plots without errors", { facet = "area", unit_label = "fish", scale_amount = 1000, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -22,6 +26,7 @@ test_that("plot_abundance_at_age generates plots without errors", { stockplotr::example_data, unit_label = "fish", scale_amount = 1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ), @@ -34,6 +39,7 @@ test_that("rda file made when indicated", { plot_abundance_at_age( stockplotr::example_data, figures_dir = getwd(), + interactive = FALSE, make_rda = TRUE ) @@ -54,6 +60,7 @@ test_that("plot_abundance_at_age generates error with scaling <1", { stockplotr::example_data, unit_label = "fish", scale_amount = 0.1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -131,6 +138,7 @@ test_that("plot_abundance_at_age generates error when abundance label is not fou sample_data, unit_label = "fish", scale_amount = 1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -143,6 +151,7 @@ test_that("plot is made proportional and does not contain a legend", { unit_label = "fish", proportional = TRUE, scale_amount = 1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -155,6 +164,7 @@ test_that("plot contains a legend", { proportional = FALSE, unit_label = "fish", scale_amount = 1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) diff --git a/tests/testthat/test-plot_biomass.R b/tests/testthat/test-plot_biomass.R index f816f763..b3e2091f 100644 --- a/tests/testthat/test-plot_biomass.R +++ b/tests/testthat/test-plot_biomass.R @@ -29,7 +29,10 @@ test_that("plot_biomass generates plots without errors", { # expect error-free plot with minimal arguments expect_no_error( - plot_biomass(stockplotr::example_data) + plot_biomass( + stockplotr::example_data, + interactive = FALSE + ) ) # TODO: Update test @@ -46,6 +49,7 @@ test_that("plot_biomass generates plots without errors", { unit_label = "metric tons", scale_amount = 1, relative = FALSE, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd(), module = "TIME_SERIES" @@ -58,7 +62,8 @@ test_that("plot_biomass generates plots without errors", { stockplotr::example_data, unit_label = "mt", # scale_amount = 10, - relative = TRUE + relative = TRUE, + interactive = FALSE ) ) @@ -68,6 +73,7 @@ test_that("plot_biomass generates plots without errors", { stockplotr::example_data, unit_label = "metric tons", scale_amount = 1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd(), module = "TIME_SERIES" @@ -81,6 +87,7 @@ test_that("rda file made when indicated", { plot_biomass( stockplotr::example_data, figures_dir = getwd(), + interactive = FALSE, make_rda = TRUE, module = "TIME_SERIES" ) diff --git a/tests/testthat/test-plot_biomass_at_age.R b/tests/testthat/test-plot_biomass_at_age.R index 8639736c..1cb74696 100644 --- a/tests/testthat/test-plot_biomass_at_age.R +++ b/tests/testthat/test-plot_biomass_at_age.R @@ -1,8 +1,10 @@ test_that("plot_biomass_at_age generates plots without errors", { # expect error-free plot with minimal arguments expect_no_error( - plot_biomass_at_age(stockplotr::example_data, - module = "BIOMASS_AT_AGE" + plot_biomass_at_age( + stockplotr::example_data, + module = "BIOMASS_AT_AGE", + interactive = FALSE ) ) @@ -14,6 +16,7 @@ test_that("plot_biomass_at_age generates plots without errors", { proportional = FALSE, scale_amount = 10, module = "BIOMASS_AT_AGE", + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -26,6 +29,7 @@ test_that("plot_biomass_at_age generates plots without errors", { unit_label = "metric tons", scale_amount = 1, module = "BIOMASS_AT_AGE", + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ), @@ -38,6 +42,7 @@ test_that("rda file made when indicated", { plot_biomass_at_age( stockplotr::example_data, module = "BIOMASS_AT_AGE", + interactive = FALSE, figures_dir = getwd(), make_rda = TRUE ) @@ -123,6 +128,7 @@ test_that("plot_biomass_at_age generates error when biomass label is not found", sample_data, unit_label = "fish", scale_amount = 1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -136,6 +142,7 @@ test_that("plot is made proportional and does not contain a legend", { unit_label = "fish", proportional = TRUE, scale_amount = 1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -149,6 +156,7 @@ test_that("plot contains a legend", { proportional = FALSE, unit_label = "fish", scale_amount = 1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) diff --git a/tests/testthat/test-plot_catch_comp.R b/tests/testthat/test-plot_catch_comp.R index d5edb287..79356c74 100644 --- a/tests/testthat/test-plot_catch_comp.R +++ b/tests/testthat/test-plot_catch_comp.R @@ -2,8 +2,10 @@ test_that("plot_catch_comp generates plots without errors", { # expect error-free plot with minimal arguments expect_no_error( - plot_catch_comp(stockplotr::example_data, - module = "CATCH_AT_AGE" + plot_catch_comp( + stockplotr::example_data, + module = "CATCH_AT_AGE", + interactive = FALSE ) ) @@ -15,6 +17,7 @@ test_that("plot_catch_comp generates plots without errors", { unit_label = "fish", scale_amount = 1000, module = "CATCH_AT_AGE", + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -27,6 +30,7 @@ test_that("plot_catch_comp generates plots without errors", { unit_label = "fish", scale_amount = 1, module = "CATCH_AT_AGE", + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ), @@ -39,6 +43,7 @@ test_that("rda file made when indicated", { plot_catch_comp( stockplotr::example_data, module = "CATCH_AT_AGE", + interactive = FALSE, figures_dir = getwd(), make_rda = TRUE ) @@ -60,6 +65,7 @@ test_that("plot_catch_comp generates error with scaling <1", { stockplotr::example_data, unit_label = "fish", scale_amount = 0.1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -137,6 +143,7 @@ test_that("plot_catch_comp generates error when catch label is not found", { sample_data, unit_label = "fish", scale_amount = 1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -150,6 +157,7 @@ test_that("plot is made proportional and does not contain a legend", { module = "CATCH_AT_AGE", proportional = TRUE, scale_amount = 1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -163,6 +171,7 @@ test_that("plot contains a legend", { module = "CATCH_AT_AGE", unit_label = "fish", scale_amount = 1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -176,6 +185,7 @@ test_that("year class lines are plotted", { unit_label = "fish", module = "CATCH_AT_AGE", scale_amount = 1, + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) diff --git a/tests/testthat/test-plot_index.R b/tests/testthat/test-plot_index.R index 26ea0695..276c6406 100644 --- a/tests/testthat/test-plot_index.R +++ b/tests/testthat/test-plot_index.R @@ -1,21 +1,29 @@ test_that("plot_index generates plots without errors", { # expect error-free plot with minimal arguments expect_no_error( - plot_index(stockplotr::example_data) + plot_index( + stockplotr::example_data, + interactive = FALSE + ) ) # expect ggplot object is returned expect_s3_class( - plot_index(stockplotr::example_data), + plot_index( + stockplotr::example_data, + interactive = FALSE + ), "gg" ) }) test_that("rda file made when indicated", { # export rda - plot_index(stockplotr::example_data, + plot_index( + stockplotr::example_data, make_rda = TRUE, unit_label = "metric tons", + interactive = FALSE, figures_dir = getwd() ) diff --git a/tests/testthat/test-plot_landings.R b/tests/testthat/test-plot_landings.R index 12961856..cfe8bdae 100644 --- a/tests/testthat/test-plot_landings.R +++ b/tests/testthat/test-plot_landings.R @@ -1,20 +1,28 @@ test_that("plot_landings generates plots without errors", { # expect error-free plot with minimal arguments expect_no_error( - plot_landings(stockplotr::example_data) + plot_landings( + stockplotr::example_data, + interactive = FALSE + ) ) # expect ggplot object is returned expect_s3_class( - plot_landings(stockplotr::example_data), + plot_landings( + stockplotr::example_data, + interactive = FALSE + ), "gg" ) }) test_that("rda file made when indicated", { # export rda - plot_landings(stockplotr::example_data, + plot_landings( + stockplotr::example_data, + interactive = FALSE, make_rda = TRUE, unit_label = "metric tons", figures_dir = getwd() diff --git a/tests/testthat/test-plot_natural_mortality.R b/tests/testthat/test-plot_natural_mortality.R index 9119ecd0..f082b2fe 100644 --- a/tests/testthat/test-plot_natural_mortality.R +++ b/tests/testthat/test-plot_natural_mortality.R @@ -1,7 +1,11 @@ test_that("plot_natural_mortality generate without errors", { # expect error-free plot with minimal arguments expect_no_error( - plot_natural_mortality(stockplotr::example_data, module = "Natural_Mortality") + plot_natural_mortality( + stockplotr::example_data, + module = "Natural_Mortality", + interactive = FALSE + ) ) # This check is moot with the more flextible approach and labelling? @@ -14,7 +18,8 @@ test_that("plot_natural_mortality generate without errors", { expect_s3_class( plot_natural_mortality( stockplotr::example_data, - module = "Natural_Mortality" + module = "Natural_Mortality", + interactive = FALSE ), "gg" ) @@ -25,6 +30,7 @@ test_that("rda file made when indicated", { plot_natural_mortality( stockplotr::example_data, module = "Natural_Mortality", + interactive = FALSE, make_rda = TRUE, figures_dir = getwd() ) diff --git a/tests/testthat/test-plot_recruitment.R b/tests/testthat/test-plot_recruitment.R index 545d3aac..7cbb763c 100644 --- a/tests/testthat/test-plot_recruitment.R +++ b/tests/testthat/test-plot_recruitment.R @@ -1,8 +1,10 @@ test_that("plot_recruitment generates plots without errors", { # expect error-free plot with minimal arguments expect_no_error( - plot_recruitment(stockplotr::example_data, - module = "TIME_SERIES" + plot_recruitment( + stockplotr::example_data, + module = "TIME_SERIES", + interactive = FALSE ) ) @@ -13,6 +15,7 @@ test_that("plot_recruitment generates plots without errors", { unit_label = "mt", scale_amount = 10, module = "TIME_SERIES", + interactive = FALSE, # relative = FALSE, make_rda = FALSE, figures_dir = getwd() @@ -42,6 +45,7 @@ test_that("plot_recruitment generates plots without errors", { scale_amount = 10, # relative = TRUE, module = "TIME_SERIES", + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ), @@ -54,6 +58,7 @@ test_that("rda file made when indicated", { plot_recruitment( stockplotr::example_data, module = "TIME_SERIES", + interactive = FALSE, figures_dir = getwd(), make_rda = TRUE ) diff --git a/tests/testthat/test-plot_recruitment_deviations.R b/tests/testthat/test-plot_recruitment_deviations.R index ad97aad6..efa631ca 100644 --- a/tests/testthat/test-plot_recruitment_deviations.R +++ b/tests/testthat/test-plot_recruitment_deviations.R @@ -1,8 +1,10 @@ test_that("plot_recruitment_deviations generates plots without errors", { # expect error-free plot with minimal arguments expect_no_error( - plot_recruitment_deviations(stockplotr::example_data, - module = "SPAWN_RECRUIT" + plot_recruitment_deviations( + stockplotr::example_data, + module = "SPAWN_RECRUIT", + interactive = FALSE ) ) @@ -11,6 +13,7 @@ test_that("plot_recruitment_deviations generates plots without errors", { plot_recruitment_deviations( stockplotr::example_data, module = "SPAWN_RECRUIT", + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -21,6 +24,7 @@ test_that("plot_recruitment_deviations generates plots without errors", { plot_recruitment_deviations( stockplotr::example_data, module = "SPAWN_RECRUIT", + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ), @@ -33,6 +37,7 @@ test_that("rda file made when indicated", { plot_recruitment_deviations( stockplotr::example_data, module = "SPAWN_RECRUIT", + interactive = FALSE, make_rda = TRUE, figures_dir = getwd() ) diff --git a/tests/testthat/test-plot_selectivity.R b/tests/testthat/test-plot_selectivity.R index 1221b0c1..8b4723ac 100644 --- a/tests/testthat/test-plot_selectivity.R +++ b/tests/testthat/test-plot_selectivity.R @@ -2,7 +2,8 @@ test_that("plot_selectivity generates plots without errors", { # expect error-free plot with minimal arguments expect_no_error( plot_selectivity( - stockplotr::example_data + stockplotr::example_data, + interactive = FALSE ) ) @@ -14,7 +15,7 @@ test_that("plot_selectivity generates plots without errors", { era = NULL, group = NULL, facet = NULL, - interactive = TRUE, + interactive = FALSE, module = "AGE_SELEX", make_rda = FALSE, figures_dir = getwd() @@ -28,7 +29,7 @@ test_that("plot_selectivity generates plots without errors", { unit_label = "mm", group = NULL, facet = NULL, - interactive = TRUE, + interactive = FALSE, module = "LEN_SELEX", make_rda = FALSE, figures_dir = getwd() @@ -38,7 +39,8 @@ test_that("plot_selectivity generates plots without errors", { # expect ggplot object is returned expect_s3_class( plot_selectivity( - stockplotr::example_data + stockplotr::example_data, + interactive = FALSE ), "gg" ) @@ -49,6 +51,7 @@ test_that("rda file made when indicated", { plot_selectivity( stockplotr::example_data, module = "AGE_SELEX", + interactive = FALSE, figures_dir = getwd(), make_rda = TRUE ) diff --git a/tests/testthat/test-plot_spawning_biomass.R b/tests/testthat/test-plot_spawning_biomass.R index e467d648..d5194a7c 100644 --- a/tests/testthat/test-plot_spawning_biomass.R +++ b/tests/testthat/test-plot_spawning_biomass.R @@ -1,12 +1,18 @@ test_that("plot_spawning_biomass generates plots without errors", { # expect error-free plot with minimal arguments expect_no_error( - plot_spawning_biomass(stockplotr::example_data) + plot_spawning_biomass( + stockplotr::example_data, + interactive = FALSE + ) ) # expect plot with warnings if ref_point not indicated expect_message( - plot_spawning_biomass(stockplotr::example_data) + plot_spawning_biomass( + stockplotr::example_data, + interactive = FALSE + ) ) # expect error-free plot with many arguments @@ -15,7 +21,8 @@ test_that("plot_spawning_biomass generates plots without errors", { stockplotr::example_data, unit_label = "metric tons", scale_amount = 1, - ref_line = "msy" + ref_line = "msy", + interactive = FALSE ) ) @@ -26,7 +33,8 @@ test_that("plot_spawning_biomass generates plots without errors", { unit_label = "metric tons", scale_amount = 1, ref_line = c("msy" = 2000000), - relative = FALSE + relative = FALSE, + interactive = FALSE ), "gg" ) @@ -40,6 +48,7 @@ test_that("rda file made when indicated", { scale_amount = 1, ref_line = "msy", module = "TIME_SERIES", + interactive = FALSE, make_rda = TRUE, figures_dir = getwd() ) diff --git a/tests/testthat/test-plot_stock_recruitment.R b/tests/testthat/test-plot_stock_recruitment.R index 569eead4..3e63f676 100644 --- a/tests/testthat/test-plot_stock_recruitment.R +++ b/tests/testthat/test-plot_stock_recruitment.R @@ -2,7 +2,8 @@ test_that("plot_stock_recruitment generates plots without errors", { # expect error-free plot with minimal arguments expect_no_error( stockplotr::plot_stock_recruitment( - dat = stockplotr::example_data + dat = stockplotr::example_data, + interactive = FALSE ) ) @@ -12,6 +13,7 @@ test_that("plot_stock_recruitment generates plots without errors", { stockplotr::example_data, spawning_biomass_label = "mt", recruitment_label = "mt", + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ) @@ -24,6 +26,7 @@ test_that("plot_stock_recruitment generates plots without errors", { stockplotr::example_data, spawning_biomass_label = "mt", recruitment_label = "mt", + interactive = FALSE, make_rda = FALSE, figures_dir = getwd() ), @@ -37,6 +40,7 @@ test_that("rda file made when indicated", { stockplotr::example_data, spawning_biomass_label = "mt", recruitment_label = "mt", + interactive = FALSE, make_rda = TRUE, figures_dir = getwd() ) diff --git a/tests/testthat/test-table_biomass_abundance_catch.R b/tests/testthat/test-table_biomass_abundance_catch.R index 6e3325cb..7e3f0d3c 100644 --- a/tests/testthat/test-table_biomass_abundance_catch.R +++ b/tests/testthat/test-table_biomass_abundance_catch.R @@ -38,6 +38,7 @@ test_that("rda file made when indicated", { table_biomass_abundance_catch( dat = stockplotr::example_data, module = c("TIME_SERIES", "CATCH", "TIME_SERIES"), + interactive = FALSE, make_rda = TRUE, tables_dir = getwd() ) diff --git a/tests/testthat/test-table_index.R b/tests/testthat/test-table_index.R index c17434e3..34f26b6f 100644 --- a/tests/testthat/test-table_index.R +++ b/tests/testthat/test-table_index.R @@ -37,6 +37,7 @@ test_that("rda file made when indicated", { # export rda table_index( dat = stockplotr::example_data, + interactive = FALSE, make_rda = TRUE, tables_dir = getwd() ) @@ -53,6 +54,7 @@ test_that("rda file made when indicated", { # export rda table_index( dat = stockplotr::example_data, + interactive = FALSE, make_rda = TRUE, tables_dir = getwd() ) diff --git a/tests/testthat/test-table_landings.R b/tests/testthat/test-table_landings.R index c7c8c9d3..2459b5b7 100644 --- a/tests/testthat/test-table_landings.R +++ b/tests/testthat/test-table_landings.R @@ -80,6 +80,7 @@ test_that("rda file made when indicated", { # export rda table_landings( dat = stockplotr::example_data, + interactive = FALSE, make_rda = TRUE, tables_dir = getwd() ) @@ -96,6 +97,7 @@ test_that("rda file made when indicated", { # export rda table_landings( dat = stockplotr::example_data, + interactive = FALSE, make_rda = TRUE, tables_dir = getwd() ) diff --git a/tests/testthat/test-table_total_catch.R b/tests/testthat/test-table_total_catch.R index 319771b2..bd1f73b3 100644 --- a/tests/testthat/test-table_total_catch.R +++ b/tests/testthat/test-table_total_catch.R @@ -81,6 +81,7 @@ test_that("rda file made when indicated", { table_total_catch( dat = stockplotr::example_data, module = "TIME_SERIES", + interactive = FALSE, make_rda = TRUE, tables_dir = getwd() ) @@ -99,6 +100,7 @@ test_that("rda file made when indicated", { table_total_catch( dat = stockplotr::example_data, module = "TIME_SERIES", + interactive = FALSE, make_rda = TRUE, tables_dir = getwd() ) From e7913ccd50b6c41c3fa1350619fa2593c85f3c02 Mon Sep 17 00:00:00 2001 From: Joshua Zahner Date: Wed, 14 Oct 2026 16:02:36 -0400 Subject: [PATCH 4/9] test: :zap: clean ups to remove warnings from tests --- R/convert_output.R | 4 ++-- R/table_total_catch.R | 2 +- tests/testthat/test-plot_biomass.R | 2 +- tests/testthat/test-plot_selectivity.R | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/R/convert_output.R b/R/convert_output.R index 62fed9e0..86285689 100644 --- a/R/convert_output.R +++ b/R/convert_output.R @@ -439,7 +439,7 @@ convert_output <- function( for (i in intersect(tolower(fleet_names), colnames(df3))) { col_name <- glue::glue("exploitation_{i}") df3 <- df3 |> - dplyr::rename(!!col_name := i) + dplyr::rename(!!col_name := dplyr::all_of(i)) } } } @@ -488,7 +488,7 @@ convert_output <- function( if (length(err_col_id) > 0) { uncert_name <- stringr::str_extract(err_col_id, paste0(errors, collapse = "|")) df3 <- df3 |> - dplyr::rename(!!uncert_name := err_col_id) + dplyr::rename(!!uncert_name := dplyr::all_of(err_col_id)) } df4 <- df3 |> tidyr::pivot_longer( diff --git a/R/table_total_catch.R b/R/table_total_catch.R index 8c1f79a5..bb1f3529 100644 --- a/R/table_total_catch.R +++ b/R/table_total_catch.R @@ -116,7 +116,7 @@ table_total_catch <- function( } catch <- catch |> - dplyr::select(-cols_to_remove) + dplyr::select(-dplyr::all_of(cols_to_remove)) if ("uncertainty" %in% colnames(catch)) { catch <- catch |> diff --git a/tests/testthat/test-plot_biomass.R b/tests/testthat/test-plot_biomass.R index b3e2091f..915c01cb 100644 --- a/tests/testthat/test-plot_biomass.R +++ b/tests/testthat/test-plot_biomass.R @@ -45,7 +45,7 @@ test_that("plot_biomass generates plots without errors", { expect_no_error( plot_biomass( stockplotr::example_data, - ref_point = c("target" = 18000), + ref_line = c("target" = 18000), unit_label = "metric tons", scale_amount = 1, relative = FALSE, diff --git a/tests/testthat/test-plot_selectivity.R b/tests/testthat/test-plot_selectivity.R index 8b4723ac..0e9f3cfe 100644 --- a/tests/testthat/test-plot_selectivity.R +++ b/tests/testthat/test-plot_selectivity.R @@ -12,7 +12,6 @@ test_that("plot_selectivity generates plots without errors", { plot_selectivity( stockplotr::example_data |> dplyr::filter(year == 2020), - era = NULL, group = NULL, facet = NULL, interactive = FALSE, From 89486c7aece00cdab778221fefa94ae53354fe00 Mon Sep 17 00:00:00 2001 From: Joshua Zahner Date: Wed, 14 Oct 2026 16:27:45 -0400 Subject: [PATCH 5/9] refactor: :art: replaced file check calls in "rda file made when indicated" tests with routine function call --- tests/testthat/helper-test_functions.R | 29 +++++++++++++++++++ tests/testthat/test-plot_abundance_at_age.R | 10 ++----- tests/testthat/test-plot_biomass.R | 8 +---- tests/testthat/test-plot_biomass_at_age.R | 8 +---- tests/testthat/test-plot_catch_comp.R | 8 +---- tests/testthat/test-plot_index.R | 8 +---- tests/testthat/test-plot_landings.R | 8 +---- tests/testthat/test-plot_natural_mortality.R | 8 +---- tests/testthat/test-plot_recruitment.R | 8 +---- .../test-plot_recruitment_deviations.R | 8 +---- tests/testthat/test-plot_selectivity.R | 8 +---- tests/testthat/test-plot_spawning_biomass.R | 8 +---- tests/testthat/test-plot_stock_recruitment.R | 8 +---- 13 files changed, 42 insertions(+), 85 deletions(-) create mode 100644 tests/testthat/helper-test_functions.R diff --git a/tests/testthat/helper-test_functions.R b/tests/testthat/helper-test_functions.R new file mode 100644 index 00000000..f920f6e6 --- /dev/null +++ b/tests/testthat/helper-test_functions.R @@ -0,0 +1,29 @@ +#' Check for the existence and remove .rda files from test environment +#' +#' Checks for the existence of `dir` and `filename` as well as the +#' existence of "captions_alt_text.csv" and "key_quantities.csv". +#' Files are removed upon completion of checks. +#' +#' For testing only. +#' +#' @param filename String. filename of figure/table .rda file +#' @param dir String. directory where filename exists +#' +check_and_remove_tmp_files <- function(filename, dir=fs::path(getwd())){ + # expect that both figures dir and the abundance_at_age_figure.rda file exist + expect_true(dir.exists(dir)) # this check needs to exist in case save dir isnt getwd() + expect_true(dir.exists(fs::path(dir, "figures"))) + expect_true(file.exists(fs::path(dir, "figures", filename))) + + # erase temporary testing files + captions_file <- fs::path(dir, "captions_alt_text.csv") + keyquant_file <- fs::path(dir, "key_quantities.csv") + + if(fs::file_exists(captions_file)) + fs::file_delete(captions_file) + + if(fs::file_exists(keyquant_file)) + fs::file_delete(keyquant_file) + + unlink(fs::path(dir, "figures"), recursive = T) +} diff --git a/tests/testthat/test-plot_abundance_at_age.R b/tests/testthat/test-plot_abundance_at_age.R index fe225f2f..3bed4d19 100644 --- a/tests/testthat/test-plot_abundance_at_age.R +++ b/tests/testthat/test-plot_abundance_at_age.R @@ -39,18 +39,12 @@ test_that("rda file made when indicated", { plot_abundance_at_age( stockplotr::example_data, figures_dir = getwd(), - interactive = FALSE, + interactive = FALSE, make_rda = TRUE ) # expect that both figures dir and the abundance_at_age_figure.rda file exist - expect_true(dir.exists(fs::path(getwd(), "figures"))) - expect_true(file.exists(fs::path(getwd(), "figures", "abundance_at_age_figure.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "figures"), recursive = T) + check_and_remove_tmp_files("abundance_at_age_figure.rda") }) test_that("plot_abundance_at_age generates error with scaling <1", { diff --git a/tests/testthat/test-plot_biomass.R b/tests/testthat/test-plot_biomass.R index 915c01cb..c4136da5 100644 --- a/tests/testthat/test-plot_biomass.R +++ b/tests/testthat/test-plot_biomass.R @@ -93,11 +93,5 @@ test_that("rda file made when indicated", { ) # expect that both figures dir and the biomass_figure.rda file exist - expect_true(dir.exists(fs::path(getwd(), "figures"))) - expect_true(file.exists(fs::path(getwd(), "figures", "biomass_figure.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "figures"), recursive = T) + check_and_remove_tmp_files("biomass_figure.rda") }) diff --git a/tests/testthat/test-plot_biomass_at_age.R b/tests/testthat/test-plot_biomass_at_age.R index 1cb74696..acb4e995 100644 --- a/tests/testthat/test-plot_biomass_at_age.R +++ b/tests/testthat/test-plot_biomass_at_age.R @@ -48,13 +48,7 @@ test_that("rda file made when indicated", { ) # expect that both figures dir and the biomass_at_age_figure.rda file exist - expect_true(dir.exists(fs::path(getwd(), "figures"))) - expect_true(file.exists(fs::path(getwd(), "figures", "biomass_at_age_figure.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "figures"), recursive = T) + check_and_remove_tmp_files("biomass_at_age_figure.rda") }) test_that("plot_biomass_at_age generates error when biomass label is not found", { diff --git a/tests/testthat/test-plot_catch_comp.R b/tests/testthat/test-plot_catch_comp.R index 79356c74..bcd847d7 100644 --- a/tests/testthat/test-plot_catch_comp.R +++ b/tests/testthat/test-plot_catch_comp.R @@ -49,13 +49,7 @@ test_that("rda file made when indicated", { ) # expect that both figures dir and the catch_comp_figure.rda file exist - expect_true(dir.exists(fs::path(getwd(), "figures"))) - expect_true(file.exists(fs::path(getwd(), "figures", "catch_comp_figure.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "figures"), recursive = T) + check_and_remove_tmp_files("catch_comp_figure.rda") }) test_that("plot_catch_comp generates error with scaling <1", { diff --git a/tests/testthat/test-plot_index.R b/tests/testthat/test-plot_index.R index 276c6406..2a190aa3 100644 --- a/tests/testthat/test-plot_index.R +++ b/tests/testthat/test-plot_index.R @@ -28,11 +28,5 @@ test_that("rda file made when indicated", { ) # expect that both figures dir and the index_figure.rda file exist - expect_true(dir.exists(fs::path(getwd(), "figures"))) - expect_true(file.exists(fs::path(getwd(), "figures", "index_figure.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "figures"), recursive = T) + check_and_remove_tmp_files("index_figure.rda") }) diff --git a/tests/testthat/test-plot_landings.R b/tests/testthat/test-plot_landings.R index cfe8bdae..f0dc9339 100644 --- a/tests/testthat/test-plot_landings.R +++ b/tests/testthat/test-plot_landings.R @@ -29,11 +29,5 @@ test_that("rda file made when indicated", { ) # expect that both figures dir and the landings_figure.rda file exist - expect_true(dir.exists(fs::path(getwd(), "figures"))) - expect_true(file.exists(fs::path(getwd(), "figures", "landings_figure.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "figures"), recursive = T) + check_and_remove_tmp_files("landings_figure.rda") }) diff --git a/tests/testthat/test-plot_natural_mortality.R b/tests/testthat/test-plot_natural_mortality.R index f082b2fe..f26efb37 100644 --- a/tests/testthat/test-plot_natural_mortality.R +++ b/tests/testthat/test-plot_natural_mortality.R @@ -36,11 +36,5 @@ test_that("rda file made when indicated", { ) # expect that both figures dir and the natural_mortality_figure.rda file exist - expect_true(dir.exists(fs::path(getwd(), "figures"))) - expect_true(file.exists(fs::path(getwd(), "figures", "natural_mortality_figure.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "figures"), recursive = T) + check_and_remove_tmp_files("natural_mortality_figure.rda") }) diff --git a/tests/testthat/test-plot_recruitment.R b/tests/testthat/test-plot_recruitment.R index 7cbb763c..d6d1dd08 100644 --- a/tests/testthat/test-plot_recruitment.R +++ b/tests/testthat/test-plot_recruitment.R @@ -64,11 +64,5 @@ test_that("rda file made when indicated", { ) # expect that both figures dir and the recruitment_figure.rda file exist - expect_true(dir.exists(fs::path(getwd(), "figures"))) - expect_true(file.exists(fs::path(getwd(), "figures", "recruitment_figure.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "figures"), recursive = T) + check_and_remove_tmp_files("recruitment_figure.rda") }) diff --git a/tests/testthat/test-plot_recruitment_deviations.R b/tests/testthat/test-plot_recruitment_deviations.R index efa631ca..69126810 100644 --- a/tests/testthat/test-plot_recruitment_deviations.R +++ b/tests/testthat/test-plot_recruitment_deviations.R @@ -43,11 +43,5 @@ test_that("rda file made when indicated", { ) # expect that both figures dir and the recruitment_deviations_figure.rda file exist - expect_true(dir.exists(fs::path(getwd(), "figures"))) - expect_true(file.exists(fs::path(getwd(), "figures", "recruitment_deviations_figure.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "figures"), recursive = T) + check_and_remove_tmp_files("recruitment_deviations_figure.rda") }) diff --git a/tests/testthat/test-plot_selectivity.R b/tests/testthat/test-plot_selectivity.R index 0e9f3cfe..ed097ffd 100644 --- a/tests/testthat/test-plot_selectivity.R +++ b/tests/testthat/test-plot_selectivity.R @@ -56,11 +56,5 @@ test_that("rda file made when indicated", { ) # expect that both figures dir and the selectivity_figure.rda file exist - expect_true(dir.exists(fs::path(getwd(), "figures"))) - expect_true(file.exists(fs::path(getwd(), "figures", "selectivity_figure.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "figures"), recursive = T) + check_and_remove_tmp_files("selectivity_figure.rda") }) diff --git a/tests/testthat/test-plot_spawning_biomass.R b/tests/testthat/test-plot_spawning_biomass.R index d5194a7c..40cc4521 100644 --- a/tests/testthat/test-plot_spawning_biomass.R +++ b/tests/testthat/test-plot_spawning_biomass.R @@ -54,11 +54,5 @@ test_that("rda file made when indicated", { ) # expect that both figures dir and the spawning_biomass_figure.rda file exist - expect_true(dir.exists(fs::path(getwd(), "figures"))) - expect_true(file.exists(fs::path(getwd(), "figures", "spawning_biomass_figure.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "figures"), recursive = T) + check_and_remove_tmp_files("spawning_biomass_figure.rda") }) diff --git a/tests/testthat/test-plot_stock_recruitment.R b/tests/testthat/test-plot_stock_recruitment.R index 3e63f676..64288b80 100644 --- a/tests/testthat/test-plot_stock_recruitment.R +++ b/tests/testthat/test-plot_stock_recruitment.R @@ -46,11 +46,5 @@ test_that("rda file made when indicated", { ) # expect that both figures dir and the sr_figure.rda file exist - expect_true(dir.exists(fs::path(getwd(), "figures"))) - expect_true(file.exists(fs::path(getwd(), "figures", "stock_recruitment_figure.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "figures"), recursive = T) + check_and_remove_tmp_files("stock_recruitment_figure.rda") }) From 45ea79e174c99484d7b7dd569d905362445a4ea5 Mon Sep 17 00:00:00 2001 From: Joshua Zahner Date: Wed, 14 Oct 2026 17:05:48 -0400 Subject: [PATCH 6/9] refactor: :art: updated check_and_remove_tmp_files to work for temporary table files from tests --- tests/testthat/helper-test_functions.R | 11 +++++---- .../test-table_biomass_abundance_catch.R | 8 +------ tests/testthat/test-table_index.R | 20 +--------------- tests/testthat/test-table_landings.R | 21 +---------------- tests/testthat/test-table_projections.R | 8 +------ tests/testthat/test-table_total_catch.R | 23 +------------------ 6 files changed, 12 insertions(+), 79 deletions(-) diff --git a/tests/testthat/helper-test_functions.R b/tests/testthat/helper-test_functions.R index f920f6e6..78688e07 100644 --- a/tests/testthat/helper-test_functions.R +++ b/tests/testthat/helper-test_functions.R @@ -8,12 +8,15 @@ #' #' @param filename String. filename of figure/table .rda file #' @param dir String. directory where filename exists +#' @param figs_or_tables String. whether check for a "figures" or "tables" internal directory #' -check_and_remove_tmp_files <- function(filename, dir=fs::path(getwd())){ +#' DEFAULT: "figures" +#' +check_and_remove_tmp_files <- function(filename, dir=fs::path(getwd()), figs_or_tables="figures"){ # expect that both figures dir and the abundance_at_age_figure.rda file exist expect_true(dir.exists(dir)) # this check needs to exist in case save dir isnt getwd() - expect_true(dir.exists(fs::path(dir, "figures"))) - expect_true(file.exists(fs::path(dir, "figures", filename))) + expect_true(dir.exists(fs::path(dir, figs_or_tables))) + expect_true(file.exists(fs::path(dir, figs_or_tables, filename))) # erase temporary testing files captions_file <- fs::path(dir, "captions_alt_text.csv") @@ -25,5 +28,5 @@ check_and_remove_tmp_files <- function(filename, dir=fs::path(getwd())){ if(fs::file_exists(keyquant_file)) fs::file_delete(keyquant_file) - unlink(fs::path(dir, "figures"), recursive = T) + unlink(fs::path(dir, figs_or_tables), recursive = T) } diff --git a/tests/testthat/test-table_biomass_abundance_catch.R b/tests/testthat/test-table_biomass_abundance_catch.R index 7e3f0d3c..6f753ac0 100644 --- a/tests/testthat/test-table_biomass_abundance_catch.R +++ b/tests/testthat/test-table_biomass_abundance_catch.R @@ -44,13 +44,7 @@ test_that("rda file made when indicated", { ) # expect that both tables dir and the biomass_abundance_catch_table.rda file exist - expect_true(dir.exists(fs::path(getwd(), "tables"))) - expect_true(file.exists(fs::path(getwd(), "tables", "biomass_abundance_catch_table.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "tables"), recursive = T) + check_and_remove_tmp_files("biomass_abundance_catch_table.rda", figs_or_tables="tables") }) test_that("table_biomass_abundance_catch generates error with incorrect module", { diff --git a/tests/testthat/test-table_index.R b/tests/testthat/test-table_index.R index 34f26b6f..4946f025 100644 --- a/tests/testthat/test-table_index.R +++ b/tests/testthat/test-table_index.R @@ -34,23 +34,6 @@ test_that("table_index generates plots without errors", { }) test_that("rda file made when indicated", { - # export rda - table_index( - dat = stockplotr::example_data, - interactive = FALSE, - make_rda = TRUE, - tables_dir = getwd() - ) - - # expect that both tables dir and the index_table.rda file exist - expect_true(dir.exists(fs::path(getwd(), "tables"))) - expect_true(file.exists(fs::path(getwd(), "tables", "index_table.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - unlink(fs::path(getwd(), "tables"), recursive = T) - - # export rda table_index( dat = stockplotr::example_data, @@ -75,6 +58,5 @@ test_that("rda file made when indicated", { expect_true(rda$caption == "Calculated index of abundance and corresponding CVs for the fleets and surveys identified in the column headers. ") # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - unlink(fs::path(getwd(), "tables"), recursive = T) + check_and_remove_tmp_files("index_table.rda", figs_or_tables="tables") }) diff --git a/tests/testthat/test-table_landings.R b/tests/testthat/test-table_landings.R index 2459b5b7..236f4c37 100644 --- a/tests/testthat/test-table_landings.R +++ b/tests/testthat/test-table_landings.R @@ -85,23 +85,6 @@ test_that("rda file made when indicated", { tables_dir = getwd() ) - # expect that both tables dir and the landings_table.rda file exist - expect_true(dir.exists(fs::path(getwd(), "tables"))) - expect_true(file.exists(fs::path(getwd(), "tables", "landings_table.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "tables"), recursive = T) - - # export rda - table_landings( - dat = stockplotr::example_data, - interactive = FALSE, - make_rda = TRUE, - tables_dir = getwd() - ) - # load the rda file and check that it contains the expected object load(fs::path(getwd(), "tables", "landings_table.rda")) # expect rda contains three objects: table, caption, and latex table @@ -118,7 +101,5 @@ test_that("rda file made when indicated", { expect_true(rda$caption == "Landed catch by fleet and year in (mt).") # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "tables"), recursive = T) + check_and_remove_tmp_files("landings_table.rda", figs_or_tables="tables") }) diff --git a/tests/testthat/test-table_projections.R b/tests/testthat/test-table_projections.R index 77d631d2..58ad4f1f 100644 --- a/tests/testthat/test-table_projections.R +++ b/tests/testthat/test-table_projections.R @@ -28,13 +28,7 @@ test_that("rda file made when indicated", { ) # expect that both tables dir and the projections_table.rda file exist - expect_true(dir.exists(fs::path(getwd(), "tables"))) - expect_true(file.exists(fs::path(getwd(), "tables", "projections_table.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "tables"), recursive = T) + check_and_remove_tmp_files("projections_table.rda", figs_or_tables="tables") }) test_that("table_projections generates error with incorrect module", { diff --git a/tests/testthat/test-table_total_catch.R b/tests/testthat/test-table_total_catch.R index bd1f73b3..8af7899d 100644 --- a/tests/testthat/test-table_total_catch.R +++ b/tests/testthat/test-table_total_catch.R @@ -77,25 +77,6 @@ test_that("table_total_catch generates error with incorrect module", { test_that("rda file made when indicated", { - # export rda - table_total_catch( - dat = stockplotr::example_data, - module = "TIME_SERIES", - interactive = FALSE, - make_rda = TRUE, - tables_dir = getwd() - ) - - # expect that both tables dir and the total_catch_table.rda file exist - expect_true(dir.exists(fs::path(getwd(), "tables"))) - expect_true(file.exists(fs::path(getwd(), "tables", "total_catch_table.rda"))) - - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "tables"), recursive = T) - - # export rda table_total_catch( dat = stockplotr::example_data, @@ -121,7 +102,5 @@ test_that("rda file made when indicated", { expect_true(rda$caption == "Total catch by fleet over time.") # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "tables"), recursive = T) + check_and_remove_tmp_files("total_catch_table.rda", figs_or_tables="tables") }) From 4e20f1e047d89596944bb346434d3fdb797343cf Mon Sep 17 00:00:00 2001 From: Joshua Zahner Date: Fri, 16 Oct 2026 11:35:53 -0400 Subject: [PATCH 7/9] test: :zap: remove redundant rda generation test plot specific tests for rda generation were redundant with the save_all_plots test --- tests/testthat/test-plot_abundance_at_age.R | 22 ++++----- tests/testthat/test-plot_biomass.R | 24 +++++----- tests/testthat/test-plot_biomass_at_age.R | 24 +++++----- tests/testthat/test-plot_catch_comp.R | 24 +++++----- tests/testthat/test-plot_index.R | 24 +++++----- tests/testthat/test-plot_landings.R | 24 +++++----- tests/testthat/test-plot_natural_mortality.R | 24 +++++----- tests/testthat/test-plot_recruitment.R | 24 +++++----- .../test-plot_recruitment_deviations.R | 24 +++++----- tests/testthat/test-plot_selectivity.R | 24 +++++----- tests/testthat/test-plot_spawning_biomass.R | 30 ++++++------ tests/testthat/test-plot_stock_recruitment.R | 26 +++++----- .../test-table_biomass_abundance_catch.R | 24 +++++----- tests/testthat/test-table_index.R | 48 +++++++++---------- tests/testthat/test-table_landings.R | 38 +++++++-------- tests/testthat/test-table_projections.R | 22 ++++----- 16 files changed, 213 insertions(+), 213 deletions(-) diff --git a/tests/testthat/test-plot_abundance_at_age.R b/tests/testthat/test-plot_abundance_at_age.R index 3bed4d19..64381c1e 100644 --- a/tests/testthat/test-plot_abundance_at_age.R +++ b/tests/testthat/test-plot_abundance_at_age.R @@ -34,18 +34,18 @@ test_that("plot_abundance_at_age generates plots without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - plot_abundance_at_age( - stockplotr::example_data, - figures_dir = getwd(), - interactive = FALSE, - make_rda = TRUE - ) +# test_that("rda file made when indicated", { +# # export rda +# plot_abundance_at_age( +# stockplotr::example_data, +# figures_dir = getwd(), +# interactive = FALSE, +# make_rda = TRUE +# ) - # expect that both figures dir and the abundance_at_age_figure.rda file exist - check_and_remove_tmp_files("abundance_at_age_figure.rda") -}) +# # expect that both figures dir and the abundance_at_age_figure.rda file exist +# check_and_remove_tmp_files("abundance_at_age_figure.rda") +# }) test_that("plot_abundance_at_age generates error with scaling <1", { # expect error diff --git a/tests/testthat/test-plot_biomass.R b/tests/testthat/test-plot_biomass.R index c4136da5..67506a40 100644 --- a/tests/testthat/test-plot_biomass.R +++ b/tests/testthat/test-plot_biomass.R @@ -82,16 +82,16 @@ test_that("plot_biomass generates plots without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - plot_biomass( - stockplotr::example_data, - figures_dir = getwd(), - interactive = FALSE, - make_rda = TRUE, - module = "TIME_SERIES" - ) +# test_that("rda file made when indicated", { +# # export rda +# plot_biomass( +# stockplotr::example_data, +# figures_dir = getwd(), +# interactive = FALSE, +# make_rda = TRUE, +# module = "TIME_SERIES" +# ) - # expect that both figures dir and the biomass_figure.rda file exist - check_and_remove_tmp_files("biomass_figure.rda") -}) +# # expect that both figures dir and the biomass_figure.rda file exist +# check_and_remove_tmp_files("biomass_figure.rda") +# }) diff --git a/tests/testthat/test-plot_biomass_at_age.R b/tests/testthat/test-plot_biomass_at_age.R index acb4e995..a19e4e59 100644 --- a/tests/testthat/test-plot_biomass_at_age.R +++ b/tests/testthat/test-plot_biomass_at_age.R @@ -37,19 +37,19 @@ test_that("plot_biomass_at_age generates plots without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - plot_biomass_at_age( - stockplotr::example_data, - module = "BIOMASS_AT_AGE", - interactive = FALSE, - figures_dir = getwd(), - make_rda = TRUE - ) +# test_that("rda file made when indicated", { +# # export rda +# plot_biomass_at_age( +# stockplotr::example_data, +# module = "BIOMASS_AT_AGE", +# interactive = FALSE, +# figures_dir = getwd(), +# make_rda = TRUE +# ) - # expect that both figures dir and the biomass_at_age_figure.rda file exist - check_and_remove_tmp_files("biomass_at_age_figure.rda") -}) +# # expect that both figures dir and the biomass_at_age_figure.rda file exist +# check_and_remove_tmp_files("biomass_at_age_figure.rda") +# }) test_that("plot_biomass_at_age generates error when biomass label is not found", { # generate test data set diff --git a/tests/testthat/test-plot_catch_comp.R b/tests/testthat/test-plot_catch_comp.R index bcd847d7..ad2e3c65 100644 --- a/tests/testthat/test-plot_catch_comp.R +++ b/tests/testthat/test-plot_catch_comp.R @@ -38,19 +38,19 @@ test_that("plot_catch_comp generates plots without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - plot_catch_comp( - stockplotr::example_data, - module = "CATCH_AT_AGE", - interactive = FALSE, - figures_dir = getwd(), - make_rda = TRUE - ) +# test_that("rda file made when indicated", { +# # export rda +# plot_catch_comp( +# stockplotr::example_data, +# module = "CATCH_AT_AGE", +# interactive = FALSE, +# figures_dir = getwd(), +# make_rda = TRUE +# ) - # expect that both figures dir and the catch_comp_figure.rda file exist - check_and_remove_tmp_files("catch_comp_figure.rda") -}) +# # expect that both figures dir and the catch_comp_figure.rda file exist +# check_and_remove_tmp_files("catch_comp_figure.rda") +# }) test_that("plot_catch_comp generates error with scaling <1", { # expect error diff --git a/tests/testthat/test-plot_index.R b/tests/testthat/test-plot_index.R index 2a190aa3..2a5239a3 100644 --- a/tests/testthat/test-plot_index.R +++ b/tests/testthat/test-plot_index.R @@ -17,16 +17,16 @@ test_that("plot_index generates plots without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - plot_index( - stockplotr::example_data, - make_rda = TRUE, - unit_label = "metric tons", - interactive = FALSE, - figures_dir = getwd() - ) +# test_that("rda file made when indicated", { +# # export rda +# plot_index( +# stockplotr::example_data, +# make_rda = TRUE, +# unit_label = "metric tons", +# interactive = FALSE, +# figures_dir = getwd() +# ) - # expect that both figures dir and the index_figure.rda file exist - check_and_remove_tmp_files("index_figure.rda") -}) +# # expect that both figures dir and the index_figure.rda file exist +# check_and_remove_tmp_files("index_figure.rda") +# }) diff --git a/tests/testthat/test-plot_landings.R b/tests/testthat/test-plot_landings.R index f0dc9339..2ffa0e9f 100644 --- a/tests/testthat/test-plot_landings.R +++ b/tests/testthat/test-plot_landings.R @@ -18,16 +18,16 @@ test_that("plot_landings generates plots without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - plot_landings( - stockplotr::example_data, - interactive = FALSE, - make_rda = TRUE, - unit_label = "metric tons", - figures_dir = getwd() - ) +# test_that("rda file made when indicated", { +# # export rda +# plot_landings( +# stockplotr::example_data, +# interactive = FALSE, +# make_rda = TRUE, +# unit_label = "metric tons", +# figures_dir = getwd() +# ) - # expect that both figures dir and the landings_figure.rda file exist - check_and_remove_tmp_files("landings_figure.rda") -}) +# # expect that both figures dir and the landings_figure.rda file exist +# check_and_remove_tmp_files("landings_figure.rda") +# }) diff --git a/tests/testthat/test-plot_natural_mortality.R b/tests/testthat/test-plot_natural_mortality.R index f26efb37..fb241f72 100644 --- a/tests/testthat/test-plot_natural_mortality.R +++ b/tests/testthat/test-plot_natural_mortality.R @@ -25,16 +25,16 @@ test_that("plot_natural_mortality generate without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - plot_natural_mortality( - stockplotr::example_data, - module = "Natural_Mortality", - interactive = FALSE, - make_rda = TRUE, - figures_dir = getwd() - ) +# test_that("rda file made when indicated", { +# # export rda +# plot_natural_mortality( +# stockplotr::example_data, +# module = "Natural_Mortality", +# interactive = FALSE, +# make_rda = TRUE, +# figures_dir = getwd() +# ) - # expect that both figures dir and the natural_mortality_figure.rda file exist - check_and_remove_tmp_files("natural_mortality_figure.rda") -}) +# # expect that both figures dir and the natural_mortality_figure.rda file exist +# check_and_remove_tmp_files("natural_mortality_figure.rda") +# }) diff --git a/tests/testthat/test-plot_recruitment.R b/tests/testthat/test-plot_recruitment.R index d6d1dd08..03764914 100644 --- a/tests/testthat/test-plot_recruitment.R +++ b/tests/testthat/test-plot_recruitment.R @@ -53,16 +53,16 @@ test_that("plot_recruitment generates plots without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - plot_recruitment( - stockplotr::example_data, - module = "TIME_SERIES", - interactive = FALSE, - figures_dir = getwd(), - make_rda = TRUE - ) +# test_that("rda file made when indicated", { +# # export rda +# plot_recruitment( +# stockplotr::example_data, +# module = "TIME_SERIES", +# interactive = FALSE, +# figures_dir = getwd(), +# make_rda = TRUE +# ) - # expect that both figures dir and the recruitment_figure.rda file exist - check_and_remove_tmp_files("recruitment_figure.rda") -}) +# # expect that both figures dir and the recruitment_figure.rda file exist +# check_and_remove_tmp_files("recruitment_figure.rda") +# }) diff --git a/tests/testthat/test-plot_recruitment_deviations.R b/tests/testthat/test-plot_recruitment_deviations.R index 69126810..491ca4b5 100644 --- a/tests/testthat/test-plot_recruitment_deviations.R +++ b/tests/testthat/test-plot_recruitment_deviations.R @@ -32,16 +32,16 @@ test_that("plot_recruitment_deviations generates plots without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - plot_recruitment_deviations( - stockplotr::example_data, - module = "SPAWN_RECRUIT", - interactive = FALSE, - make_rda = TRUE, - figures_dir = getwd() - ) +# test_that("rda file made when indicated", { +# # export rda +# plot_recruitment_deviations( +# stockplotr::example_data, +# module = "SPAWN_RECRUIT", +# interactive = FALSE, +# make_rda = TRUE, +# figures_dir = getwd() +# ) - # expect that both figures dir and the recruitment_deviations_figure.rda file exist - check_and_remove_tmp_files("recruitment_deviations_figure.rda") -}) +# # expect that both figures dir and the recruitment_deviations_figure.rda file exist +# check_and_remove_tmp_files("recruitment_deviations_figure.rda") +# }) diff --git a/tests/testthat/test-plot_selectivity.R b/tests/testthat/test-plot_selectivity.R index ed097ffd..8244c10d 100644 --- a/tests/testthat/test-plot_selectivity.R +++ b/tests/testthat/test-plot_selectivity.R @@ -45,16 +45,16 @@ test_that("plot_selectivity generates plots without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - plot_selectivity( - stockplotr::example_data, - module = "AGE_SELEX", - interactive = FALSE, - figures_dir = getwd(), - make_rda = TRUE - ) +# test_that("rda file made when indicated", { +# # export rda +# plot_selectivity( +# stockplotr::example_data, +# module = "AGE_SELEX", +# interactive = FALSE, +# figures_dir = getwd(), +# make_rda = TRUE +# ) - # expect that both figures dir and the selectivity_figure.rda file exist - check_and_remove_tmp_files("selectivity_figure.rda") -}) +# # expect that both figures dir and the selectivity_figure.rda file exist +# check_and_remove_tmp_files("selectivity_figure.rda") +# }) diff --git a/tests/testthat/test-plot_spawning_biomass.R b/tests/testthat/test-plot_spawning_biomass.R index 40cc4521..dea24c82 100644 --- a/tests/testthat/test-plot_spawning_biomass.R +++ b/tests/testthat/test-plot_spawning_biomass.R @@ -40,19 +40,19 @@ test_that("plot_spawning_biomass generates plots without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - plot_spawning_biomass( - stockplotr::example_data, - unit_label = "metric tons", - scale_amount = 1, - ref_line = "msy", - module = "TIME_SERIES", - interactive = FALSE, - make_rda = TRUE, - figures_dir = getwd() - ) +# test_that("rda file made when indicated", { +# # export rda +# plot_spawning_biomass( +# stockplotr::example_data, +# unit_label = "metric tons", +# scale_amount = 1, +# ref_line = "msy", +# module = "TIME_SERIES", +# interactive = FALSE, +# make_rda = TRUE, +# figures_dir = getwd() +# ) - # expect that both figures dir and the spawning_biomass_figure.rda file exist - check_and_remove_tmp_files("spawning_biomass_figure.rda") -}) +# # expect that both figures dir and the spawning_biomass_figure.rda file exist +# check_and_remove_tmp_files("spawning_biomass_figure.rda") +# }) diff --git a/tests/testthat/test-plot_stock_recruitment.R b/tests/testthat/test-plot_stock_recruitment.R index 64288b80..b918730f 100644 --- a/tests/testthat/test-plot_stock_recruitment.R +++ b/tests/testthat/test-plot_stock_recruitment.R @@ -34,17 +34,17 @@ test_that("plot_stock_recruitment generates plots without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - plot_stock_recruitment( - stockplotr::example_data, - spawning_biomass_label = "mt", - recruitment_label = "mt", - interactive = FALSE, - make_rda = TRUE, - figures_dir = getwd() - ) +# test_that("rda file made when indicated", { +# # export rda +# plot_stock_recruitment( +# stockplotr::example_data, +# spawning_biomass_label = "mt", +# recruitment_label = "mt", +# interactive = FALSE, +# make_rda = TRUE, +# figures_dir = getwd() +# ) - # expect that both figures dir and the sr_figure.rda file exist - check_and_remove_tmp_files("stock_recruitment_figure.rda") -}) +# # expect that both figures dir and the sr_figure.rda file exist +# check_and_remove_tmp_files("stock_recruitment_figure.rda") +# }) diff --git a/tests/testthat/test-table_biomass_abundance_catch.R b/tests/testthat/test-table_biomass_abundance_catch.R index 6f753ac0..d4a5b1e0 100644 --- a/tests/testthat/test-table_biomass_abundance_catch.R +++ b/tests/testthat/test-table_biomass_abundance_catch.R @@ -33,19 +33,19 @@ test_that("table_biomass_abundance_catch generates plots without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - table_biomass_abundance_catch( - dat = stockplotr::example_data, - module = c("TIME_SERIES", "CATCH", "TIME_SERIES"), - interactive = FALSE, - make_rda = TRUE, - tables_dir = getwd() - ) +# test_that("rda file made when indicated", { +# # export rda +# table_biomass_abundance_catch( +# dat = stockplotr::example_data, +# module = c("TIME_SERIES", "CATCH", "TIME_SERIES"), +# interactive = FALSE, +# make_rda = TRUE, +# tables_dir = getwd() +# ) - # expect that both tables dir and the biomass_abundance_catch_table.rda file exist - check_and_remove_tmp_files("biomass_abundance_catch_table.rda", figs_or_tables="tables") -}) +# # expect that both tables dir and the biomass_abundance_catch_table.rda file exist +# check_and_remove_tmp_files("biomass_abundance_catch_table.rda", figs_or_tables="tables") +# }) test_that("table_biomass_abundance_catch generates error with incorrect module", { # expect error diff --git a/tests/testthat/test-table_index.R b/tests/testthat/test-table_index.R index 4946f025..9fa9563e 100644 --- a/tests/testthat/test-table_index.R +++ b/tests/testthat/test-table_index.R @@ -33,30 +33,30 @@ test_that("table_index generates plots without errors", { # ) }) -test_that("rda file made when indicated", { - # export rda - table_index( - dat = stockplotr::example_data, - interactive = FALSE, - make_rda = TRUE, - tables_dir = getwd() - ) +# test_that("rda file made when indicated", { +# # export rda +# table_index( +# dat = stockplotr::example_data, +# interactive = FALSE, +# make_rda = TRUE, +# tables_dir = getwd() +# ) - # load the rda file and check that it contains the expected object - load(fs::path(getwd(), "tables", "index_table.rda")) - # expect rda contains three objects: table, caption, and latex table - expect_false( - is.null(rda$table) - ) - expect_false( - is.null(rda$caption) - ) - expect_false( - is.null(rda$latex_table) - ) +# # load the rda file and check that it contains the expected object +# load(fs::path(getwd(), "tables", "index_table.rda")) +# # expect rda contains three objects: table, caption, and latex table +# expect_false( +# is.null(rda$table) +# ) +# expect_false( +# is.null(rda$caption) +# ) +# expect_false( +# is.null(rda$latex_table) +# ) - expect_true(rda$caption == "Calculated index of abundance and corresponding CVs for the fleets and surveys identified in the column headers. ") +# expect_true(rda$caption == "Calculated index of abundance and corresponding CVs for the fleets and surveys identified in the column headers. ") - # erase temporary testing files - check_and_remove_tmp_files("index_table.rda", figs_or_tables="tables") -}) +# # erase temporary testing files +# check_and_remove_tmp_files("index_table.rda", figs_or_tables="tables") +# }) diff --git a/tests/testthat/test-table_landings.R b/tests/testthat/test-table_landings.R index 236f4c37..1bc7df84 100644 --- a/tests/testthat/test-table_landings.R +++ b/tests/testthat/test-table_landings.R @@ -37,27 +37,27 @@ test_that("table_landings generates plots without errors", { # ) }) -test_that("rda file made when indicated", { - # export rda - table_landings( - dat = stockplotr::example_data, - unit_label = "mt", - era = NULL, - interactive = FALSE, - module = "CATCH", - make_rda = TRUE, - tables_dir = getwd() - ) +# test_that("rda file made when indicated", { +# # export rda +# table_landings( +# dat = stockplotr::example_data, +# unit_label = "mt", +# era = NULL, +# interactive = FALSE, +# module = "CATCH", +# make_rda = TRUE, +# tables_dir = getwd() +# ) - # expect that both tables dir and the landings_table.rda file exist - expect_true(dir.exists(fs::path(getwd(), "tables"))) - expect_true(file.exists(fs::path(getwd(), "tables", "landings_table.rda"))) +# # expect that both tables dir and the landings_table.rda file exist +# expect_true(dir.exists(fs::path(getwd(), "tables"))) +# expect_true(file.exists(fs::path(getwd(), "tables", "landings_table.rda"))) - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "tables"), recursive = T) -}) +# # erase temporary testing files +# file.remove(fs::path(getwd(), "captions_alt_text.csv")) +# file.remove(fs::path(getwd(), "key_quantities.csv")) +# unlink(fs::path(getwd(), "tables"), recursive = T) +# }) test_that("table_landings generates error with incorrect module", { # expect error diff --git a/tests/testthat/test-table_projections.R b/tests/testthat/test-table_projections.R index 58ad4f1f..316661cc 100644 --- a/tests/testthat/test-table_projections.R +++ b/tests/testthat/test-table_projections.R @@ -18,18 +18,18 @@ test_that("table_projections generates plots without errors", { ) }) -test_that("rda file made when indicated", { - # export rda - table_projections( - dat = stockplotr::example_data, - interactive = FALSE, - make_rda = TRUE, - tables_dir = getwd() - ) +# test_that("rda file made when indicated", { +# # export rda +# table_projections( +# dat = stockplotr::example_data, +# interactive = FALSE, +# make_rda = TRUE, +# tables_dir = getwd() +# ) - # expect that both tables dir and the projections_table.rda file exist - check_and_remove_tmp_files("projections_table.rda", figs_or_tables="tables") -}) +# # expect that both tables dir and the projections_table.rda file exist +# check_and_remove_tmp_files("projections_table.rda", figs_or_tables="tables") +# }) test_that("table_projections generates error with incorrect module", { # expect error From d74aa43b7f2a11959a01c767acb69f676bd5c010 Mon Sep 17 00:00:00 2001 From: Joshua Zahner Date: Fri, 16 Oct 2026 12:34:50 -0400 Subject: [PATCH 8/9] test: :zap: removed redundant "make rda" tests for select tables --- tests/testthat/test-table_landings.R | 48 +++++++------- tests/testthat/test-table_total_catch.R | 88 ++++++++++++------------- 2 files changed, 68 insertions(+), 68 deletions(-) diff --git a/tests/testthat/test-table_landings.R b/tests/testthat/test-table_landings.R index 1bc7df84..04f37761 100644 --- a/tests/testthat/test-table_landings.R +++ b/tests/testthat/test-table_landings.R @@ -76,30 +76,30 @@ test_that("table_landings generates error with incorrect module", { }) -test_that("rda file made when indicated", { - # export rda - table_landings( - dat = stockplotr::example_data, - interactive = FALSE, - make_rda = TRUE, - tables_dir = getwd() - ) +# test_that("rda file made when indicated", { +# # export rda +# table_landings( +# dat = stockplotr::example_data, +# interactive = FALSE, +# make_rda = TRUE, +# tables_dir = getwd() +# ) - # load the rda file and check that it contains the expected object - load(fs::path(getwd(), "tables", "landings_table.rda")) - # expect rda contains three objects: table, caption, and latex table - expect_false( - is.null(rda$table) - ) - expect_false( - is.null(rda$caption) - ) - expect_false( - is.null(rda$latex_table) - ) +# # load the rda file and check that it contains the expected object +# load(fs::path(getwd(), "tables", "landings_table.rda")) +# # expect rda contains three objects: table, caption, and latex table +# expect_false( +# is.null(rda$table) +# ) +# expect_false( +# is.null(rda$caption) +# ) +# expect_false( +# is.null(rda$latex_table) +# ) - expect_true(rda$caption == "Landed catch by fleet and year in (mt).") +# expect_true(rda$caption == "Landed catch by fleet and year in (mt).") - # erase temporary testing files - check_and_remove_tmp_files("landings_table.rda", figs_or_tables="tables") -}) +# # erase temporary testing files +# check_and_remove_tmp_files("landings_table.rda", figs_or_tables="tables") +# }) diff --git a/tests/testthat/test-table_total_catch.R b/tests/testthat/test-table_total_catch.R index 8af7899d..dfb9f8be 100644 --- a/tests/testthat/test-table_total_catch.R +++ b/tests/testthat/test-table_total_catch.R @@ -37,27 +37,27 @@ test_that("table_total_catch generates plots without errors", { # ) }) -test_that("rda file made when indicated", { - # export rda - table_total_catch( - dat = stockplotr::example_data, - unit_label = "mt", - era = NULL, - interactive = FALSE, - module = "TIME_SERIES", - make_rda = TRUE, - tables_dir = getwd() - ) +# test_that("rda file made when indicated", { +# # export rda +# table_total_catch( +# dat = stockplotr::example_data, +# unit_label = "mt", +# era = NULL, +# interactive = FALSE, +# module = "TIME_SERIES", +# make_rda = TRUE, +# tables_dir = getwd() +# ) - # expect that both tables dir and the total_catch_table.rda file exist - expect_true(dir.exists(fs::path(getwd(), "tables"))) - expect_true(file.exists(fs::path(getwd(), "tables", "total_catch_table.rda"))) +# # expect that both tables dir and the total_catch_table.rda file exist +# expect_true(dir.exists(fs::path(getwd(), "tables"))) +# expect_true(file.exists(fs::path(getwd(), "tables", "total_catch_table.rda"))) - # erase temporary testing files - file.remove(fs::path(getwd(), "captions_alt_text.csv")) - file.remove(fs::path(getwd(), "key_quantities.csv")) - unlink(fs::path(getwd(), "tables"), recursive = T) -}) +# # erase temporary testing files +# file.remove(fs::path(getwd(), "captions_alt_text.csv")) +# file.remove(fs::path(getwd(), "key_quantities.csv")) +# unlink(fs::path(getwd(), "tables"), recursive = T) +# }) test_that("table_total_catch generates error with incorrect module", { # expect error @@ -76,31 +76,31 @@ test_that("table_total_catch generates error with incorrect module", { }) -test_that("rda file made when indicated", { - # export rda - table_total_catch( - dat = stockplotr::example_data, - module = "TIME_SERIES", - interactive = FALSE, - make_rda = TRUE, - tables_dir = getwd() - ) +# test_that("rda file made when indicated", { +# # export rda +# table_total_catch( +# dat = stockplotr::example_data, +# module = "TIME_SERIES", +# interactive = FALSE, +# make_rda = TRUE, +# tables_dir = getwd() +# ) - # load the rda file and check that it contains the expected object - load(fs::path(getwd(), "tables", "total_catch_table.rda")) - # expect rda contains three objects: table, caption, and latex table - expect_false( - is.null(rda$table) - ) - expect_false( - is.null(rda$caption) - ) - expect_false( - is.null(rda$latex_table) - ) +# # load the rda file and check that it contains the expected object +# load(fs::path(getwd(), "tables", "total_catch_table.rda")) +# # expect rda contains three objects: table, caption, and latex table +# expect_false( +# is.null(rda$table) +# ) +# expect_false( +# is.null(rda$caption) +# ) +# expect_false( +# is.null(rda$latex_table) +# ) - expect_true(rda$caption == "Total catch by fleet over time.") +# expect_true(rda$caption == "Total catch by fleet over time.") - # erase temporary testing files - check_and_remove_tmp_files("total_catch_table.rda", figs_or_tables="tables") -}) +# # erase temporary testing files +# check_and_remove_tmp_files("total_catch_table.rda", figs_or_tables="tables") +# }) From 5568d3fb3b2051fcf3bc3abab76f8e3c28452283 Mon Sep 17 00:00:00 2001 From: Joshua Zahner Date: Fri, 16 Oct 2026 12:35:54 -0400 Subject: [PATCH 9/9] chore: :zap: added support for parallel testthat save_all_plots and convert_output tests will run first, followed by the individual plotting and table function tests --- DESCRIPTION | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0b38cf27..6c7db50c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -63,7 +63,8 @@ VignetteBuilder: knitr Config/roxygen2/version: 8.1.0 Config/testthat/edition: 3 -Config/testthat/parallel: false +Config/testthat/parallel: true +Config/testthat/start-first: save_all_plots*, convert_output* Encoding: UTF-8 Language: en-US LazyData: true