diff --git a/tests/testthat/test-global_roclet.R b/tests/testthat/test-global_roclet.R index fef9e51..a4429d7 100644 --- a/tests/testthat/test-global_roclet.R +++ b/tests/testthat/test-global_roclet.R @@ -75,7 +75,6 @@ test_that("global_roclet() writes unique globals", { test_that("global_roclet() writes to custom filename", { pkg_path <- local_package_copy(test_path("./config-filename")) globals_file <- file.path(pkg_path, "R", "generated-globals.R") - on.exit(unlink(globals_file)) suppressMessages(roxygen2::roxygenise(pkg_path)) @@ -94,3 +93,21 @@ test_that("global_roclet() writes to custom filename", { ) ) }) + +test_that("global_roclet() cleans globals file", { + pkg_path <- local_package_copy(test_path("./empty")) + globals_file <- file.path(pkg_path, "R", "globals.R") + + roxygen2::roclet_clean(global_roclet(), pkg_path) + expect_false( + file.exists(globals_file) + ) + + # ensure file exists + suppressMessages(roxygen2::roxygenise(pkg_path, clean = TRUE)) + + roxygen2::roclet_clean(global_roclet(), pkg_path) + expect_false( + file.exists(globals_file) + ) +})