From e1c8cabd66567ed4c7ca9f5262dea8574961c096 Mon Sep 17 00:00:00 2001 From: asardaes Date: Sun, 1 Mar 2020 18:18:45 +0100 Subject: [PATCH] Allow exceptions with unknown reason on CRAN's tests See RcppCore/Rcpp#972 --- DESCRIPTION | 1 + tests/testthat/setup-expect_error.R | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/testthat/setup-expect_error.R diff --git a/DESCRIPTION b/DESCRIPTION index 11221d0..efc81cd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,6 +22,7 @@ LinkingTo: RcppParallel, RcppThread Suggests: + rlang, testthat Date: 2020-03-01 Authors@R: c( diff --git a/tests/testthat/setup-expect_error.R b/tests/testthat/setup-expect_error.R new file mode 100644 index 0000000..0817ff4 --- /dev/null +++ b/tests/testthat/setup-expect_error.R @@ -0,0 +1,15 @@ +if (!identical(Sys.getenv("NOT_CRAN"), "true")) { + # see https://github.com/RcppCore/Rcpp/issues/972 + # what is mentioned there happened on r-devel-fedora-clang + expect_error <- function(...) { + e <- rlang::enexprs(...) + + if (is.null(e$regexp)) { + testthat::expect_error(...) + } + else { + e$regexp <- glue::glue("[unknown reason|{ e$regexp }]") + eval(rlang::call2("expect_error", .ns = "testthat", !!!e)) + } + } +}