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
9 # http://www.apache.org/licenses/LICENSE-2.0
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
18 # Wrap testthat::test_that with a check for the C++ library
19 options(..skip.tests = !arrow:::arrow_available())
23 MAX_INT <- 2147483647L
25 # Make sure this is unset
26 Sys.setenv(ARROW_PRE_0_15_IPC_FORMAT = "")
28 # use the C locale for string collation (ARROW-12046)
29 Sys.setlocale("LC_COLLATE", "C")
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)
33 Sys.setenv(LANGUAGE = "en")
35 with_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)
43 Sys.setenv(LANGUAGE = old)
44 .cache$i18ized_error_pattern <<- NULL
46 if (!identical(before, i18ize_error_messages())) {
47 skip(paste("This OS either does not support changing languages to", lang, "or it caches translations"))
52 test_that <- function(what, code) {
53 testthat::test_that(what, {
54 skip_if(getOption("..skip.tests", TRUE), "arrow C++ library not available")
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)
61 r_only <- function(code) {
62 withr::with_options(list(..skip.tests = FALSE), code)
65 make_temp_dir <- function() {
68 normalizePath(path, winslash = "/")