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

$set XX NT
$if %system.filesys% == UNIX $set XX un

*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/gmsprm%XX%.dat $abort 'keep=1: Expected file 225b/gmsprm%XX%.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/gmsprm%XX%.dat $abort 'procDir: Expected file pDir/gmsprm%XX%.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/gamsstat.dat $abort 'procDir and scrDir: Expected file sDir/gamsstat.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/gamsstat.dat $abort 'procDirPath and scrDir: Expected sDir/gamsstat.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'