paleolimbot commented on a change in pull request #12558:
URL: https://github.com/apache/arrow/pull/12558#discussion_r837832796



##########
File path: r/tests/testthat/test-safe-call-into-r.R
##########
@@ -0,0 +1,55 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+test_that("SafeCallIntoR works from the main R thread", {
+  expect_identical(
+    TestSafeCallIntoR(function() "string one!", opt = "on_main_thread"),
+    "string one!"
+  )
+
+  expect_error(
+    TestSafeCallIntoR(function() stop("an error!"), opt = "on_main_thread"),
+    "an error!"
+  )
+})
+
+test_that("SafeCallIntoR works within RunWithCapturedR", {
+  expect_identical(
+    TestSafeCallIntoR(function() "string one!", opt = "async_with_executor"),
+    "string one!"
+  )
+
+  # This runs with the expected error, but causes subsequent segfaults, 
probably related
+  # to the error_token_ (maybe having to do with the copy-constructor?)
+  # expect_error(
+  #   TestSafeCallIntoR(function() stop("an error!"), opt = 
"async_with_executor"),
+  #   "an error!"
+  # )

Review comment:
       It totally did! The gist of it was that we need to catch any 
`cpp11::unwind_exception` that is thrown when executing something on the event 
loop (the latest version has this, although it could use some more experienced 
eyes to make sure that my function wrapper is written properly).




-- 
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.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

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


Reply via email to