-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start using testthat 3e * get migrated tests passing * reference PR * infix spacing * add & use a helper for comparing environments * add rlang Suggested * revert custom helper * remove rlang too Co-authored-by: AshesITR <alexander.rosenstock@web.de>
- Loading branch information
1 parent
80ec7b1
commit 23b06bd
Showing
13 changed files
with
198 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,55 @@ | ||
test_that("GitHub Actions functionality works", { | ||
# imitate being on GHA whether or not we are | ||
withr::with_envvar(c(GITHUB_ACTIONS = "true"), { | ||
old <- options(lintr.rstudio_source_markers = FALSE) | ||
on.exit(options(old), add = TRUE) | ||
withr::local_envvar(list(GITHUB_ACTIONS = "true")) | ||
withr::local_options(lintr.rstudio_source_markers = FALSE) | ||
tmp <- withr::local_tempfile() | ||
|
||
writeLines("x <- 1:nrow(y)", tmp <- tempfile()) | ||
on.exit(unlink(tmp)) | ||
writeLines("x <- 1:nrow(y)", tmp) | ||
|
||
l <- lint(tmp) | ||
expect_output(print(l), "::warning file", fixed = TRUE) | ||
}) | ||
l <- lint(tmp) | ||
expect_output(print(l), "::warning file", fixed = TRUE) | ||
}) | ||
|
||
test_that("GitHub Actions functionality works in a subdirectory", { | ||
# imitate being on GHA whether or not we are | ||
pkg_path <- file.path("dummy_packages", "assignmentLinter") | ||
withr::with_envvar(c(GITHUB_ACTIONS = "true"), { | ||
old <- options( | ||
lintr.rstudio_source_markers = FALSE, | ||
lintr.github_annotation_project_dir = pkg_path | ||
) | ||
on.exit(options(old), add = TRUE) | ||
|
||
read_settings(NULL) | ||
l <- lint_package( | ||
pkg_path, linters = list(assignment_linter()), | ||
parse_settings = FALSE | ||
) | ||
expect_output( | ||
print(l), | ||
paste0("::warning file=", file.path(pkg_path, "R(/|\\\\)abc\\.R")) | ||
) | ||
}) | ||
withr::local_envvar(list(GITHUB_ACTIONS = "true")) | ||
withr::local_options(lintr.rstudio_source_markers = FALSE, lintr.github_annotation_project_dir = pkg_path) | ||
|
||
read_settings(NULL) | ||
l <- lint_package( | ||
pkg_path, | ||
linters = list(assignment_linter()), | ||
parse_settings = FALSE | ||
) | ||
expect_output( | ||
print(l), | ||
paste0("::warning file=", file.path(pkg_path, "R(/|\\\\)abc\\.R")) | ||
) | ||
}) | ||
|
||
test_that("Printing works for Travis", { | ||
withr::with_envvar(c(GITHUB_ACTIONS = "false", TRAVIS_REPO_SLUG = "test/repo", LINTR_COMMENT_BOT = "true"), { | ||
old <- options(lintr.rstudio_source_markers = FALSE) | ||
on.exit(options(old), add = TRUE) | ||
withr::local_envvar(list(GITHUB_ACTIONS = "false", TRAVIS_REPO_SLUG = "test/repo", LINTR_COMMENT_BOT = "true")) | ||
withr::local_options(lintr.rstudio_source_markers = FALSE) | ||
tmp <- withr::local_tempfile() | ||
writeLines("x <- 1:nrow(y)", tmp) | ||
|
||
writeLines("x <- 1:nrow(y)", tmp <- tempfile()) | ||
on.exit(unlink(tmp)) | ||
l <- lint(tmp) | ||
|
||
l <- lint(tmp) | ||
|
||
with_mock(github_comment = function(x, ...) cat(x, "\n"), .env = asNamespace("lintr"), { | ||
expect_output(print(l), "*warning:*", fixed = TRUE) | ||
}) | ||
with_mock(github_comment = function(x, ...) cat(x, "\n"), .env = asNamespace("lintr"), { | ||
expect_output(print(l), "*warning:*", fixed = TRUE) | ||
}) | ||
}) | ||
|
||
test_that("Printing works for Wercker", { | ||
withr::with_envvar(c(GITHUB_ACTIONS = "false", WERCKER_GIT_BRANCH = "test/repo", LINTR_COMMENT_BOT = "true"), { | ||
old <- options(lintr.rstudio_source_markers = FALSE) | ||
on.exit(options(old), add = TRUE) | ||
|
||
writeLines("x <- 1:nrow(y)", tmp <- tempfile()) | ||
on.exit(unlink(tmp)) | ||
withr::local_envvar(list(GITHUB_ACTIONS = "false", WERCKER_GIT_BRANCH = "test/repo", LINTR_COMMENT_BOT = "true")) | ||
withr::local_options(lintr.rstudio_source_markers = FALSE) | ||
tmp <- withr::local_tempfile() | ||
writeLines("x <- 1:nrow(y)", tmp) | ||
|
||
l <- lint(tmp) | ||
l <- lint(tmp) | ||
|
||
with_mock(github_comment = function(x, ...) cat(x, "\n"), .env = asNamespace("lintr"), { | ||
expect_output(print(l), "*warning:*", fixed = TRUE) | ||
}) | ||
with_mock(github_comment = function(x, ...) cat(x, "\n"), .env = asNamespace("lintr"), { | ||
expect_output(print(l), "*warning:*", fixed = TRUE) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.