Skip to content

Commit 864ed25

Browse files
hadleygaborcsardi
andauthored
Update snapshots (#1722)
* Update snapshots Since knitr now generates srcref locations in a different format * Fix snapshots for markdown errors Drop the traceback from knitr, because it is only there in `R CMD check`, but not in `test()` and it also seems quite fragile. --------- Co-authored-by: Gábor Csárdi <[email protected]>
1 parent ace81d3 commit 864ed25

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

tests/testthat/_snaps/markdown-code.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
Message
1717
18-
Quitting from lines 1-1
18+
Quitting from :1-1
1919
x <text>:4: @description failed to evaluate inline markdown code.
2020
Caused by error in `map_chr()`:
2121
i In index: 1.

tests/testthat/_snaps/rd-include-rmd.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
2121
Message
2222
23-
Quitting from lines 2-3 [unnamed-chunk-2] (<temp-path.Rmd>)
23+
Quitting from <temp-path.Rmd>:1-3 [unnamed-chunk-2]
2424
25-
Quitting from lines 2-2 [unnamed-chunk-1] (<another-temp-path.Rmd>)
25+
Quitting from <another-temp-path.Rmd>:1-2 [unnamed-chunk-1]
2626
x <text>:3: @includeRmd failed to evaluate '<temp-path.Rmd>'.
2727
Caused by error:
2828
! Error

tests/testthat/test-markdown-code.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,14 @@ test_that("inline code gives useful warning", {
133133
"
134134

135135
expect_snapshot(
136-
out <- roc_proc_text(rd_roclet(), block)[[1]]
136+
out <- roc_proc_text(rd_roclet(), block)[[1]],
137+
transform = function(x) {
138+
line <- grep("~~~", x)[1]
139+
if (!is.na(line)) {
140+
x <- x[1:(line-1)]
141+
}
142+
x
143+
}
137144
)
138145
expect_equal(out$get_value("description"), "\\verb{r 1 + }")
139146
})

tests/testthat/test-rd-include-rmd.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ test_that("useful warnings", {
297297
transform = function(x) {
298298
x <- gsub(path, "<temp-path.Rmd>", x, fixed = TRUE)
299299
x <- gsub("file.*\\.Rmd", "<another-temp-path.Rmd>", x)
300+
line <- grep("~~~", x)[1]
301+
if (!is.na(line)) {
302+
x <- x[1:(line-1)]
303+
}
300304
x
301305
}
302306
)

0 commit comments

Comments
 (0)