From 5ced947c1eb42719b294f6039262ffcea8e97a91 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 22 Nov 2023 14:19:19 -0600 Subject: [PATCH] Use snapshot for ease of debugigng --- tests/testthat/_snaps/stdout-stderr.md | 22 ++++++++++++++++++++++ tests/testthat/test-stdout-stderr.R | 4 +--- 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 tests/testthat/_snaps/stdout-stderr.md diff --git a/tests/testthat/_snaps/stdout-stderr.md b/tests/testthat/_snaps/stdout-stderr.md new file mode 100644 index 00000000..c6c90673 --- /dev/null +++ b/tests/testthat/_snaps/stdout-stderr.md @@ -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] "Created on 2023-11-22 with [reprex v2.0.2.9000](https://reprex.tidyverse.org)" + [6] "" + [7] "
" + [8] "" + [9] "Standard output and standard error" + [10] "" + [11] "" + [12] "``` sh" + [13] "blah" + [14] "```" + [15] "" + [16] "
" + diff --git a/tests/testthat/test-stdout-stderr.R b/tests/testthat/test-stdout-stderr.R index e80af7d4..f52c9d66 100644 --- a/tests/testthat/test-stdout-stderr.R +++ b/tests/testthat/test-stdout-stderr.R @@ -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", {