From 5abcd7786513db6b03070ae096670fb96b28be3b Mon Sep 17 00:00:00 2001 From: Luis Moris Fernandez Date: Tue, 17 Sep 2024 17:31:33 +0200 Subject: [PATCH] archive library snaps - Running tests with `test_package` tests the installed package. - Updated test snapshots are stored in the `_snaps` folder within the installation library. - Archive the `_snaps` folder, not the root folder, as the root does not contain updated snapshots. --- .github/workflows/test.yml | 2 +- scripts/test_qc_pkg.R | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e0dcc6..3bc254e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -89,5 +89,5 @@ jobs: uses: actions/upload-artifact@v4 with: name: snap_results - path: tests/testthat/_snaps + path: snaps_archive \ No newline at end of file diff --git a/scripts/test_qc_pkg.R b/scripts/test_qc_pkg.R index e850da5..2d6d169 100644 --- a/scripts/test_qc_pkg.R +++ b/scripts/test_qc_pkg.R @@ -46,6 +46,17 @@ test_results <- tibble::as_tibble( success[["test"]] <- sum(test_results[["failed"]]) == 0 +# Copy _snaps folder so it can be archived later for test debugging +# Empty if no errors are found +root <- Sys.getenv("GITHUB_WORKSPACE") +archive_folder <- file.path(root, "snaps_archive") +if (!dir.exists(archive_folder)) dir.create(archive_folder) + +if (!success[["test"]]) { + snap_folder <- system.file("tests/testthat/_snaps") + file.copy(snap_folder, archive_folder, recursive = TRUE) +} + message("##########################") message("###### TESTING (F) ######") message("##########################")