From d872ff1d0e14d9a9b0d5203678c21e478f0625c1 Mon Sep 17 00:00:00 2001 From: Jakub Sobolewski Date: Wed, 22 May 2024 11:52:53 +0200 Subject: [PATCH] chore: remove Crashpad directory when checking the package --- DESCRIPTION | 4 +++- tests/testthat/setup-disable-crashpad.R | 30 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/testthat/setup-disable-crashpad.R diff --git a/DESCRIPTION b/DESCRIPTION index 19521dd..feff498 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,6 +30,7 @@ Imports: shiny.react (>= 0.4.0), utils Suggests: + chromote, covr, knitr, lintr (>= 3.0.0), @@ -38,5 +39,6 @@ Suggests: rmarkdown, shiny.router, shinytest2, - testthat (>= 3.0.0) + testthat (>= 3.0.0), + withr Config/testthat/edition: 3 diff --git a/tests/testthat/setup-disable-crashpad.R b/tests/testthat/setup-disable-crashpad.R new file mode 100644 index 0000000..73e56ee --- /dev/null +++ b/tests/testthat/setup-disable-crashpad.R @@ -0,0 +1,30 @@ +# ❯ checking for detritus in the temp directory ... NOTE +# Found the following files/directories: +# ‘Crashpad’ +# +# 0 errors ✔ | 0 warnings ✔ | 1 note ✖ +# Error: Error: R CMD check found NOTEs +# Flavors: ubuntu-22.04 (devel), ubuntu-22.04 (release), ubuntu-22.04 (oldrel) + +# References (shinytest2 github): +# 1. https://github.com/rstudio/shinytest2/blob/main/cran-comments.md +# 2. https://github.com/rstudio/shinytest2/blob/main/tests/testthat/setup-disable-crashpad.R + +# Disable crash reporting on CRAN machines. (Can't get the report anyways) +chromote::set_chrome_args(c( + # https://peter.sh/experiments/chromium-command-line-switches/#disable-crash-reporter + #> Disable crash reporter for headless. It is enabled by default in official builds + "--disable-crash-reporter", + chromote::default_chrome_args() +)) + +# Make sure the temp folder is removed when testing is complete +withr::defer({ + + # Clean up chromote sessions + gc() # Run R6 finalizer methods + Sys.sleep(2) # Wait for any supervisors to exit + + # Delete the Crashpad folder if it exists + unlink(file.path(tempdir(), "Crashpad"), recursive = TRUE) +}, envir = testthat::teardown_env())