thisisnic commented on a change in pull request #9909:
URL: https://github.com/apache/arrow/pull/9909#discussion_r611436837



##########
File path: r/tests/testthat/helper-expectation.R
##########
@@ -98,12 +103,34 @@ expect_dplyr_equal <- function(expr, # A dplyr pipeline 
with `input` as its star
 expect_dplyr_error <- function(expr, # A dplyr pipeline with `input` as its 
start
                                tbl,  # A tbl/df as reference, will make 
RB/Table with
                                ...) {
+  # ensure we have supplied tbl
+  force(tbl)
+  
   expr <- rlang::enquo(expr)
   msg <- tryCatch(
     rlang::eval_tidy(expr, rlang::new_data_mask(rlang::env(input = tbl))),
-    error = function (e) conditionMessage(e)
+    error = function (e) {
+          msg <- conditionMessage(e)
+
+      # The error here is of the form:
+      #
+      # Problem with `filter()` input `..1`.
+      # x object 'b_var' not found
+      # ℹ Input `..1` is `chr == b_var`.
+      #
+      # but what we really care about is the `x` block
+      # so (temporarily) let's pull those blocks out when we find them
+      if (grepl("object '.*'.not.found", msg)) {
+        return(gsub("^.*(object '.*'.not found).*$", "\\1", msg))
+      }
+      if (grepl('could not find function ".*"', msg)) {
+        return(gsub('^.*(could not find function ".*").*$', "\\1", msg))
+      }
+      invisible(structure(msg, class = "try-error", condition = e))

Review comment:
       Thanks! Will give this a go.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to