testapi.gms : API Quality Assurance Test

Description

This model runs all models included in the API Library.

Contributor: Lutz Westermann, October 2014


Small Model of Type : GAMS


Category : GAMS API library


Main file : testapi.gms   includes :  apimod.inc [html]

$TITLE 'API Quality Assurance Test' (TESTAPI,SEQ=2)

$ontext
This model runs all models included in the API Library.

Contributor: Lutz Westermann, October 2014
$offtext



* Do not do anything on Testers except for Win8
$if %runAsTester%==1
$if not %sysenv.GHOST%==Win8 $exit

set tests / Cex1
            Cex2
            CPPex1*CPPex3
            CPPtrseq
            DCex1
            DOex1
            DPex1
            DOex2
            Fex1
            Fex2
            JAlias
            JBenders
            JClad
            JCutstock
            JDomainCheck
            Jex1
            Jex2
            JInterrupt
            JSpecialValues
            Jtrseq
            JTsp
            JWarehouse
            CSex1
            CSex2
            CSCalcInverse
            CStrseq
            CSAlias
            CSBenders
            CSClad
            CSCutstock
            CSDomainChecking
            CSNUnit
            CSSpecialValues
            CSTsp
            CSInterrupt
            CSWarehouse
            Pex1
            Pex2
            Ptrseq
            PAlias
            PBenders
            PClad
            PCutstock
            PDomainChecking
            PInterrupt
            PWarehouse
            PTsp
            PSpecialValues
            VBex1
            VBex2
            VBtrseq /

    suite / C 'C and CPP'
            D 'Delphi'
            F 'Fortran'
            J 'Java'
            N '.Net'
            P 'Python'    /

    st(suite, tests) / C.(Cex1,  Cex2,  CPPex1* CPPex3)
                       D.(DCex1, DOex1, DPex1,  DOex2 )
                       F.(Fex1,  Fex2)
                       J.(JAlias, JBenders, JCutstock, JDomainCheck, Jex1,  Jex2, JInterrupt, Jtrseq
$if not set demosize      ,JWarehouse, JTsp, JSpecialValues, JClad
                         )
                       N.(CSex1, CSex2, CSCalcInverse, CStrseq, CSAlias, CSBenders, CSCutstock, CSDomainChecking, CSInterrupt, CSSpecialValues
$if not set demosize             ,CSTsp ,CSWarehouse, CSClad
$if not %system.filesys% == UNIX ,CSNUnit ,VBex1, VBex2, VBtrseq, CPPtrseq
                         )
                       P.(Pex1,  Pex2, Ptrseq, PAlias, PBenders, PCutstock, PDomainChecking, PInterrupt
$if not set demosize      ,PWarehouse, PTsp, PSpecialValues, PClad
                         ) /

    pfsuite(*,suite) / deg.(C,  F,J,N,P)
                       sig.(C,  F,J    )
                       sox.(C,  F,J    )
                       leg.(C,  F,J,N,P)
$ifThen %sysenv.GHOST%==Win8
                       vs8.(C          )
                       wei.(C,  F      )
$else
                       vs8.(C,D,F,J,N,P)
                       wei.(C,  F,J,N,P)
$endIf
                     /;

$onempty
set skip(tests) List of temporary skips /
$if %system.buildcode% == DEG JClad 'pstree/kill problem, #2824'
$if %system.buildcode% == SIG JClad 'pstree missing, #2824'
$if %system.buildcode% == SOX JClad 'pstree missing, #2824'
$if %system.buildcode% == AIX CPPex1*CPPex3 'no C++ API on AIX'
$if %system.buildcode% == SIG CPPex1*CPPex3 'no C++ API on SIG'
$if %system.buildcode% == SOX CPPex1*CPPex3 'no C++ API on SOX'
$if %system.buildcode% == VS8 CPPex1*CPPex3 'no C++ API on VS8, #3226'
$if %system.buildcode% == WEI CPPex3 'cmake does not create makefiles, #3232'
/;
$offempty

$set FLAGS lo=%GAMS.lo%
$ifThen %sysenv.GHOST%==Win8
$  set FLAGS --COMPILER=GNU %FLAGS%
$endIf
$ifThen %sysenv.GHOST%==anton.gams.com
$  set FLAGS --COMPILER=GNU %FLAGS%
$endIf
$ifThen %sysenv.GHOST%==jan.local
$  set FLAGS --COMPILER=GNU %FLAGS%
$endIf
$if set demosize $set FLAGS %FLAGS% --demosize=1


$if not set TEST $goto checksuite
SET runtests(tests) / %TEST% /;
$if errorfree $goto TEST_OK
$clearerror
$log The test model(s) specified (--TEST=%TEST%) are not all valid
$abort

$label checksuite
$if not set SUITE $goto alltests
SET tsuite(suite) / %SUITE% /;
$if errorfree $goto SUITE_OK
$clearerror
$log The suite(s) specified (--SUITE=%SUITE%) are not all valid
$abort
$label SUITE_OK
SET runtests(tests);
runtests(tests) = sum{st(tsuite,tests),yes};
$goto TEST_OK

$label alltests
SET runtests(tests);
runtests(tests) = yes;
$label TEST_OK

*Not done for all platforms yet
$if %system.buildcode% == AIX $exit

scalar
  tot    / 0 /,
  err    / 0 /,
  cnt    / 0 /;

file fall / 'all_api.gms'      /
     ferr / 'failures_api.gms' /
     rmme / 'rmme.gms'         /
     log  / ''                 /
     fx;

putclose fall '* These are the tests we ran' /;
putclose ferr '* These are the tests that failed' /;
fall.ap = 1;
ferr.ap = 1;

$if not set PREFIX $set PREFIX %system.buildcode%
$set DIRNAME "'%PREFIX%_api_' tests.tl:0 "

loop(runtests(tests)$(sum(pfsuite('%system.buildcode%',suite)$st(suite,tests),1) and not skip(tests)),
  tot = tot + 1;
  put_utility fx 'shell' / 'rm -rf ' %DIRNAME%;
  put_utility fx 'shell' / 'mkdir ' %DIRNAME%;
  put_utility fx 'shell' / 'cd ' %DIRNAME% ' && apilib ' tests.tl:0 ' && gams ' tests.tl:0 ' %FLAGS% > stdout.txt 2>stderr.txt';
  if(errorlevel,
    err = err + 1;
    putclose ferr '$call =gams testapi --test=' tests.tl:0 ' %FLAGS% --dir='%DIRNAME% /;
 else
    put_utility fx 'shell' / 'rm -rf ' %DIRNAME%;
  );
  putclose fall '$call =gams testapi --test=' tests.tl:0 ' %FLAGS% --dir='%DIRNAME% /;
);


putclose ferr '*Total tests: ', tot:0:0, '  Failed tests: ', err:0:0 ;

put log;
if {(err > 0),
  put 'There were errors: ', err:0:0, ' out of ',
       tot:0:0, ' tests failed.' /;
  put 'See the file failures_api.gms to reproduce the failed runs'/;
  put 'You have some failures. See failures_api.gms for details.';
else
  put 'Congratulations!  All ', tot:0:0, ' tests passed.'/;
};

put 'See the file all_api.gms to reproduce all the runs'/;