Description
This test ensures that certain (error) messages are written to the log (and not to stdOut). It also tests that the log file written to the expected location - and only to that. Contributor: Lutz Westermann, May 2025 Check for error messages
Small Model of Type : GAMS
Category : GAMS Test library
Main file : lo01.gms
$title 'Test log behavior' (LO01,SEQ=986)
$onText
This test ensures that certain (error) messages are written to the log
(and not to stdOut).
It also tests that the log file written to the expected location - and only to that.
Contributor: Lutz Westermann, May 2025
$offText
*********************************************************
* Check for error messages
*********************************************************
$onEcho > test.gms
Scalar h;
Variable v;
Equation e;
e.. v =e= 0;
Model m /e/;
option SolveLink=3;
solve m min v use lp;
h = m.handle;
display$ReadyCollect(h) 'wait';
display$HandleCollect(h) 'done';
* By skipping this, certain "Delete file ..." messages were printed to stdOut in the past
*display$HandleDelete(h) 'done';
$offEcho
$call.checkErrorLevel gams test.gms lo=2
$call.checkErrorLevel grep -iw Delete test.log > %system.NullFile%
*********************************************************
* Check for log location with relative curDir and wDir
*********************************************************
$call.checkErrorLevel gamslib -q trnsport
$call.checkErrorLevel rm -rf a b
$call.checkErrorLevel mkdir a b a%system.DirSep%b
$call.checkErrorLevel cp trnsport.gms a
$call.checkErrorLevel cp trnsport.gms b
$call.checkErrorLevel mv trnsport.gms a%system.DirSep%b
$call.checkErrorLevel gams trnsport curdir=a wdir=b filestem=notTrnsport lo=2
$if not exist a%system.DirSep%b%system.DirSep%notTrnsport.log $abort log file should be in curDir/wDir
$if exist a%system.DirSep%b%system.DirSep%trnsport.log $abort log file should be in curDir/wDir respecting filestem
$if exist a%system.DirSep%notTrnsport.log $abort log file should be in curDir/wDir only
$if exist b%system.DirSep%notTrnsport.log $abort log file should be in curDir/wDir only
$if exist notTrnsport.log $abort log file should be in curDir/wDir only
$call.checkErrorLevel gams trnsport curdir=a wdir=b lo=2
$if not exist a%system.DirSep%b%system.DirSep%trnsport.log $abort log file should be in curDir/wDir
$if exist a%system.DirSep%trnsport.log $abort log file should be in curDir/wDir only
$if exist b%system.DirSep%trnsport.log $abort log file should be in curDir/wDir only
$if exist trnsport.log $abort log file should be in curDir/wDir only
$call.checkErrorLevel gams trnsport curdir=a lo=2
$if not exist a%system.DirSep%trnsport.log $abort log file should be in curDir
$if exist trnsport.log $abort log file should be in curDir only
$call.checkErrorLevel gams trnsport wdir=b lo=2
$if not exist b%system.DirSep%trnsport.log $abort log file should be in wDir
$if exist trnsport.log $abort log file should be in wDir only
*********************************************************
* Check for log location with absolute curDir and wDir
*********************************************************
$call.checkErrorLevel gamslib -q trnsport
$call.checkErrorLevel rm -rf a b c
$call.checkErrorLevel mkdir a b c
$call.checkErrorLevel cp trnsport.gms a
$call.checkErrorLevel cp trnsport.gms b
$call.checkErrorLevel mv trnsport.gms c
$call.checkErrorLevel gams trnsport curdir="%gams.workdir%%system.DirSep%a" wdir="%gams.workdir%%system.DirSep%c" filestem=notTrnsport lo=2
$if not exist c%system.DirSep%notTrnsport.log $abort log file should be in wDir
$if exist c%system.DirSep%trnsport.log $abort log file should be in wDir respecting filestem
$if exist a%system.DirSep%notTrnsport.log $abort log file should be in wDir only
$if exist notTrnsport.log $abort log file should be in wDir only
$call.checkErrorLevel 'gams trnsport curdir="%gams.workdir%%system.DirSep%a" wdir="%gams.workdir%%system.DirSep%c" lo=2'
$if not exist c%system.DirSep%trnsport.log $abort log file should be in wDir
$if exist a%system.DirSep%trnsport.log $abort log file should be in wDir only
$if exist trnsport.log $abort log file should be in wDir only
$call.checkErrorLevel 'gams trnsport curdir="%gams.workdir%%system.DirSep%a" lo=2'
$if not exist a%system.DirSep%trnsport.log $abort log file should be in curDir
$if exist trnsport.log $abort log file should be in curDir only
$call.checkErrorLevel 'gams trnsport wdir="%gams.workdir%%system.DirSep%b" lo=2'
$if not exist b%system.DirSep%trnsport.log $abort log file should be in wDir
$if exist trnsport.log $abort log file should be in wDir only
*********************************************************
* Check for log (and other) name when setting fileStem
*********************************************************
$call.checkErrorLevel gamslib -q trnsport
$call.checkErrorLevel gams trnsport filestem=notTrnsport lo=2 gdx=default rf=default
$if exist trnsport.log $abort log file ignored fileStem
$if exist trnsport.lst $abort lst file ignored fileStem
$if exist trnsport.gdx $abort gdx file ignored fileStem
$if exist trnsport.ref $abort ref file ignored fileStem
$if not exist notTrnsport.log $abort log file ignored fileStem
$if not exist notTrnsport.lst $abort lst file ignored fileStem
$if not exist notTrnsport.gdx $abort gdx file ignored fileStem
$if not exist notTrnsport.ref $abort ref file ignored fileStem