Skip to content

Commit d2bc824

Browse files
committed
clean .quarto files
1 parent b2297a6 commit d2bc824

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

tests/testthat/helpers.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,21 @@ local_clean_state <- function(env = parent.frame()) {
317317
)
318318
}
319319

320+
local_clean_dot_quarto <- function(where = ".", env = parent.frame()) {
321+
skip_if_not_installed("withr")
322+
skip_if_not_installed("fs")
323+
withr::defer(
324+
{
325+
# clean up internal .quarto directory
326+
dot_quarto <- fs::path(where, ".quarto")
327+
if (fs::dir_exists(dot_quarto)) {
328+
fs::dir_delete(dot_quarto)
329+
}
330+
},
331+
envir = env
332+
)
333+
}
334+
320335
resources_path <- function(...) {
321336
test_path("resources", ...)
322337
}

tests/testthat/test-inspect.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ test_that("Documents can be inspected", {
1010

1111
test_that("Quarto projects can be inspected", {
1212
skip_if_no_quarto()
13-
metadata <- quarto_inspect(test_path("project"))
13+
project_path <- test_path("project")
14+
local_clean_dot_quarto(project_path)
15+
metadata <- quarto_inspect(project_path)
1416
expect_type(metadata$config, "list")
1517
})
1618

1719
test_that("Quarto projects can be inspected with profile", {
1820
skip_if_no_quarto()
19-
metadata <- quarto_inspect(test_path("project"), "test")
21+
project_path <- test_path("project")
22+
local_clean_dot_quarto(project_path)
23+
metadata <- quarto_inspect(project_path, "test")
2024
expect_type(metadata$config, "list")
2125
expect_identical(metadata$config$execute$echo, TRUE)
2226
})

tests/testthat/test-theme.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,15 @@ resource_dir <- function(input) {
1818

1919
local_render_theme_file <- function(input, env = parent.frame()) {
2020
skip_if_not_installed("withr")
21+
skip_if_not_installed("fs")
22+
local_clean_dot_quarto(where = dirname(input), env = env)
2123
withr::defer(
2224
{
2325
# clean up output resource directory
2426
out_dir <- resource_dir(input)
2527
if (fs::dir_exists(out_dir)) {
2628
fs::dir_delete(out_dir)
2729
}
28-
# clean up internal .quarto directory
29-
if (fs::dir_exists(".quarto")) {
30-
fs::dir_delete(".quarto")
31-
}
3230
},
3331
envir = env
3432
)

0 commit comments

Comments
 (0)