gcamdata icon indicating copy to clipboard operation
gcamdata copied to clipboard

Make consistent checking gcamdata package options

Open pralitp opened this issue 7 years ago • 0 comments

We have the need to control package options for a number of reasons: if we have Java, which tests can be run where, etc. However we have not always been consistent with how we expect a user to set those options nor what to set them to.

For instance we sometimes simply check if(!is.null(getOption('gcamdata.validate_with_compdata'))) while other times we are a bit more rigorous about coercing to logical: if(isTRUE(as.logical(Sys.getenv("gcamdata.is_coverage_test")))).

And finally we have a hybrid where we check the system environment in onload.R:

# onload.R

.onLoad <- function(libname, pkgname) {
  op <- options()
  op.gcamdata <- list(
    gcamdata.use_java = isTRUE(as.logical(Sys.getenv("GCAMDATA_USE_JAVA")))
  )
  toset <- !(names(op.gcamdata) %in% names(op))
  if(any(toset)) {
    options(op.gcamdata[toset])
  }
  invisible()
}

pralitp avatar May 24 '18 16:05 pralitp