Skip to content

Commit

Permalink
try forcing matched .libPaths()?
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Dec 25, 2023
1 parent 508548b commit 05873e2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/testthat/test-lint_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,14 @@ test_that("package using .lintr.R config lints correctly", {
})

test_that("lintr need not be attached for .lintr.R configs to use lintr functions", {
lib_paths <- character()
withr::with_conn(

Check warning on line 235 in tests/testthat/test-lint_package.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-lint_package.R,line=235,col=10,[namespace_linter] 'with_conn' is not exported from {withr}.
list(conn = textConnection("lib_paths", "w")),
dput(.libPaths(), conn)

Check warning on line 237 in tests/testthat/test-lint_package.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-lint_package.R,line=237,col=10,[undesirable_function_linter] Avoid undesirable function ".libPaths". As an alternative, use withr::with_libpaths() for a temporary change instead of permanently modifying the library location.
)

Check warning on line 239 in tests/testthat/test-lint_package.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-lint_package.R,line=239,col=1,[trailing_whitespace_linter] Remove trailing whitespace.
exprs <- paste(
sprintf(".libPaths(%s)", paste(lib_paths, collapse = "")),
'options(lintr.linter_file = "lintr_test_config")',
sprintf('lints <- lintr::lint_package("%s")', test_path("dummy_packages", "RConfig")),
# simplify output to be read from stdout
Expand All @@ -243,7 +250,6 @@ test_that("lintr need not be attached for .lintr.R configs to use lintr function
} else {
rscript <- file.path(R.home("bin"), "Rscript")
}
system2(rscript, c("-e", '"stopifnot(requireNamespace(\'lintr\'))"'), stdout = TRUE)
expect_identical(
system2(rscript, c("-e", shQuote(exprs)), stdout = TRUE),
"infix_spaces_linter|any_duplicated_linter"
Expand Down

0 comments on commit 05873e2

Please sign in to comment.