@@ -73,15 +73,22 @@ expect_known_output <- function(
7373 act $ lab <- label %|| % quo_label(act $ quo )
7474 act <- append(act , eval_with_output(object , print = print , width = width ))
7575
76- compare_file (file , act $ out , update = update , info = info , ... )
76+ expect_file_unchanged_ (file , act $ out , update = update , info = info , ... )
7777 invisible (act $ val )
7878}
7979
80- compare_file <- function (path , lines , ... , update = TRUE , info = NULL ) {
80+ expect_file_unchanged_ <- function (
81+ path ,
82+ lines ,
83+ ... ,
84+ update = TRUE ,
85+ info = NULL
86+ ) {
8187 if (! file.exists(path )) {
8288 cli :: cli_warn(" Creating reference output." )
8389 brio :: write_lines(lines , path )
84- return (pass(NULL ))
90+ pass()
91+ return ()
8592 }
8693
8794 old_lines <- brio :: read_lines(path )
@@ -108,9 +115,10 @@ compare_file <- function(path, lines, ..., update = TRUE, info = NULL) {
108115 encodeString(path , quote = " '" ),
109116 paste0(comp , collapse = " \n\n " )
110117 )
111- return (fail(msg , info = info , trace_env = caller_env()))
118+ fail(msg , info = info , trace_env = caller_env())
119+ } else {
120+ pass()
112121 }
113- pass(NULL )
114122}
115123
116124# ' Do you expect the output/result to equal a known good value?
@@ -151,7 +159,7 @@ expect_output_file <- function(
151159 act $ lab <- label %|| % quo_label(act $ quo )
152160 act <- append(act , eval_with_output(object , print = print , width = width ))
153161
154- compare_file (file , act $ out , update = update , info = info , ... )
162+ expect_file_unchanged_ (file , act $ out , update = update , info = info , ... )
155163 invisible (act $ val )
156164}
157165
@@ -180,6 +188,7 @@ expect_known_value <- function(
180188 if (! file.exists(file )) {
181189 cli :: cli_warn(" Creating reference value." )
182190 saveRDS(object , file , version = version )
191+ pass()
183192 } else {
184193 ref_val <- readRDS(file )
185194 comp <- compare(act $ val , ref_val , ... )
@@ -194,11 +203,13 @@ expect_known_value <- function(
194203 encodeString(file , quote = " '" ),
195204 comp $ message
196205 )
197- return (fail(msg , info = info ))
206+ fail(msg , info = info )
207+ } else {
208+ pass()
198209 }
199210 }
200211
201- pass (act $ value )
212+ invisible (act $ val )
202213}
203214
204215# ' @export
@@ -233,18 +244,21 @@ expect_known_hash <- function(object, hash = NULL) {
233244
234245 if (is.null(hash )) {
235246 cli :: cli_warn(" No recorded hash: use {substr(act_hash, 1, 10)}." )
247+ pass()
236248 } else {
237249 if (hash != act_hash ) {
238250 msg <- sprintf(
239251 " Expected value to hash to %s.\n Actual hash: %s" ,
240252 hash ,
241253 act_hash
242254 )
243- return (fail(msg ))
255+ fail(msg )
256+ } else {
257+ pass()
244258 }
245259 }
246260
247- pass (act $ value )
261+ invisible (act $ val )
248262}
249263
250264all_utf8 <- function (x ) {
0 commit comments