Skip to content

Commit 3e86b45

Browse files
committed
Add test for OS config dir support
1 parent 23ef58d commit 3e86b45

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/testthat/test-settings.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,23 @@ test_that("it uses config home directory settings if provided", {
4343
expect_identical(settings$exclude, "test")
4444
})
4545

46+
test_that("it uses system config directory settings if provided", {
47+
path <- withr::local_tempdir()
48+
config_parent_path <- withr::local_tempdir("config")
49+
config_path <- file.path(config_parent_path, "R", "lintr")
50+
dir.create(config_path, recursive = TRUE)
51+
file <- withr::local_tempfile(tmpdir = path)
52+
local_config(config_path, 'exclude: "test"', filename = "config")
53+
54+
withr::with_envvar(c(R_USER_CONFIG_DIR = config_parent_path), lintr:::read_settings(file))
55+
56+
lapply(setdiff(ls(settings), "exclude"), function(setting) {
57+
expect_identical(settings[[setting]], default_settings[[setting]])
58+
})
59+
60+
expect_identical(settings$exclude, "test")
61+
})
62+
4663
test_that("it errors if the config file does not end in a newline", {
4764
f <- withr::local_tempfile()
4865
cat("linters: linters_with_defaults(closed_curly_linter = NULL)", file = f)

0 commit comments

Comments
 (0)