Skip to content

Commit

Permalink
Use snapshot for ease of debugigng
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Nov 22, 2023
1 parent 295f417 commit 5ced947
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
22 changes: 22 additions & 0 deletions tests/testthat/_snaps/stdout-stderr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# stdout is captured

Code
(reprex(system2("echo", args = "blah"), std_out_err = TRUE))
Output
[1] "``` r"
[2] "system2(\"echo\", args = \"blah\")"
[3] "```"
[4] ""
[5] "<sup>Created on 2023-11-22 with [reprex v2.0.2.9000](https://reprex.tidyverse.org)</sup>"
[6] ""
[7] "<details style=\"margin-bottom:10px;\">"
[8] "<summary>"
[9] "Standard output and standard error"
[10] "</summary>"
[11] ""
[12] "``` sh"
[13] "blah"
[14] "```"
[15] ""
[16] "</details>"

4 changes: 1 addition & 3 deletions tests/testthat/test-stdout-stderr.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
test_that("stdout is captured", {
skip_on_cran()
out <- reprex(system2("echo", args = "blah"), std_out_err = TRUE)
expect_match(out, "Standard output and standard error", all = FALSE)
expect_match(out, "^blah$", all = FALSE)
expect_snapshot((reprex(system2("echo", args = "blah"), std_out_err = TRUE)))
})

test_that("stdout placeholder appears if nothing is captured", {
Expand Down

0 comments on commit 5ced947

Please sign in to comment.