tests/testthat/helper-init.R

#Copyright © 2016 RTE Réseau de transport d’électricité

# Copy the test study in a temporary folder

path <- tempdir()

sourcedir <- system.file("inst/testdata", package = "antaresRead")
if(sourcedir == ""){sourcedir <- system.file("testdata", package = "antaresRead")}


# Hack: For some unknown reason, this script is executed at some point of
# the R CMD CHECK before package is correctly installed and tests actually run.
# The following "if" prevents errors at this step
if (sourcedir != "") {
  if (Sys.info()['sysname'] == "Windows") {
    untar(file.path(sourcedir, "antares-test-study.tar.gz"), exdir = path,
          extras = "--force-local")
  } else {
    untar(file.path(sourcedir, "antares-test-study.tar.gz"), exdir = path)
  }
  
  assign("studyPath", file.path(path, "test_case"), envir = globalenv())
  assign("nweeks", 2, envir = globalenv())
  assign("pathtemp", path, envir = globalenv())
}

setSimulationPath(get("studyPath", envir = globalenv()))
rte-antares-rpackage/bpN documentation built on May 31, 2019, 2:52 p.m.