Copilot commented on code in PR #49996:
URL: https://github.com/apache/arrow/pull/49996#discussion_r3510086850
##########
r/R/arrow-package.R:
##########
@@ -182,19 +189,35 @@ configure_tzdb <- function() {
tryCatch(
{
tzdb::tzdb_initialize()
- set_timezone_database(tzdb::tzdb_path("text"))
+ tz_path <- tzdb::tzdb_path("text")
+ packageStartupMessage("[configure_tzdb] tzdb path: ", tz_path)
Review Comment:
`configure_tzdb()` now emits multiple startup messages (including listing
tzdb contents) and does a recursive `list.files()` on every package load. This
is both user-facing output (contradicting the PR's "no user-facing changes")
and potentially expensive, especially in Wasm/webR. Consider only emitting
these diagnostics when `getOption("arrow.debug", TRUE)` is enabled, and avoid
the recursive file listing by default.
##########
r/tests/testthat/helper-skip.R:
##########
@@ -101,6 +101,10 @@ skip_on_linux_devel <- function() {
}
}
+skip_on_emscripten <- function() {
+ skip_if(identical(R.version$os, "emscripten"), "Not supported on Emscripten")
+}
Review Comment:
Other skip helpers in this file honor `force_tests()` so developers/CI can
override skips via `ARROW_R_FORCE_TESTS=true`. `skip_on_emscripten()` currently
doesn't, which makes it impossible to force these tests to run under Emscripten
when needed.
##########
ci/scripts/r_wasm_test.sh:
##########
@@ -0,0 +1,80 @@
+#!/usr/bin/env bash
+# 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 the arrow R package built for WebAssembly.
+#
+# This script is intended to run inside the ghcr.io/r-universe-org/build-wasm
+# Docker container after rwasm::build() has produced a .tgz binary. It:
+# 1. Sets up a CRAN-like repo structure from the built .tgz
+# 2. Installs the npm webr package (Node.js webR runtime)
+# 3. Boots webR, installs arrow from the local repo, and verifies:
+# - The package can be installed and loaded
+# - Multithreading is disabled (arrow.use_threads == FALSE)
+# - The testthat test suite runs
+#
+# Tests that require threading are automatically skipped via
+# skip_if_not(CanRunWithCapturedR()) since CanRunWithCapturedR() returns
+# FALSE under Emscripten.
+#
+# Usage:
+# r_wasm_test.sh <path-to-arrow-r-dir>
+#
+# Example:
+# r_wasm_test.sh /work
+#
+# The arrow .tgz file(s) should already exist in <path-to-arrow-r-dir>.
+
+set -euxo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+arrow_r_dir="${1:-.}"
+
+# Set up a fake CRAN-like repo so we can install the package
+tgz_file=$(ls "${arrow_r_dir}"/arrow_*.tgz 2>/dev/null | head -1)
+if [ -z "${tgz_file}" ]; then
+ echo "ERROR: No arrow_*.tgz found in ${arrow_r_dir}" >&2
+ exit 1
+fi
Review Comment:
With `set -euo pipefail`, the `ls | head` pipeline will cause the script to
exit immediately when no files match (because `ls` returns non-zero), so the
custom "No arrow_*.tgz" error message is never reached. Make the pipeline
non-fatal so the subsequent check can run.
##########
ci/scripts/r_wasm_test.cjs:
##########
@@ -0,0 +1,160 @@
+// 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.
+
+// Smoke-test the arrow R package under webR, then run the testthat suite.
+// Called by r_wasm_test.sh. Requires env vars:
+// ARROW_WASM_REPO_DIR - local CRAN-like repo with the arrow .tgz
+// ARROW_R_TESTS_DIR - path to tests/testthat in the source tree
+
+const { WebR } = require("webr");
+const http = require("http");
+const fs = require("fs");
+const path = require("path");
+
+const repoDir = process.env.ARROW_WASM_REPO_DIR;
+if (!repoDir) {
+ console.error("ERROR: ARROW_WASM_REPO_DIR not set");
+ process.exit(1);
+}
+
+const testsDir = process.env.ARROW_R_TESTS_DIR;
+if (!testsDir) {
+ console.error("ERROR: ARROW_R_TESTS_DIR not set");
+ process.exit(1);
+}
+
+function listFilesRecursive(dir) {
+ const results = [];
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
+ const full = path.join(dir, entry.name);
+ if (entry.isDirectory()) {
+ results.push(...listFilesRecursive(full));
+ } else {
+ results.push(full);
+ }
+ }
+ return results;
+}
+
+async function main() {
+ // Serve the repo over HTTP (webR can't access the host filesystem directly)
+ const server = http.createServer((req, res) => {
+ const filePath = path.join(repoDir, decodeURIComponent(req.url));
+ fs.readFile(filePath, (err, data) => {
+ if (err) {
+ res.writeHead(404);
+ res.end();
+ } else {
+ res.writeHead(200);
+ res.end(data);
+ }
+ });
+ });
Review Comment:
The HTTP server path construction is unsafe and also breaks routing:
`path.join(repoDir, req.url)` will ignore `repoDir` when `req.url` starts with
`/`, and it also allows `..` traversal to read arbitrary files. Normalize the
URL pathname, strip leading slashes, resolve it under `repoDir`, and reject
requests that escape the repo root.
##########
r/inst/build_arrow_static.sh:
##########
@@ -114,7 +114,7 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \
-G "${CMAKE_GENERATOR:-Unix Makefiles}" \
${SOURCE_DIR}
-${CMAKE} --build . --target install -- -j $N_JOBS
+MAKEFLAGS="-j$N_JOBS" ${CMAKE} --build . --target install
Review Comment:
Using `MAKEFLAGS` to control parallelism only affects Make-based generators.
If `CMAKE_GENERATOR` is set to Ninja (or others), this will likely fall back to
a single-threaded build and slow down CI/builds. Prefer CMake's
generator-agnostic parallel flag.
##########
r/tests/testthat/test-dplyr-filter.R:
##########
@@ -415,6 +415,8 @@ test_that("filter() with namespaced functions", {
})
test_that("filter() with across()", {
+ skip_on_emscripten() # TODO(xxx): need to figure out what warnings this
throws
Review Comment:
The `TODO(xxx)` placeholder isn't actionable/traceable. If this skip is
temporary, it should reference an issue/PR (e.g., GH-49995) or at least
describe the exact warnings to investigate.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]