From 9e3a23888b9032fc8d7d2ff8fad6ece699bea711 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 --- tests/testthat/setup-disable-crashpad.R | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/testthat/setup-disable-crashpad.R 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())