Skip to content

Commit

Permalink
Scrub temp paths. (#45)
Browse files Browse the repository at this point in the history
GHA workflow runners had some confusion in test results.
  • Loading branch information
jonthegeek authored Mar 29, 2024
1 parent 9270bbf commit b5d6f88
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
10 changes: 10 additions & 0 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,13 @@ scrub_config <- function(input) {
scrub_tempdir <- function(input) {
sub("^.*Rtmp\\S+", "TMPDIR", input)
}

scrub_path <- function(input, keep_dirs = c("R", "tests")) {
dirs_string <- paste0(keep_dirs, collapse = "|")
search <- glue("^.*(/({dirs_string})/)")
stringr::str_replace(
input,
search,
"\\1"
)
}
16 changes: 7 additions & 9 deletions tests/testthat/test-generate_pkg_main.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ test_that("generate_pkg() returns a vector of created files", {
saveRDS(guru_rapid, "guru_rapid.rds")

test_result <- generate_pkg(pkg_agent = "TESTPKG (https://example.com)")
expected_result <- paste0(
test_dir,
c(
"/R/010-call.R",
"/tests/testthat/test-010-call.R",
"/R/paths-apis.R",
"/tests/testthat/test-paths-apis.R",
"/tests/testthat/setup.R"
)
test_result <- scrub_path(test_result)
expected_result <- c(
"/R/010-call.R",
"/tests/testthat/test-010-call.R",
"/R/paths-apis.R",
"/tests/testthat/test-paths-apis.R",
"/tests/testthat/setup.R"
)

expect_identical(test_result, expected_result)
Expand Down

0 comments on commit b5d6f88

Please sign in to comment.