R Under development (unstable) (2024-01-28 r85838 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## Write a test for running APSIM only under Windows > require(apsimx) Loading required package: apsimx APSIM(X) not found. If APSIM(X) is installed in an alternative location, set paths manually using 'apsimx_options' or 'apsim_options'. You can still try as the package will look into the registry (under Windows) > apsim_options(warn.versions = FALSE) > > ## This needs windows and APSIM Classic > run.classic.examples <- grepl("windows", Sys.info()[["sysname"]], ignore.case = TRUE) && get(".run.local.tests", envir = apsimx.options) > > tmp.dir <- tempdir() > setwd(tmp.dir) > > if(run.classic.examples){ + + ade <- auto_detect_apsim_examples() + + ex <- list.files(path = ade, pattern = ".apsim$") + ## Will only run a few + ex.to.run <- c("Canopy","Centro","Millet","Potato","Sugar") + + for(i in ex.to.run){ + tmp <- apsim_example(i) + cat("Ran (apsim_example):",i,"\n") + } + + ## Test examples individually + ## Note: this will not work unless tmp.dir is the current directory + ## because of a bug in APSIM + for(i in ex.to.run){ + file.copy(paste0(ade,"/",i,".apsim"), tmp.dir) + tmp <- apsim(paste0(i,".apsim"), cleanup = TRUE) + file.remove(paste0(tmp.dir,"/",i,".apsim")) + cat("Ran (apsim):",i,"\n") + } + } > > proc.time() user system elapsed 0.96 0.21 1.15