Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update compare_branches not to fail when one branch errors in some cases #1962

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .dev/compare_branches.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ param_list <- list(
"--benchmark",
default = if (interactive()) {
askYesNo("Benchmark the timing of linter execution?")
} else {
FALSE
},
type = "logical",
help = "Whether to run performance diagnostics of the branch(es)"
Expand Down Expand Up @@ -311,15 +313,23 @@ lint_one_package <- function(package, linters, out_dir, check_deps) {
# ignore them because they're innocuous.
# also ignore lintr's deprecations to make including all linters easier
suppressMessages(withCallingHandlers(
lints <- as.data.frame(lint_dir(package, linters = linters, parse_settings = FALSE)),
{
# Don't fail out if one branch exhibits errors (e.g. if the new version fixes a known error)
lints <- tryCatch(lint_dir(package, linters = linters, parse_settings = FALSE), error = identity)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are already within a withCallingHandlers() block so you could just add an error handler?

if (inherits(lints, "error")) {
lints <- list(Lint(package, message = paste("Failed:", conditionMessage(lints))))
class(lints) <- "lints"
}
lint_df <- as.data.frame(lints)
},
warning = function(cond) {
if (!grepl("ncomplete final line found|was deprecated in lintr", cond$message)) {
warning(cond$message, call. = FALSE)
}
invokeRestart("muffleWarning")
}
))
if (nrow(lints) > 0L) data.table::fwrite(lints, file.path(out_dir, paste0(package_name, ".csv")))
if (nrow(lint_df) > 0L) data.table::fwrite(lint_df, file.path(out_dir, paste0(package_name, ".csv")))
TRUE
}

Expand Down