Skip to content

Commit c780c51

Browse files
Don't check for exact error messages on CRAN
1 parent 8c0fbcd commit c780c51

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

R/testing.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,17 @@ not_conda <- function() {
273273
Sys.getenv("PRECOMMIT_INSTALLATION_METHOD") != "conda"
274274
}
275275

276+
#' Reduce a check to the empty string on CRAN
277+
#'
278+
#' In testing, we don't want to rely on exact error messages or stdout on CRAN
279+
#' for third-party packages, since this would complicate the release process for
280+
#' dependencies of \{precommit\}.
281+
#' @param string The string to test.
282+
#' @keywords internal
283+
empty_on_cran <- function(string) {
284+
ifelse(on_cran(), "", string)
285+
}
286+
276287
#' Testing utilities
277288
#'
278289
#' Similar to the `local_()` family from `{withr}`, this function creates a

man/empty_on_cran.Rd

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-hook-pkgdown.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ run_test("pkgdown",
1616
"DESCRIPTION" = "DESCRIPTION"
1717
),
1818
suffix = "",
19-
std_err = ""
19+
std_err = empty_on_cran("topic must be a known")
2020
)
2121

2222
# failed articles

tests/testthat/test-hook-roxygenize.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ run_test("roxygenize",
33
file_name = c("man/flie.Rd" = "flie.Rd"),
44
suffix = "",
55
std_err = NA,
6-
std_out = "Writing NAMESPACE",
6+
std_out = empty_on_cran("Writing NAMESPACE"),
77
artifacts = c(
88
"DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"),
99
"R/roxygenize.R" = test_path("in/roxygenize.R")
@@ -24,7 +24,7 @@ if (!on_cran()) {
2424
suffix = "",
2525
std_err = NA,
2626
cmd_args = "--root=rpkg",
27-
std_out = "Writing NAMESPACE",
27+
std_out = empty_on_cran("Writing NAMESPACE"),
2828
artifacts = c(
2929
"rpkg/DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"),
3030
"rpkg/R/roxygenize.R" = test_path("in/roxygenize.R")
@@ -79,7 +79,7 @@ run_test("roxygenize",
7979
run_test("roxygenize",
8080
file_name = c("man/flie.Rd" = "flie-true.Rd"),
8181
suffix = "",
82-
std_err = "Writing NAMESPACE",
82+
std_err = empty_on_cran("Writing NAMESPACE"),
8383
artifacts = c(
8484
"DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"),
8585
"R/roxygenize.R" = test_path("in/roxygenize.R")

0 commit comments

Comments
 (0)