@@ -142,7 +142,11 @@ expect_snapshot_file <- function(
142142 return (equal )
143143 }
144144
145- hint <- snapshot_review_hint(snapshotter $ file , name )
145+ if (in_rcmd_check()) {
146+ hint <- " "
147+ } else {
148+ hint <- snapshot_review_hint(snapshotter $ file , name )
149+ }
146150
147151 if (! equal ) {
148152 msg <- sprintf(
@@ -151,7 +155,7 @@ expect_snapshot_file <- function(
151155 paste0(snapshotter $ file , " /" , name ),
152156 hint
153157 )
154- return (fail(msg ))
158+ return (fail(msg , snapshot = TRUE ))
155159 }
156160 pass(NULL )
157161}
@@ -167,45 +171,16 @@ announce_snapshot_file <- function(path, name = basename(path)) {
167171 }
168172}
169173
170- snapshot_review_hint <- function (
171- test ,
172- name ,
173- ci = on_ci(),
174- check = in_rcmd_check(),
175- reset_output = TRUE
176- ) {
174+ snapshot_review_hint <- function (test , name , reset_output = TRUE ) {
177175 if (reset_output ) {
178176 local_reporter_output()
179177 }
180178
181- path <- paste0(" tests/testthat/_snaps/" , test , " /" , new_name(name ))
182-
183- if (check ) {
184- if (on_gh()) {
185- bullets <- snap_download_hint()
186- } else {
187- bullets <- c(
188- if (ci ) " * Download and unzip run artifact\n " ,
189- if (! ci ) " * Locate check directory\n " ,
190- paste0(" * Copy '" , path , " ' to local test directory\n " )
191- )
192- }
193- } else {
194- bullets <- NULL
195- }
196-
197- paste0(
198- c(
199- bullets ,
200- cli :: format_inline(
201- " * Run {.run testthat::snapshot_review('{test}/')} to review changes"
202- )
203- ),
204- collapse = " "
179+ cli :: format_inline(
180+ " * Run {.run testthat::snapshot_review('{test}/{name}')} to review the change."
205181 )
206182}
207183
208-
209184snapshot_file_equal <- function (
210185 snap_dir , # _snaps/
211186 snap_test , # test file name
@@ -254,7 +229,7 @@ snapshot_file_equal <- function(
254229 # We want to fail on CI since this suggests that the user has failed
255230 # to record the value locally
256231 if (fail_on_new ) {
257- return (fail(message , trace_env = trace_env ))
232+ return (fail(message , snapshot = TRUE , trace_env = trace_env ))
258233 }
259234 testthat_warn(message )
260235 TRUE
0 commit comments