Skip to content

Commit 73ea582

Browse files
committed
tests - add a test for error reporting
and improve snapshot transformation
1 parent 28a292c commit 73ea582

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

tests/testthat/_snaps/quarto.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,31 @@
99
Caused by error:
1010
! System command 'quarto' failed
1111

12+
# quarto_run report full quarto cli error message
13+
14+
Code
15+
quarto_inspect()
16+
Condition
17+
Error in `quarto_inspect()`:
18+
x Error running quarto cli.
19+
-------------------------
20+
ERROR: Book chapter 'intro.qmd' not found
21+
22+
Stack trace:
23+
at throwInputNotFound (file:///<quarto full path>/quarto.js:100761:19)
24+
at findInputs (file:///<quarto full path>/quarto.js:100792:17)
25+
at eventLoopTick (ext:core/01_core.js:175:7)
26+
at async findChapters (file:///<quarto full path>/quarto.js:100804:13)
27+
at async bookRenderItems (file:///<quarto full path>/quarto.js:100807:5)
28+
at async Object.bookProjectConfig [as config] (file:///<quarto full path>/quarto.js:100712:25)
29+
at async projectContext (file:///<quarto full path>/quarto.js:82390:38)
30+
at async inspectConfig (file:///<quarto full path>/quarto.js:110378:21)
31+
at async Command.actionHandler (file:///<quarto full path>/quarto.js:110497:20)
32+
at async Command.execute (file:///<quarto full path>/quarto.js:8253:13)
33+
34+
Caused by error:
35+
! System command 'quarto.exe' failed
36+
1237
# is_using_quarto correctly check directory
1338

1439
Code
@@ -60,7 +85,7 @@
6085
Code
6186
quarto_binary_sitrep(debug = TRUE)
6287
Message
63-
v quarto R package will use '<quarto full path>'
88+
v quarto R package will use '<quarto full path>\quarto.exe'
6489
i It is configured to use the latest version found in the PATH environment variable.
6590
x RStudio IDE render button seems configured to use '<RSTUDIO_QUARTO path>'.
6691
! It is configured through `RSTUDIO_QUARTO` environment variable.
@@ -72,7 +97,7 @@
7297
Code
7398
quarto_binary_sitrep(debug = TRUE)
7499
Message
75-
v quarto R package will use '<quarto full path>'
100+
v quarto R package will use '<quarto full path>\quarto.exe'
76101
i It is configured to use the latest version found in the PATH environment variable.
77102
Output
78103
[1] TRUE

tests/testthat/_snaps/render.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
Code
44
quarto_render("input.qmd", quiet = TRUE, quarto_args = c("--to", "native"))
55
Output
6-
Running <quarto full path> render input.qmd --quiet --to native
6+
Running <quarto full path>/quarto.exe render input.qmd --quiet --to native
77

tests/testthat/test-quarto.R

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@ test_that("quarto_run gives guidance in error", {
1414
)
1515
})
1616

17+
test_that("quarto_run report full quarto cli error message", {
18+
skip_if_no_quarto()
19+
local_reproducible_output(width = 1000)
20+
# https://github.com/quarto-dev/quarto-r/issues/235
21+
tmp_proj <- local_quarto_project(type = "book")
22+
withr::local_dir(tmp_proj)
23+
# simulate an error by renaming the intro.qmd
24+
file.rename(from = "intro.qmd", to = "no_intro.qmd")
25+
expect_snapshot(
26+
error = TRUE,
27+
quarto_inspect(),
28+
transform = transform_quarto_cli_in_output(
29+
full_path = TRUE
30+
)
31+
)
32+
})
33+
1734
test_that("is_using_quarto correctly check directory", {
1835
qmd <- local_qmd_file(c("content"))
1936
# Only qmd
@@ -63,7 +80,7 @@ test_that("quarto CLI sitrep", {
6380
lines,
6481
fixed = TRUE
6582
)
66-
transform_quarto_cli_in_output(full_path = TRUE, normalize_path = TRUE)(
83+
transform_quarto_cli_in_output(full_path = TRUE)(
6784
lines
6885
)
6986
}
@@ -75,8 +92,7 @@ test_that("quarto CLI sitrep", {
7592
expect_snapshot(
7693
quarto_binary_sitrep(debug = TRUE),
7794
transform = transform_quarto_cli_in_output(
78-
full_path = TRUE,
79-
normalize_path = TRUE
95+
full_path = TRUE
8096
)
8197
)
8298
)

0 commit comments

Comments
 (0)