procdir1.gms : Test correct behavior of procDir, scrDir and procDirPath

Description

Contributor: Clemens Westphal, January 2017


Small Model of Type : GAMS


Category : GAMS Test library


Main file : procdir1.gms

$Title 'Test correct behavior of procDir, scrDir and procDirPath'  (PROCDIR1,SEQ=715)

$ontext
Contributor: Clemens Westphal, January 2017
$offtext

$set scriptExt cmd
$If %system.filesys% == UNIX $set scriptExt sh

*clean up directories that might still exist from previous runs
$call rm -rf pDir
$call rm -rf sDir
$call rm -rf pDirPath
$call rm -rf 225b

*get transport as example model
$call gamslib -q trnsport
$if errorlevel 1 $abort 'Error retrieving transport model'

*Test keep=1
$call gams trnsport.gms keep=1 lo=%GAMS.lo%
$if errorlevel 1 $abort 'Error calling GAMS'
$If not dexist 225b $abort 'keep=1: Expected directory 225b to exist'
$If not exist 225b/gamscntr.dat $abort 'keep=1: Expected file 225a/gamscntr.dat to exist'
$call rm -rf 225b

*Test procDir
$call mkdir pDir
$call gams trnsport.gms procDir=pDir lo=%GAMS.lo%
$if errorlevel 1 $abort 'Error calling GAMS'
$If not exist pDir/gamscntr.dat $abort 'procDir: Expected file pDir/gamscntr.dat to exist'
$If not exist pDir/gamsnext.%scriptExt% $abort 'procDir: Expected file pDir/gamsnext.%scriptExt% to exist'
$call rm -rf pDir

*Test procDir and scrDir
$call mkdir pDir
$call mkdir sDir
$call gams trnsport.gms procDir=pDir scrDir=sDir lo=%GAMS.lo%
$if errorlevel 1 $abort 'Error calling GAMS'
$If not exist sDir/gamscntr.dat $abort 'procDir and scrDir: Expected file sDir/gamscntr.dat to exist'
$If not exist pDir/gamsnext.%scriptExt% $abort 'procDir and scrDir: Expected file pDir/gamsnext.%scriptExt% to exist'
$call rm -rf pDir
$call rm -rf sDir

*Test procDirPath
$call mkdir pDirPath
$call gams trnsport.gms procDirPath=pDirPath lo=%GAMS.lo%
$if errorlevel 1 $abort 'Error calling GAMS'
$If dexist pDirPath/225a $abort 'procDirPath: Expected directory pDirPath/225a to be deleted'
$call rm -rf pDirPath

*Test procDirPath and keep=1
$call mkdir pDirPath
$call gams trnsport.gms procDirPath=pDirPath keep=1 lo=%GAMS.lo%
$if errorlevel 1 $abort 'Error calling GAMS'
$If not dexist pDirPath/225a $abort 'procDirPath and keep=1: Expected directory pDirPath/225a to exist'
$If dexist 225b $abort 'procDirPath and keep=1: Expected directory 225b not to exist since scrDir is derived from procDirPath'
$call rm -rf pDirPath

*Test procDirPath and scrDir
$call mkdir pDirPath
$call mkdir sDir
$call gams trnsport.gms procDirPath=pDirPath scrDir=sDir lo=%GAMS.lo%
$if errorlevel 1 $abort 'Error calling GAMS'
$If dexist pDirPath/225a $abort 'procDirPath and scrDir: Expected directory pDirPath/225a to be deleted'
$If not exist sDir/gamscntr.dat $abort 'procDirPath and scrDir: Expected sDir/gamscntr.dat to exist'
$call rm -rf pDirPath
$call rm -rf sDir

*Test procDirPath and procDir with absolute path -> should create an error
$call mkdir pDirPath
$call gams trnsport.gms procDirPath=pDirPath procDir="%gams.curdir%pDirPath" lo=%GAMS.lo%
$if not errorlevel 1 $abort 'Expected error calling GAMS'