Skip to content

Commit 5245866

Browse files
committed
Record if we're in a check reporter
1 parent 2978bc9 commit 5245866

File tree

7 files changed

+13
-7
lines changed

7 files changed

+13
-7
lines changed

β€ŽR/expect-that.Rβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#' informative traceack for failures. You should only need to set this if
1919
#' you're calling `fail()` from a helper function; see
2020
#' `vignette("custom-expectation")` for details.
21-
#' @param snapshot Is this a snapshot failure?
2221
#' @param trace An optional backtrace created by [rlang::trace_back()].
2322
#' When supplied, the expectation is displayed with the backtrace.
2423
#' Expert use only.

β€ŽR/reporter-check.Rβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ CheckReporter <- R6::R6Class(
1313
skips = NULL,
1414
warnings = NULL,
1515
n_ok = 0L,
16+
old_in_check_reporter = NULL,
1617

1718
initialize = function(...) {
1819
self$capabilities$parallel_support <- TRUE
@@ -35,7 +36,14 @@ CheckReporter <- R6::R6Class(
3536
}
3637
},
3738

39+
start_reporter = function() {
40+
self$old_in_check_reporter <- in_check_reporter()
41+
the$in_check_reporter <- TRUE
42+
},
43+
3844
end_reporter = function() {
45+
the$in_check_reporter <- self$old_in_check_reporter
46+
3947
if (self$skips$size() || self$warnings$size() || self$problems$size()) {
4048
self$cat_line(summary_line(
4149
n_fail = self$problems$size(),

β€ŽR/snapshot-file.Rβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ expect_snapshot_file <- function(
142142
return(equal)
143143
}
144144

145-
if (in_rcmd_check()) {
145+
if (in_check_reporter()) {
146146
hint <- ""
147147
} else {
148148
hint <- snapshot_review_hint(snapshotter$file, name)

β€ŽR/snapshot.Rβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ expect_snapshot_helper <- function(
340340
} else {
341341
variant_lab <- ""
342342
}
343-
if (in_rcmd_check()) {
343+
if (in_check_reporter()) {
344344
hint <- ""
345345
} else {
346346
hint <- snapshot_accept_hint(variant, snapshotter$file)

β€ŽR/testthat-package.Rβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ the <- new.env(parent = emptyenv())
2222
the$description <- character()
2323
the$top_level_test <- TRUE
2424
the$test_expectations <- 0
25+
the$in_check_reporter <- FALSE
2526

2627
# The following block is used by usethis to automatically manage
2728
# roxygen namespace tags. Modify with care!

β€ŽR/utils.Rβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ first_upper <- function(x) {
5151
x
5252
}
5353

54-
in_rcmd_check <- function() {
55-
nzchar(Sys.getenv("_R_CHECK_PACKAGE_NAME_", ""))
54+
in_check_reporter <- function() {
55+
isTRUE(the$in_check_reporter)
5656
}
5757

5858
r_version <- function() paste0("R", getRversion()[, 1:2])

β€Žman/fail.Rdβ€Ž

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
Β (0)