From 05873e209c3ac8db90263d3c73e1add0e60f59b8 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 25 Dec 2023 02:29:07 -0800 Subject: [PATCH] try forcing matched .libPaths()? --- tests/testthat/test-lint_package.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-lint_package.R b/tests/testthat/test-lint_package.R index 18a18a388..ee011031a 100644 --- a/tests/testthat/test-lint_package.R +++ b/tests/testthat/test-lint_package.R @@ -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( + list(conn = textConnection("lib_paths", "w")), + dput(.libPaths(), conn) + ) + 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 @@ -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"