Skip to content

Commit e67713d

Browse files
Further normalization of expect_lint (#2967)
* further normalization of expect_lint * rm vestigial ws * caller_env is from rlang
1 parent 132a6dd commit e67713d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

R/expect_lint.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ expect_lint <- function(content, checks, ..., file = NULL, language = "en", igno
8787
}
8888

8989
expect_lint_impl_(lints, checks)
90+
91+
invisible(lints)
9092
}
9193

9294
#' NB: must _not_ succeed(), should only fail() or abort()
9395
#' @noRd
94-
expect_lint_impl_ <- function(lints, checks) {
96+
expect_lint_impl_ <- function(lints, checks, trace_env = rlang::caller_env()) {
9597
itr <- 0L
9698
# valid fields are those from Lint(), plus 'linter'
9799
lint_fields <- c(names(formals(Lint)), "linter")
@@ -117,11 +119,12 @@ expect_lint_impl_ <- function(lints, checks) {
117119
isTRUE(all.equal(value, check_field))
118120
}
119121
if (!ok) {
120-
return(testthat::fail(sprintf(
122+
fail_msg <- sprintf(
121123
"check #%d: %s %s did not match %s",
122124
# deparse ensures that NULL, list(), etc are handled gracefully
123125
itr, field, deparse(value), deparse(check_field)
124-
)))
126+
)
127+
return(testthat::fail(fail_msg, trace_env = trace_env))
125128
}
126129
}
127130
}

0 commit comments

Comments
 (0)