Repository: apache/arrow
File: ci/scripts/r_test.sh (Shell)

Code before:
# --run-donttest was used in R < 4.0, this is used now
export _R_CHECK_DONTTEST_EXAMPLES_=TRUE
# Not all Suggested packages are needed for checking, so in case they aren't installed don't fail
export _R_CHECK_FORCE_SUGGESTS_=FALSE
export _R_CHECK_LIMIT_CORES_=FALSE
export _R_CHECK_TESTS_NLINES_=0
# This can cause failures on CRAN but needs to be set here so issues an error not a warning
export _R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS_=TRUE

# By default, aws-sdk tries to contact a non-existing local ip host
# to retrieve metadata. Disable this so that S3FileSystem tests run faster.
export AWS_EC2_METADATA_DISABLED=TRUE

# Enable memory debug checks if the env is not set already
if [ -z "${ARROW_DEBUG_MEMORY_POOL}" ]; then
  export ARROW_DEBUG_MEMORY_POOL=trap
fi

# Hack so that texlive2020 doesn't pollute the home dir
export TEXMFCONFIG=/tmp/texmf-config
export TEXMFVAR=/tmp/texmf-var

# Make sure we aren't writing to the home dir (CRAN _hates_ this but there is no official check)
BEFORE=$(ls -alh ~/)

export RETICULATE_PYTHON="$(which python3)"
SCRIPT="as_cran <- !identical(tolower(Sys.getenv('NOT_CRAN')), 'true')
  # generally will be false, but we can override it by setting SKIP_VIGNETTES=true
  skip_vignettes <- identical(tolower(Sys.getenv('SKIP_VIGNETTES')), 'true')
  if (as_cran && !skip_vignettes) {
    args <- '--as-cran'
    build_args <- character()
  } else {
    args <- c('--no-manual', '--ignore-vignettes')
    build_args <- '--no-build-vignettes'
  }

  if (!as_cran && requireNamespace('reticulate', quietly = TRUE) && reticulate::py_module_available('pyarrow')) {
      message('Running flight demo server for tests.')
      pid_flight <- sys::exec_background(
          'python',
          c(
              '-c',
              paste0(
                  '__import__(\"sys\").path.append(\"./inst\"); ',
                  '__import__(\"demo_flight_server\").DemoFlightServer(port=8089).serve()'
              )
          )
      )
      on.exit(tools::pskill(pid_flight), add = TRUE)
  }

Review comment (suggestion):
This is unrelated to the actual change in binary hosting, yeah? I'm not opposed to it, but curious about it.

Code after:
# --run-donttest was used in R < 4.0, this is used now
export _R_CHECK_DONTTEST_EXAMPLES_=TRUE
# Not all Suggested packages are needed for checking, so in case they aren't installed don't fail
export _R_CHECK_FORCE_SUGGESTS_=FALSE
export _R_CHECK_LIMIT_CORES_=FALSE
export _R_CHECK_TESTS_NLINES_=0
# This can cause failures on CRAN but needs to be set here so issues an error not a warning
export _R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS_=TRUE

# By default, aws-sdk tries to contact a non-existing local ip host
# to retrieve metadata. Disable this so that S3FileSystem tests run faster.
export AWS_EC2_METADATA_DISABLED=TRUE

# Enable memory debug checks if the env is not set already
if [ -z "${ARROW_DEBUG_MEMORY_POOL}" ]; then
  export ARROW_DEBUG_MEMORY_POOL=trap
fi

# Hack so that texlive2020 doesn't pollute the home dir
export TEXMFCONFIG=/tmp/texmf-config
export TEXMFVAR=/tmp/texmf-var

# Make sure we aren't writing to the home dir (CRAN _hates_ this but there is no official check)
BEFORE=$(ls -alh ~/)

SCRIPT="as_cran <- !identical(tolower(Sys.getenv('NOT_CRAN')), 'true')
  # generally will be false, but we can override it by setting SKIP_VIGNETTES=true
  skip_vignettes <- identical(tolower(Sys.getenv('SKIP_VIGNETTES')), 'true')
  if (as_cran && !skip_vignettes) {
    args <- '--as-cran'
    build_args <- character()
  } else {
    args <- c('--no-manual', '--ignore-vignettes')
    build_args <- '--no-build-vignettes'
  }

  if (!as_cran && requireNamespace('reticulate', quietly = TRUE) && reticulate::py_module_available('pyarrow')) {
      message('Running flight demo server for tests.')
      pid_flight <- sys::exec_background(
          'python',
          c(
              '-c',
              paste0(
                  '__import__(\"sys\").path.append(\"./inst\"); ',
                  '__import__(\"demo_flight_server\").DemoFlightServer(port=8089).serve()'
              )
          )
      )
      on.exit(tools::pskill(pid_flight), add = TRUE)
  }