Copilot commented on code in PR #49996:
URL: https://github.com/apache/arrow/pull/49996#discussion_r3510310113
##########
r/R/arrow-package.R:
##########
@@ -189,7 +196,6 @@ configure_tzdb <- function() {
packageStartupMessage(
"The tzdb package was available but failed to initialize: ",
e,
- "Timezones will not be available to Arrow compute functions."
)
}
Review Comment:
The error handler in configure_tzdb() now calls packageStartupMessage() with
a trailing comma after `e`, which is a syntax error in R and will break package
loading.
##########
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)
Review Comment:
With `set -euo pipefail`, `tgz_file=$(ls ... | head -1)` will exit the
script when no files match because `ls` returns non-zero and pipefail
propagates it. The explicit empty-string check below will never run.
##########
ci/scripts/r_wasm_test.cjs:
##########
@@ -0,0 +1,165 @@
+// 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));
+ if (!filePath.startsWith(path.resolve(repoDir))) {
+ res.writeHead(403);
+ res.end();
+ return;
+ }
Review Comment:
`path.join(repoDir, decodeURIComponent(req.url))` will ignore repoDir for
absolute URLs (req.url starts with '/'), causing all requests to fail the
startsWith() check and return 403. Also, the prefix check should use a
normalized/absolute path with a path-separator boundary to avoid traversal edge
cases.
--
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]