Commit fa8bafa1 authored by Dorchies David's avatar Dorchies David
Browse files

refactor: add fonction cfg_tmp_project

- copy a project in a temporary folder for tests or work
1 merge request!6Resolve "Read result simulation in sections from a binary result files"
Showing with 51 additions and 12 deletions
+51 -12
# Generated by roxygen2: do not edit by hand
export(cfg_tmp_project)
export(convert_sic_params)
export(create_section_txt)
export(create_uniform_reach_txt)
......
#' Set a configuration with a temporary project directory
#'
#' @param xml_path [character], the path of the XML SIC project file
#' @param cfg [config], the configuration to modify
#'
#' @return The updated configuration with the temporary project directory
#' @export
#'
#' @examples
#' cfg <- cfg_tmp_project()
#' cfg$project$xml_path
#'
cfg_tmp_project <- function(xml_path = system.file("sic_project_test1.xml", package = "rsic2"), cfg = loadConfig(xml_path = xml_path)) {
cfg$project$path <- tempfile("sic_project", fileext = ".xml")
file.copy(xml_path,
cfg$project$path,
overwrite = TRUE)
return(cfg)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cfg_tmp_project.R
\name{cfg_tmp_project}
\alias{cfg_tmp_project}
\title{Set a configuration with a temporary project directory}
\usage{
cfg_tmp_project(
xml_path = system.file("sic_project_test1.xml", package = "rsic2"),
cfg = loadConfig(xml_path = xml_path)
)
}
\arguments{
\item{xml_path}{\link{character}, the path of the XML SIC project file}
\item{cfg}{\link{config}, the configuration to modify}
}
\value{
The updated configuration with the temporary project directory
}
\description{
Set a configuration with a temporary project directory
}
\examples{
cfg <- cfg_tmp_project()
cfg$project$xml_path
}
# Set local configuration for SIC tests
loadLocalConfig <- function() {
xml_path <- tempfile("sic_project", fileext = ".xml")
file.copy(system.file("sic_project_test1.xml", package = "rsic2"),
xml_path,
overwrite = TRUE)
loadConfig(xml_path = xml_path)
}
skip_on_ci()
test_that("set_initial_conditions works", {
cfg <- loadLocalConfig()
cfg <- cfg_tmp_project()
sic_run_fortran("fluvia", list(SCE = 1), cfg = cfg)
set_initial_conditions(c(1, 0, 0, 1, 1), cfg = cfg)
sic_run_fortran("sirene", list(SCE = 1, VAR = 1), cfg = cfg)
......
skip_on_ci()
cfg <- loadLocalConfig()
cfg <- cfg_tmp_project()
# Minor bed generation
profT <- matrix(c(2, 6, 0, 2), ncol = 2)
......
skip_on_ci()
cfg <- loadLocalConfig()
cfg <- cfg_tmp_project()
test_that("RunExport on Fluvia run works", {
sic_run_fortran("fluvia", list(SCE = 1), cfg = cfg)
......
skip_on_ci()
cfg <- loadLocalConfig()
cfg <- cfg_tmp_project()
test_that("fluvia on SCE=1 should create a binary result file", {
sic_run_fortran("fluvia", list(SCE = 1), cfg = cfg)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment