Skip to content

Commit 767ab96

Browse files
Merge branch 'main' into f-2386-use-cli
2 parents 776408d + c3ba49b commit 767ab96

File tree

2 files changed

+26
-34
lines changed

2 files changed

+26
-34
lines changed

tests/testthat/test-ci.R

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
test_that("GitHub Actions functionality works", {
2-
# imitate being on GHA whether or not we are
32
withr::local_envvar(list(GITHUB_ACTIONS = "true"))
43
withr::local_options(lintr.rstudio_source_markers = FALSE)
54
tmp <- withr::local_tempfile(lines = "x <- 1:nrow(y)")
@@ -9,7 +8,6 @@ test_that("GitHub Actions functionality works", {
98
})
109

1110
test_that("GitHub Actions functionality works in a subdirectory", {
12-
# imitate being on GHA whether or not we are
1311
pkg_path <- test_path("dummy_packages", "assignmentLinter")
1412
withr::local_envvar(list(GITHUB_ACTIONS = "true"))
1513
withr::local_options(lintr.rstudio_source_markers = FALSE, lintr.github_annotation_project_dir = pkg_path)
@@ -26,14 +24,31 @@ test_that("GitHub Actions functionality works in a subdirectory", {
2624
)
2725
})
2826

29-
test_that("GitHub Actions - linting on error works", {
30-
# imitate being on GHA whether or not we are
31-
withr::local_envvar(list(GITHUB_ACTIONS = "true", LINTR_ERROR_ON_LINT = "true"))
32-
withr::local_options(lintr.rstudio_source_markers = FALSE)
33-
tmp <- withr::local_tempfile(lines = "x <- 1:nrow(y)")
27+
patrick::with_parameters_test_that(
28+
"GitHub Actions - error on lint works",
29+
{
30+
withr::local_envvar(list(GITHUB_ACTIONS = "true", LINTR_ERROR_ON_LINT = env_var_value))
31+
withr::local_options(lintr.rstudio_source_markers = FALSE)
32+
tmp <- withr::local_tempfile(lines = "x <- 1:nrow(y)")
3433

35-
l <- lint(tmp)
34+
l <- lint(tmp)
3635

37-
local_mocked_bindings(quit = function(...) cat("Tried to quit.\n"))
38-
expect_output(print(l), "::warning file", fixed = TRUE)
39-
})
36+
local_mocked_bindings(quit = function(...) cat("Tried to quit.\n"))
37+
expect_output(print(l), "::warning file", fixed = TRUE)
38+
},
39+
env_var_value = list("T", "true")
40+
)
41+
42+
patrick::with_parameters_test_that(
43+
"GitHub Actions - env var for error on lint is converted to logical",
44+
{
45+
withr::local_envvar(list(GITHUB_ACTIONS = "true", LINTR_ERROR_ON_LINT = env_var_value))
46+
withr::local_options(lintr.rstudio_source_markers = FALSE)
47+
tmp <- withr::local_tempfile(lines = "x <- 1:nrow(y)")
48+
49+
l <- lint(tmp)
50+
51+
expect_output(print(l), "::warning file", fixed = TRUE)
52+
},
53+
env_var_value = list("", "F", NA, NULL)
54+
)

tests/testthat/test-settings.R

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,29 +88,6 @@ test_that("rot utility works as intended", {
8888
expect_identical(lintr:::rot(letters), c(letters[14L:26L], LETTERS[1L:13L]))
8989
})
9090

91-
test_that("logical_env utility works as intended", {
92-
test_env <- "LINTR_TEST_LOGICAL_ENV_"
93-
withr::with_envvar(
94-
setNames("true", test_env),
95-
expect_true(lintr:::logical_env(test_env))
96-
)
97-
98-
withr::with_envvar(
99-
setNames("F", test_env),
100-
expect_false(lintr:::logical_env(test_env))
101-
)
102-
103-
withr::with_envvar(
104-
setNames("", test_env),
105-
expect_null(lintr:::logical_env(test_env))
106-
)
107-
108-
withr::with_envvar(
109-
setNames(list(NULL), test_env),
110-
expect_null(lintr:::logical_env(test_env))
111-
)
112-
})
113-
11491
# fixing #774
11592
test_that("linters_with_defaults doesn't break on very long input", {
11693
expect_named(

0 commit comments

Comments
 (0)