@@ -80,10 +80,12 @@ expect_doppelganger <- function(title,
8080
8181 testthat :: local_edition(3 )
8282
83+ file <- paste0(fig_name , " .svg" )
84+
8385 withCallingHandlers(
8486 testthat :: expect_snapshot_file(
8587 testcase ,
86- name = paste0( fig_name , " .svg " ) ,
88+ name = file ,
8789 binary = FALSE ,
8890 cran = FALSE
8991 ),
@@ -94,9 +96,34 @@ expect_doppelganger <- function(title,
9496 " i" = " Please update your snapshots."
9597 ))
9698 }
99+
100+ if (! is.null(snapshotter <- get_snapshotter())) {
101+ path_old <- snapshot_path(snapshotter , file )
102+ path_new <- snapshot_path(snapshotter , paste0(fig_name , " .new.svg" ))
103+
104+ if (all(file.exists(path_old , path_new ))) {
105+ push_log(fig_name , path_old , path_new )
106+ }
107+ }
97108 }
98109 )
110+ }
111+
112+ # From testthat
113+ get_snapshotter <- function () {
114+ x <- getOption(" testthat.snapshotter" )
115+ if (is.null(x )) {
116+ return ()
117+ }
99118
119+ if (! x $ is_active()) {
120+ return ()
121+ }
122+
123+ x
124+ }
125+ snapshot_path <- function (snapshotter , file ) {
126+ file.path(snapshotter $ snap_dir , snapshotter $ file , file )
100127}
101128
102129is_graphics_engine_stale <- function () {
@@ -112,10 +139,13 @@ str_standardise <- function(s, sep = "-") {
112139}
113140
114141is_snapshot_stale <- function (title , testcase ) {
115- ctxt <- testthat :: get_reporter() $ .context
116- file <- paste0(str_standardise( title ), " .svg " )
117- path <- testthat :: test_path( " _snaps " , ctxt , file )
142+ if (is_null( snapshotter <- get_snapshotter())) {
143+ return ( FALSE )
144+ }
118145
146+ file <- paste0(str_standardise(title ), " .svg" )
147+ path <- snapshot_path(snapshotter , file )
148+
119149 if (! file.exists(path )) {
120150 return (FALSE )
121151 }
0 commit comments