@@ -63,6 +63,34 @@ local_qmd_file <- function(..., .env = parent.frame()) {
6363 path
6464}
6565
66+ local_quarto_project <- function (
67+ name = " test-project" ,
68+ type ,
69+ ... ,
70+ .env = parent.frame()
71+ ) {
72+ skip_if_no_quarto()
73+ path_tmp <- withr :: local_tempdir(
74+ pattern = " quarto-tests-project-" ,
75+ .local_envir = .env
76+ )
77+ tryCatch(
78+ quarto_create_project(
79+ name = name ,
80+ type = type ,
81+ dir = path_tmp ,
82+ no_prompt = TRUE ,
83+ quiet = TRUE ,
84+ ...
85+ ),
86+ error = function (e ) {
87+ stop(" Creating temp project for tests failed" , call. = FALSE )
88+ }
89+ )
90+ # return the path to the created project
91+ return (file.path(path_tmp , name ))
92+ }
93+
6694.render <- function (input , output_file = NULL , ... , .env = parent.frame()) {
6795 skip_if_no_quarto()
6896 skip_if_not_installed(" withr" )
@@ -105,23 +133,33 @@ expect_snapshot_qmd_output <- function(name, input, output_file = NULL, ...) {
105133
106134transform_quarto_cli_in_output <- function (
107135 full_path = FALSE ,
108- normalize_path = FALSE ,
109136 version = FALSE
110137) {
138+ hide_path <- function (lines , real_path ) {
139+ gsub(
140+ real_path ,
141+ " <quarto full path>" ,
142+ lines ,
143+ fixed = TRUE
144+ )
145+ }
146+
111147 return (
112148 function (lines ) {
113149 if (full_path ) {
114150 quarto_found <- find_quarto()
115- if (normalize_path ) {
116- quarto_found <- normalizePath(quarto_found , mustWork = FALSE )
117- }
118- lines <- gsub(quarto_found , " <quarto full path>" , lines , fixed = TRUE )
151+ quarto_found <- dirname(quarto_found )
152+ quarto_found_normalized <- normalizePath(quarto_found , mustWork = FALSE )
153+ # look for non-normalized path
154+ lines <- hide_path(lines , quarto_found )
155+ # look for normalized path
156+ lines <- hide_path(lines , quarto_found_normalized )
157+
119158 # seems like there are quotes around path in CI windows
120159 lines <- gsub(
121- " \" <quarto full path>\" " ,
122- " <quarto full path>" ,
123- lines ,
124- fixed = TRUE
160+ " \" <quarto full path>([^\" ]*)\" " ,
161+ " <quarto full path>\\ 1" ,
162+ lines
125163 )
126164 } else {
127165 # it will be quarto.exe only on windows
0 commit comments