This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new fdecb6a0be GH-38049: [R] Prevent `on_rosetta()` from warning (#38052)
fdecb6a0be is described below
commit fdecb6a0bee5fb482705de14c161853fe2ea2b41
Author: Jonathan Keane <[email protected]>
AuthorDate: Fri Oct 6 09:21:31 2023 -0500
GH-38049: [R] Prevent `on_rosetta()` from warning (#38052)
### Rationale for this change
Stop extraneous warnings.
### What changes are included in this PR?
Prevent warning when detecting translation, but on x86
### Are these changes tested?
Yes
### Are there any user-facing changes?
Yes, there will be fewer extraneous warnings.
* Closes: #38049
Authored-by: Jonathan Keane <[email protected]>
Signed-off-by: Dewey Dunnington <[email protected]>
---
r/R/arrow-package.R | 5 +++--
r/tests/testthat/test-arrow-pacakge.R | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/r/R/arrow-package.R b/r/R/arrow-package.R
index 09183250ba..54218bbf85 100644
--- a/r/R/arrow-package.R
+++ b/r/R/arrow-package.R
@@ -183,7 +183,7 @@ configure_tzdb <- function() {
# Just to be extra safe, let's wrap this in a try();
# we don't want a failed startup message to prevent the package from loading
try({
- # On MacOS only, Check if we are running in under emulation, and warn
this will not work
+ # On MacOS only, Check if we are running in under emulation, and warn this
will not work
if (on_rosetta()) {
packageStartupMessage(
paste(
@@ -242,8 +242,9 @@ on_macos_10_13_or_lower <- function() {
}
on_rosetta <- function() {
+ # make sure to suppress warnings and ignore the stdout + stderr so that this
is silent
identical(tolower(Sys.info()[["sysname"]]), "darwin") &&
- identical(system("sysctl -n sysctl.proc_translated", intern = TRUE), "1")
+ identical(suppressWarnings(system("sysctl -n sysctl.proc_translated",
intern = TRUE, ignore.stderr = TRUE, ignore.stdout = TRUE)), "1")
}
option_use_threads <- function() {
diff --git a/r/tests/testthat/test-arrow-pacakge.R
b/r/tests/testthat/test-arrow-pacakge.R
new file mode 100644
index 0000000000..2d79467fa3
--- /dev/null
+++ b/r/tests/testthat/test-arrow-pacakge.R
@@ -0,0 +1,21 @@
+# 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("on_rosetta() does not warn", {
+ # There is no warning
+ expect_warning(on_rosetta(), NA)
+})