Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# testthat 3.3.1

* The hint to use `snapshot_download_gh()` is now only emitted when running in a job named "R-CMD-check" (#2300).
* `expect_snapshot_file()` correctly reports file name if duplicated (@MichaelChirico, #2296).
* Fixed support for `shinytest2::AppDriver$expect_values()` screenshot snapshot failing on CI (#2293, #2288).

Expand Down
2 changes: 1 addition & 1 deletion R/reporter-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ summary_line <- function(n_fail, n_warn, n_skip, n_pass) {
snapshot_check_hint <- function() {
intro <- "To review and process snapshots locally:"

if (on_gh()) {
if (on_gh() && Sys.getenv("GITHUB_JOB") == "R-CMD-check") {
repository <- Sys.getenv("GITHUB_REPOSITORY")
run_id <- Sys.getenv("GITHUB_RUN_ID")

Expand Down
6 changes: 4 additions & 2 deletions R/snapshot-github.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
#' take the artifacts from.
#'
#' Note that you should not generally need to use this function manually;
#' instead copy and paste from the hint emitted on GitHub.
#' instead copy and paste from the hint emitted on GitHub. This hint is only
#' emitted when running in a job named "R-CMD-check", since that's where the
#' testthat artifact is typically uploaded.
#'
#' @param repository Repository owner/name, e.g. `"r-lib/testthat"`.
#' @param run_id Run ID, e.g. `"47905180716"`. You can find this in the action url.
#' @param dest_dir Directory to download to. Defaults to the current directory.
#' @param dest_dir Package root directory. Defaults to the current directory.
#' @export
snapshot_download_gh <- function(repository, run_id, dest_dir = ".") {
check_string(repository)
Expand Down
6 changes: 4 additions & 2 deletions man/snapshot_download_gh.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tests/testthat/test-reporter-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ test_that("generates informative snapshot hints", {
withr::local_envvar(
GITHUB_ACTIONS = "true",
GITHUB_REPOSITORY = "r-lib/testthat",
GITHUB_RUN_ID = "123"
GITHUB_RUN_ID = "123",
GITHUB_JOB = "R-CMD-check"
)
expect_snapshot(base::writeLines(snapshot_check_hint()))
})