gdxmerg3.gms : Test strict mode

Description

The strict mode in gdxmerge triggers errors if input files specified
do not exist, input file pattern result in empty file lists, or if
the output file already exists.

Contributor: Michael Bussieck


Small Model of Type : GAMS


Category : GAMS Test library


Main file : gdxmerg3.gms

$title 'test gdxmerge - test strict mode' (GDXMERG3,SEQ=849)

$ontext
The strict mode in gdxmerge triggers errors if input files specified
do not exist, input file pattern result in empty file lists, or if
the output file already exists.

Contributor: Michael Bussieck
$offtext

set i / 1*100 /;
$gdxOut f1.gdx
$unLoad
$gdxOut
$call cp f1.gdx f2.gdx
$call cp f1.gdx f3.gdx

set ii / (f1*f3).#i /, Merged_set_1 / f1*f3 /;
$gdxOut mergedxxx.gdx
$unLoad ii=i Merged_set_1
$gdxOut

* First time around everything should be fine
$call rm -f merged.gdx
$call.checkErrorLevel gdxmerge f1.gdx f2.gdx f3.gdx strict=true > %system.nullfile%

* Check differences in merged and mergedxxx
$call.checkErrorLevel gdxdiff merged.gdx mergedxxx.gdx SetDesc=N > %system.nullfile%

* Test if strict mode triggers fail because of existing output file
$call gdxmerge f1.gdx f2.gdx f3.gdx strict=true > %system.nullfile%
$if not errorlevel 1 $abort Expect gdxmerge to fail because output file already exists

* After moving the output file this should succeed
$call mv -f merged.gdx xmerged.gdx
$call.checkErrorLevel gdxmerge f1.gdx f2.gdx f3.gdx strict=true > %system.nullfile%

* Test if strict mode triggers fail because of non-existing input file
$call rm -f merged.gdx
$call gdxmerge f1.gdx f2.gdx ff3.gdx strict=true > %system.nullfile%
$if not errorlevel 1 $abort Expect gdxmerge to fail because missing input file

* Test if strict mode triggers fail because of non-existing input file pattern
$call rm -f merged.gdx
$call gdxmerge *.gdx *xdg strict=true > %system.nullfile%
$if not errorlevel 1 $abort Expect gdxmerge to fail because input file pattern result in empty list