11test_that(" options quarto.log.debug and env var R_QUARTO_LOG_DEBUG" , {
22 # clean state
3- withr :: local_options(quarto.log.debug = NULL )
4- withr :: local_envvar(R_QUARTO_LOG_DEBUG = NA )
3+ local_clean_state()
54 expect_false(is_quarto_r_debug())
65 withr :: with_envvar(list (R_QUARTO_LOG_DEBUG = TRUE ), {
76 expect_true(is_quarto_r_debug())
@@ -23,7 +22,7 @@ test_that("options quarto.log.debug and env var R_QUARTO_LOG_DEBUG", {
2322})
2423
2524test_that(" quarto_log_level respects Quarto env var" , {
26- withr :: local_envvar( QUARTO_LOG_LEVEL = NA )
25+ local_clean_state( )
2726 expect_true(is.na(quarto_log_level()))
2827 expect_false(quarto_log_level(" DEBUG" ))
2928 withr :: with_envvar(list (QUARTO_LOG_LEVEL = " DEBUG" ), {
@@ -44,7 +43,7 @@ test_that("quarto_log_level respects Quarto env var", {
4443})
4544
4645test_that(" in_debug_mode respects GHA CI env var" , {
47- withr :: local_envvar( ACTIONS_RUNNER_DEBUG = NA , ACTIONS_STEP_DEBUG = NA )
46+ local_clean_state( )
4847 expect_false(in_debug_mode())
4948
5049 withr :: with_envvar(list (ACTIONS_RUNNER_DEBUG = " true" ), {
@@ -65,8 +64,7 @@ test_that("in_debug_mode respects GHA CI env var", {
6564
6665test_that(" in_debug mode respects quarto_log_level" , {
6766 # clean state
68- withr :: local_envvar(ACTIONS_RUNNER_DEBUG = NA , ACTIONS_STEP_DEBUG = NA )
69- withr :: local_envvar(QUARTO_LOG_LEVEL = NA )
67+ local_clean_state()
7068 expect_false(in_debug_mode())
7169
7270 withr :: with_envvar(list (QUARTO_LOG_LEVEL = " DEBUG" ), {
@@ -84,10 +82,7 @@ test_that("in_debug mode respects quarto_log_level", {
8482
8583test_that(" in_debug_mode respects R_QUARTO_LOG_DEBUG and quarto.log.debug" , {
8684 # clean state
87- withr :: local_envvar(ACTIONS_RUNNER_DEBUG = NA , ACTIONS_STEP_DEBUG = NA )
88- withr :: local_envvar(QUARTO_LOG_LEVEL = NA )
89- withr :: local_envvar(R_QUARTO_LOG_DEBUG = NA )
90- withr :: local_options(quarto.log.debug = NULL )
85+ local_clean_state()
9186 expect_false(in_debug_mode())
9287
9388 withr :: with_envvar(list (R_QUARTO_LOG_DEBUG = TRUE ), {
@@ -112,14 +107,9 @@ test_that("in_debug_mode respects R_QUARTO_LOG_DEBUG and quarto.log.debug", {
112107})
113108
114109test_that(" quarto_log only logs when in debug mode" , {
115- temp_file <- tempfile(fileext = " .log" )
116- on.exit(unlink(temp_file ))
110+ temp_file <- withr :: local_tempfile(fileext = " .log" )
117111
118- # Test with debug mode off
119- withr :: local_envvar(ACTIONS_RUNNER_DEBUG = NA , ACTIONS_STEP_DEBUG = NA )
120- withr :: local_envvar(QUARTO_LOG_LEVEL = NA )
121- withr :: local_envvar(R_QUARTO_LOG_DEBUG = NA )
122- withr :: local_options(quarto.log.debug = NULL )
112+ local_clean_state()
123113
124114 result <- quarto_log(" test message" , file = temp_file )
125115 expect_false(result )
@@ -141,10 +131,10 @@ test_that("quarto_log only logs when in debug mode", {
141131})
142132
143133test_that(" quarto_log respects log file configuration" , {
144- temp_file <- tempfile(fileext = " .log" )
145- on.exit(unlink(temp_file ))
134+ temp_file <- withr :: local_tempfile(fileext = " .log" )
135+
136+ local_clean_state()
146137
147- # Enable debug mode
148138 withr :: local_options(quarto.log.debug = TRUE )
149139
150140 # Test with file parameter
@@ -169,13 +159,16 @@ test_that("quarto_log respects log file configuration", {
169159 })
170160
171161 # Test with no file configured
162+ unlink(temp_file )
172163 result <- quarto_log(" no file configured" )
173164 expect_false(result )
165+ expect_false(file.exists(temp_file ))
174166})
175167
176168test_that(" quarto_log handles custom formatting" , {
177- temp_file <- tempfile(fileext = " .log" )
178- on.exit(unlink(temp_file ))
169+ temp_file <- withr :: local_tempfile(fileext = " .log" )
170+
171+ local_clean_state()
179172
180173 withr :: local_options(quarto.log.debug = TRUE )
181174
0 commit comments