@@ -399,15 +399,9 @@ snapshot_hint <- function(
399399 id <- c(file , if (! identical(variant , " _default" )) variant , name )
400400 full_name <- paste0(id , collapse = " /" )
401401
402- args <- encodeString(full_name , quote = ' "' )
403- # Include path argument if we're in a different working directory
404- wd <- Sys.getenv(" TESTTHAT_WD" , unset = " " )
405- if (wd != " " ) {
406- test_path <- file.path(wd , " tests/testthat" )
407- if (test_path != getwd()) {
408- args <- paste0(args , " , " , encodeString(getwd(), quote = ' "' ))
409- }
410- }
402+ args <- c(full_name , snapshot_hint_path())
403+ args <- encodeString(args , quote = ' "' )
404+ args <- paste0(args , collapse = " , " )
411405
412406 accept_link <- cli :: format_inline(" {.run testthat::snapshot_accept({args})}" )
413407 review_link <- cli :: format_inline(" {.run testthat::snapshot_review({args})}" )
@@ -419,6 +413,21 @@ snapshot_hint <- function(
419413 structure(out , class = " testthat_hint" )
420414}
421415
416+ # Include path argument if we're in a different working directory
417+ snapshot_hint_path <- function () {
418+ wd <- Sys.getenv(" TESTTHAT_WD" , unset = " " )
419+ if (wd == " " ) {
420+ return ()
421+ }
422+
423+ test_path <- file.path(wd , " tests/testthat" )
424+ if (test_path == getwd()) {
425+ return ()
426+ }
427+
428+ getwd()
429+ }
430+
422431# ' @export
423432print.testthat_hint <- function (x , ... ) {
424433 cat(paste0(x , " \n " , collapse = " " ))
0 commit comments