From 579441d291bcc1e1cd06b00128df14f70bc7e474 Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Fri, 25 Oct 2024 13:19:56 +0200 Subject: [PATCH 1/3] Use Setup file to handle logger setup/teardown --- tests/testthat/setup.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/testthat/setup.R diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R new file mode 100644 index 0000000..00770a9 --- /dev/null +++ b/tests/testthat/setup.R @@ -0,0 +1,13 @@ +## save current settings so that we can reset later + +## Logger Settings +# Set threshold to OFF, and capture previous state +logger_threshold <- logger::log_threshold("OFF") + +## Tear down function +withr::defer( + expr = { + logger::log_threshold(logger_threshold) + }, + envir = teardown_env() +) From f155565a3e166873019c4572948f592f0fb47dab Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Fri, 25 Oct 2024 13:20:30 +0200 Subject: [PATCH 2/3] Remove logger setup/teardown in individual files --- tests/testthat/test-analysis_prechecks.R | 15 --------------- tests/testthat/test-audit_prechecks.R | 15 --------------- tests/testthat/test-calc_weights_prechecks.R | 15 --------------- 3 files changed, 45 deletions(-) diff --git a/tests/testthat/test-analysis_prechecks.R b/tests/testthat/test-analysis_prechecks.R index 0fd5b90..150afd5 100644 --- a/tests/testthat/test-analysis_prechecks.R +++ b/tests/testthat/test-analysis_prechecks.R @@ -1,18 +1,3 @@ -## save current settings so that we can reset later -threshold <- logger::log_threshold() -appender <- logger::log_appender() -layout <- logger::log_layout() -on.exit({ - ## reset logger settings - logger::log_threshold(threshold) - logger::log_layout(layout) - logger::log_appender(appender) -}) - -logger::log_appender(logger::appender_stdout) -logger::log_threshold(logger::FATAL) -logger::log_layout(logger::layout_simple) - test_that("audit_prechecks works when all files are present", { pacta_data_dir <- withr::local_tempdir() filenames <- c( diff --git a/tests/testthat/test-audit_prechecks.R b/tests/testthat/test-audit_prechecks.R index 500b43e..60f2054 100644 --- a/tests/testthat/test-audit_prechecks.R +++ b/tests/testthat/test-audit_prechecks.R @@ -1,18 +1,3 @@ -## save current settings so that we can reset later -threshold <- logger::log_threshold() -appender <- logger::log_appender() -layout <- logger::log_layout() -on.exit({ - ## reset logger settings - logger::log_threshold(threshold) - logger::log_layout(layout) - logger::log_appender(appender) -}) - -logger::log_appender(logger::appender_stdout) -logger::log_threshold(logger::FATAL) -logger::log_layout(logger::layout_simple) - test_that("audit_prechecks works when all files are present", { pacta_data_dir <- withr::local_tempdir() filenames <- c( diff --git a/tests/testthat/test-calc_weights_prechecks.R b/tests/testthat/test-calc_weights_prechecks.R index 1e3ba9e..e224ce3 100644 --- a/tests/testthat/test-calc_weights_prechecks.R +++ b/tests/testthat/test-calc_weights_prechecks.R @@ -1,18 +1,3 @@ -## save current settings so that we can reset later -threshold <- logger::log_threshold() -appender <- logger::log_appender() -layout <- logger::log_layout() -on.exit({ - ## reset logger settings - logger::log_threshold(threshold) - logger::log_layout(layout) - logger::log_appender(appender) -}) - -logger::log_appender(logger::appender_stdout) -logger::log_threshold(logger::FATAL) -logger::log_layout(logger::layout_simple) - test_that("audit_prechecks works when all files are present", { data_dir <- withr::local_tempdir() filenames <- c( From 5087f8d837336e9b8eeb6191f447b1ea6467e55e Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Fri, 25 Oct 2024 13:22:43 +0200 Subject: [PATCH 3/3] Increment version number to 0.0.0.9012 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0a3607c..7a5e100 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: workflow.pacta Title: Run PACTA -Version: 0.0.0.9011 +Version: 0.0.0.9012 Authors@R: c(person(given = "CJ", family = "Yetman",