From 139a6305116693268c322593989eb210b8eb34fb Mon Sep 17 00:00:00 2001 From: parmsam-pfizer Date: Wed, 25 Feb 2026 19:17:08 +0000 Subject: [PATCH 01/10] Add `visible = TRUE` to `purrr::safely()` call for `run_safely` --- R/zzz.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/zzz.R b/R/zzz.R index 1d10fdda..9086f758 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -17,7 +17,7 @@ logrx_default_options <- list( # This overwrite is to correctly build purrr adverb function # outlined in purrr best practices for exporting adverb-wrapped functions - run_safely <<- purrr::safely(run_file, quiet = FALSE) + run_safely <<- purrr::safely(run_file, quiet = FALSE, visible = TRUE) # set warn to 1 to have warnings be output as they happen options(warn = 1) From b952e70ef9147c937dbc27b6566080449202ed83 Mon Sep 17 00:00:00 2001 From: parmsam-pfizer Date: Wed, 25 Feb 2026 19:38:20 +0000 Subject: [PATCH 02/10] Remove `visible` argument from `purrr::safely()` call in `.onLoad` --- R/zzz.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/zzz.R b/R/zzz.R index 9086f758..1d10fdda 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -17,7 +17,7 @@ logrx_default_options <- list( # This overwrite is to correctly build purrr adverb function # outlined in purrr best practices for exporting adverb-wrapped functions - run_safely <<- purrr::safely(run_file, quiet = FALSE, visible = TRUE) + run_safely <<- purrr::safely(run_file, quiet = FALSE) # set warn to 1 to have warnings be output as they happen options(warn = 1) From ca74fb7938574b3aff2feda42fc48df2590ecc7f Mon Sep 17 00:00:00 2001 From: parmsam-pfizer Date: Wed, 4 Mar 2026 16:47:56 +0000 Subject: [PATCH 03/10] Add tests for invisible returned objects --- tests/testthat/ref/invisible_returned_obj.R | 4 +++ tests/testthat/test-invisible.R | 33 +++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/testthat/ref/invisible_returned_obj.R create mode 100644 tests/testthat/test-invisible.R diff --git a/tests/testthat/ref/invisible_returned_obj.R b/tests/testthat/ref/invisible_returned_obj.R new file mode 100644 index 00000000..3cefca68 --- /dev/null +++ b/tests/testthat/ref/invisible_returned_obj.R @@ -0,0 +1,4 @@ +my_fun <- function(x){ + return(invisible(x)) +} +my_fun("do not print this") \ No newline at end of file diff --git a/tests/testthat/test-invisible.R b/tests/testthat/test-invisible.R new file mode 100644 index 00000000..2713c53d --- /dev/null +++ b/tests/testthat/test-invisible.R @@ -0,0 +1,33 @@ +test_that("invisibly returned results are not written to the log", { + options("log.rx" = NULL) + scriptPath <- test_path("ref", "invisible_returned_obj.R") + logDir <- tempdir() + + axecute(scriptPath, log_name = "log_invisible", log_path = logDir) + + con <- file(file.path(logDir, "log_invisible"), "r") + flines <- readLines(con) + close(con) + + expect_false(any(grepl("do not print this", flines))) + + rm(flines, con, logDir) + log_remove() +}) + +test_that("visibly returned results are written to the log", { + options("log.rx" = NULL) + scriptPath <- test_path("ref", "safely_loudly_test_file_result.R") + logDir <- tempdir() + + axecute(scriptPath, log_name = "log_visible", log_path = logDir) + + con <- file(file.path(logDir, "log_visible"), "r") + flines <- readLines(con) + close(con) + + expect_true(any(grepl("8, 6, 7, 5, 3, 0, 9|test", flines))) + + rm(flines, con, logDir) + log_remove() +}) From 8d95077feb002c83da041e8ae06bf8f30190e516 Mon Sep 17 00:00:00 2001 From: parmsam-pfizer Date: Wed, 4 Mar 2026 20:28:23 +0000 Subject: [PATCH 04/10] Suppress invisible results in write_result for non-Rmarkdown files --- R/writer.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/writer.R b/R/writer.R index 6f94b114..a22768d4 100644 --- a/R/writer.R +++ b/R/writer.R @@ -313,8 +313,10 @@ write_result <- function(file) { if (is_rmarkdown(file)) { c("\nResult:", paste0("\t", capture.output(result))) - } else { + } else if (isTRUE(result$visible)) { c("\nResult:", paste0("\t", capture.output(result$value))) + } else { + character(0) } } From 95088ba198e63d3a0e47eb75af0d88301c31b1a8 Mon Sep 17 00:00:00 2001 From: parmsam-pfizer Date: Wed, 4 Mar 2026 20:36:52 +0000 Subject: [PATCH 05/10] Add test for invisibly returned results in Rmd files not being written to the log --- tests/testthat/ref/invisible_returned_obj.Rmd | 11 +++++++++++ tests/testthat/test-invisible.R | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/testthat/ref/invisible_returned_obj.Rmd diff --git a/tests/testthat/ref/invisible_returned_obj.Rmd b/tests/testthat/ref/invisible_returned_obj.Rmd new file mode 100644 index 00000000..ca5c0949 --- /dev/null +++ b/tests/testthat/ref/invisible_returned_obj.Rmd @@ -0,0 +1,11 @@ +--- +title: "invisible_returned_obj" +output: html_document +--- + +```{r} +my_fun <- function(x){ + return(invisible(x)) +} +my_fun("do not print this") +``` diff --git a/tests/testthat/test-invisible.R b/tests/testthat/test-invisible.R index 2713c53d..8e76a404 100644 --- a/tests/testthat/test-invisible.R +++ b/tests/testthat/test-invisible.R @@ -15,6 +15,23 @@ test_that("invisibly returned results are not written to the log", { log_remove() }) +test_that("invisibly returned results in Rmd files are not written to the log", { + options("log.rx" = NULL) + scriptPath <- test_path("ref", "invisible_returned_obj.Rmd") + logDir <- tempdir() + + axecute(scriptPath, log_name = "log_invisible_rmd", log_path = logDir) + + con <- file(file.path(logDir, "log_invisible_rmd"), "r") + flines <- readLines(con) + close(con) + + expect_false(any(grepl("do not print this", flines))) + + rm(flines, con, logDir) + log_remove() +}) + test_that("visibly returned results are written to the log", { options("log.rx" = NULL) scriptPath <- test_path("ref", "safely_loudly_test_file_result.R") From ee228378b21646ef079ee9c86651360be62aa812 Mon Sep 17 00:00:00 2001 From: parmsam-pfizer Date: Wed, 4 Mar 2026 20:39:40 +0000 Subject: [PATCH 06/10] Invisibly returned objects are no longer captured in the "Result" section of the log (#275) --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 32cdb556..9ef64fd7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ ## Updates +- Invisibly returned objects are no longer captured in the "Result" section of the log (#275) + - Removed .dcf file for old Addin (#280) ## Documentation From 3921c71151176c6af758aba4ceec92a111636770 Mon Sep 17 00:00:00 2001 From: parmsam-pfizer Date: Wed, 4 Mar 2026 20:48:37 +0000 Subject: [PATCH 07/10] Fix code style: add space before opening brace in function definition and ensure trailing newline --- tests/testthat/ref/invisible_returned_obj.R | 4 ++-- tests/testthat/ref/invisible_returned_obj.Rmd | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/ref/invisible_returned_obj.R b/tests/testthat/ref/invisible_returned_obj.R index 3cefca68..bd0714e1 100644 --- a/tests/testthat/ref/invisible_returned_obj.R +++ b/tests/testthat/ref/invisible_returned_obj.R @@ -1,4 +1,4 @@ -my_fun <- function(x){ +my_fun <- function(x) { return(invisible(x)) } -my_fun("do not print this") \ No newline at end of file +my_fun("do not print this") diff --git a/tests/testthat/ref/invisible_returned_obj.Rmd b/tests/testthat/ref/invisible_returned_obj.Rmd index ca5c0949..ebafbb34 100644 --- a/tests/testthat/ref/invisible_returned_obj.Rmd +++ b/tests/testthat/ref/invisible_returned_obj.Rmd @@ -4,7 +4,7 @@ output: html_document --- ```{r} -my_fun <- function(x){ +my_fun <- function(x) { return(invisible(x)) } my_fun("do not print this") From 4fafaf4d3fc8f477354dea438049922cacf2ee97 Mon Sep 17 00:00:00 2001 From: parmsam-pfizer Date: Wed, 11 Mar 2026 17:31:34 +0000 Subject: [PATCH 08/10] Add test to ensure gt table HTML content is excluded from log output --- tests/testthat/ref/invisible_returned_gt.R | 4 ++++ tests/testthat/test-invisible.R | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/testthat/ref/invisible_returned_gt.R diff --git a/tests/testthat/ref/invisible_returned_gt.R b/tests/testthat/ref/invisible_returned_gt.R new file mode 100644 index 00000000..30a31d40 --- /dev/null +++ b/tests/testthat/ref/invisible_returned_gt.R @@ -0,0 +1,4 @@ +library(gt) + +gt_tbl <- gt(head(mtcars)) +gt_tbl diff --git a/tests/testthat/test-invisible.R b/tests/testthat/test-invisible.R index 8e76a404..a903cb1d 100644 --- a/tests/testthat/test-invisible.R +++ b/tests/testthat/test-invisible.R @@ -48,3 +48,20 @@ test_that("visibly returned results are written to the log", { rm(flines, con, logDir) log_remove() }) + +test_that("gt table HTML content is not written to the result portion of the log", { + options("log.rx" = NULL) + scriptPath <- test_path("ref", "invisible_returned_gt.R") + logDir <- tempdir() + + axecute(scriptPath, log_name = "log_gt", log_path = logDir) + + con <- file(file.path(logDir, "log_gt"), "r") + flines <- readLines(con) + close(con) + + expect_false(any(grepl(" Date: Wed, 11 Mar 2026 18:07:12 +0000 Subject: [PATCH 09/10] Add gt to Suggests in DESCRIPTION --- DESCRIPTION | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5fb05bb4..bc444832 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -68,7 +68,8 @@ Suggests: rstudioapi, tidyselect, renv, - yaml + yaml, + gt VignetteBuilder: knitr Config/testthat/edition: 3 Depends: From b45719ba05259676717c7b9bd7b7f46e12bcf053 Mon Sep 17 00:00:00 2001 From: Sam Parmar <107635309+parmsam-pfizer@users.noreply.github.com> Date: Fri, 13 Mar 2026 14:05:57 -0400 Subject: [PATCH 10/10] Use namespace for gt function in test --- tests/testthat/ref/invisible_returned_gt.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/ref/invisible_returned_gt.R b/tests/testthat/ref/invisible_returned_gt.R index 30a31d40..9ae88eea 100644 --- a/tests/testthat/ref/invisible_returned_gt.R +++ b/tests/testthat/ref/invisible_returned_gt.R @@ -1,4 +1,4 @@ library(gt) -gt_tbl <- gt(head(mtcars)) +gt_tbl <- gt::gt(head(mtcars)) gt_tbl