From 7fb10876041840284b2e906d785918e8181cff53 Mon Sep 17 00:00:00 2001
From: tonyk7440 <tonyk7440@gmail.com>
Date: Sun, 6 Nov 2022 19:23:43 +0000
Subject: [PATCH] #1746 better cleanup, use file_path better

---
 tests/testthat/test-lint_package.R | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tests/testthat/test-lint_package.R b/tests/testthat/test-lint_package.R
index 3003bb55f..f5b16b2f5 100644
--- a/tests/testthat/test-lint_package.R
+++ b/tests/testthat/test-lint_package.R
@@ -140,21 +140,22 @@ test_that(
 
     pkg_path <- test_path("dummy_packages", "github_lintr_file")
 
+    # In `github/linters`add a `.lintr` file that excludes the whole of `abc.R`
+    # and the first line of `jkl.R` (and remove it on finishing this test)
     dir.create(
-      path = file.path(pkg_path, ".github/linters/"),
+      path = file.path(pkg_path, ".github", "linters/"),
       recursive = TRUE
     )
 
-    # In `github/linters`add a `.lintr` file that excludes the whole of `abc.R`
-    # and the first line of `jkl.R` (and remove it on finishing this test)
-    local_config(file.path(pkg_path, ".github/linters"), "exclusions: list('R/abc.R', 'R/jkl.R' = 1)")
+    local_config(file.path(pkg_path, ".github", "linters"), "exclusions: list('R/abc.R', 'R/jkl.R' = 1)")
 
     lints_using_github_lintr <- withr::with_dir(
       pkg_path,
       lint_package(".", linters = list(assignment_linter()))
     )
 
-    file.remove(paste0(pkg_path, "/.github/linters/.lintr"))
+    # Cleanup directory and files created above
+    unlink(file.path(pkg_path, ".github"), recursive = TRUE)
 
     # Now add the same file to the package root
     local_config(pkg_path, "exclusions: list('R/abc.R', 'R/jkl.R' = 1)")