-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into rm-xml-missing-tests
- Loading branch information
Showing
67 changed files
with
1,229 additions
and
421 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# This script is designed to find linters that lack metadata tests. | ||
# To do so, it forces Lint() to give the wrong information, | ||
# runs the test suite, and finds linters that nevertheless pass all their tests. | ||
library(testthat) | ||
|
||
lint_file <- "R/lint.R" | ||
|
||
original <- readLines(lint_file) | ||
expected_line <- "line_number = as.integer(line_number)" | ||
if (sum(grepl(expected_line, original, fixed = TRUE)) != 1L) { | ||
stop(sprintf( | ||
"Please update this workflow -- need exactly one hit for line '%s' in file '%s'.", | ||
expected_line, lint_file | ||
)) | ||
} | ||
writeLines( | ||
sub(expected_line, "line_number = as.integer(2^31 - 1)", original, fixed = TRUE), | ||
lint_file | ||
) | ||
# Not useful in CI but good when running locally. | ||
withr::defer({ | ||
writeLines(original, lint_file) | ||
pkgload::load_all() | ||
}) | ||
|
||
pkgload::load_all() | ||
|
||
report <- test_dir( | ||
"tests/testthat", | ||
filter = "linter$", | ||
stop_on_failure = FALSE, | ||
reporter = SilentReporter$new() | ||
) | ||
names(report) <- gsub("^test-|\\.R$", "", vapply(report, `[[`, "file", FUN.VALUE = character(1L))) | ||
|
||
# Hack the nested structure of the testthat report to identify which files have | ||
# any failed test | ||
failed <- report |> | ||
vapply( | ||
\(x) any(vapply(x$results, inherits, "expectation_failure", FUN.VALUE = logical(1L))), | ||
logical(1L) | ||
) |> | ||
which() |> | ||
names() |> | ||
unique() | ||
|
||
passed <- setdiff( | ||
available_linters(tags = NULL)$linter, | ||
failed | ||
) | ||
|
||
if (length(passed) > 0L) { | ||
stop("Please add tests of lint metadata for the following linters: ", toString(passed)) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Ensure lint metadata is tested | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
name: ensure-metadata-tests | ||
|
||
jobs: | ||
ensure-metadata-tests: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
r-version: "release" | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
|
||
- name: Ensure lint metadata is tested | ||
run: | | ||
options(crayon.enabled = TRUE) | ||
callr::rscript(".dev/lint_metadata_test.R") | ||
shell: Rscript {0} |
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
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
Oops, something went wrong.