1# Licensed to the Apache Software Foundation (ASF) under one 2# or more contributor license agreements. See the NOTICE file 3# distributed with this work for additional information 4# regarding copyright ownership. The ASF licenses this file 5# to you under the Apache License, Version 2.0 (the 6# "License"); you may not use this file except in compliance 7# with the License. You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, 12# software distributed under the License is distributed on an 13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14# KIND, either express or implied. See the License for the 15# specific language governing permissions and limitations 16# under the License. 17 18# Wrap testthat::test_that with a check for the C++ library 19options(..skip.tests = !arrow:::arrow_available()) 20 21set.seed(1) 22 23MAX_INT <- 2147483647L 24 25# Make sure this is unset 26Sys.setenv(ARROW_PRE_0_15_IPC_FORMAT = "") 27 28# use the C locale for string collation (ARROW-12046) 29Sys.setlocale("LC_COLLATE", "C") 30 31# Set English language so that error messages aren't internationalized 32# (R CMD check does this, but in case you're running outside of check) 33Sys.setenv(LANGUAGE = "en") 34 35with_language <- function(lang, expr) { 36 old <- Sys.getenv("LANGUAGE") 37 # Check what this message is before changing languages; this will 38 # trigger caching the transations if the OS does that (some do). 39 # If the OS does cache, then we can't test changing languages safely. 40 before <- i18ize_error_messages() 41 Sys.setenv(LANGUAGE = lang) 42 on.exit({ 43 Sys.setenv(LANGUAGE = old) 44 .cache$i18ized_error_pattern <<- NULL 45 }) 46 if (!identical(before, i18ize_error_messages())) { 47 skip(paste("This OS either does not support changing languages to", lang, "or it caches translations")) 48 } 49 force(expr) 50} 51 52test_that <- function(what, code) { 53 testthat::test_that(what, { 54 skip_if(getOption("..skip.tests", TRUE), "arrow C++ library not available") 55 code 56 }) 57} 58 59# Wrapper to run tests that only touch R code even when the C++ library isn't 60# available (so that at least some tests are run on those platforms) 61r_only <- function(code) { 62 withr::with_options(list(..skip.tests = FALSE), code) 63} 64 65make_temp_dir <- function() { 66 path <- tempfile() 67 dir.create(path) 68 normalizePath(path, winslash = "/") 69} 70