Blame agen5/test/directives.test

Packit Service 96b5d3
#! /bin/sh
Packit Service 96b5d3
#  -*- Mode: Shell-script -*-
Packit Service 96b5d3
# directives.test --- test definition directives
Packit Service 96b5d3
#
Packit Service 96b5d3
# Author:            Bruce Korb <bkorb@gnu.org>
Packit Service 96b5d3
##
Packit Service 96b5d3
## This file is part of AutoGen.
Packit Service 96b5d3
## AutoGen Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
Packit Service 96b5d3
##
Packit Service 96b5d3
## AutoGen is free software: you can redistribute it and/or modify it
Packit Service 96b5d3
## under the terms of the GNU General Public License as published by the
Packit Service 96b5d3
## Free Software Foundation, either version 3 of the License, or
Packit Service 96b5d3
## (at your option) any later version.
Packit Service 96b5d3
##
Packit Service 96b5d3
## AutoGen is distributed in the hope that it will be useful, but
Packit Service 96b5d3
## WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 96b5d3
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Packit Service 96b5d3
## See the GNU General Public License for more details.
Packit Service 96b5d3
##
Packit Service 96b5d3
## You should have received a copy of the GNU General Public License along
Packit Service 96b5d3
## with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit Service 96b5d3
##
Packit Service 96b5d3
#
Packit Service 96b5d3
# ----------------------------------------------------------------------
Packit Service 96b5d3
Packit Service 96b5d3
. ./defs
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # TEMPLATE FILE # # # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
mkdir ${testname}.dir
Packit Service 96b5d3
mkdir ${testname}.dir/subdir
Packit Service 96b5d3
LDIR=`pwd`/${testname}.dir
Packit Service 96b5d3
export LDIR
Packit Service 96b5d3
Packit Service 96b5d3
echo creating ${testname}.dir/subdir/${testname}.tpl
Packit Service 96b5d3
cat > ${testname}.dir/subdir/${testname}.tpl <<'_EOF_'
Packit Service 96b5d3
[= AutoGen5 Template test =]
Packit Service 96b5d3
Irrelevant [=foo=].
Packit Service 96b5d3
_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # DEFINITIONS FILE # # # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
echo creating ${testname}.inc
Packit Service 96b5d3
${SED} 's/^ *[0-9]*: //' > ${testname}.inc <<_EOF_
Packit Service 96b5d3
      1: autogen definitions ${testname};
Packit Service 96b5d3
      2: 
Packit Service 96b5d3
      3: #option templ-dir \$LDIR/subdir
Packit Service 96b5d3
      4: 
Packit Service 96b5d3
      5: /*
Packit Service 96b5d3
      6: #define COMMENT
Packit Service 96b5d3
      7: #ifdef COMMENT
Packit Service 96b5d3
      8: # error error in comment
Packit Service 96b5d3
      9:  */
Packit Service 96b5d3
     10: 
Packit Service 96b5d3
     11: #ifdef MUMBLE
Packit Service 96b5d3
     12: #  define MORE
Packit Service 96b5d3
     13: #else
Packit Service 96b5d3
     14: #  define FUMBLE
Packit Service 96b5d3
     15: #endif
Packit Service 96b5d3
_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
echo creating ${testname}.def
Packit Service 96b5d3
${SED} 's/^ *[0-9]*: //' > ${testname}.def <<_EOF_
Packit Service 96b5d3
      1: autogen definitions ${testname};
Packit Service 96b5d3
      2: 
Packit Service 96b5d3
      3: #include ${testname}.inc
Packit Service 96b5d3
      4: 
Packit Service 96b5d3
      5: #ifdef FUMBLE
Packit Service 96b5d3
      6: #  error  we fumbled mumble
Packit Service 96b5d3
      7: #endif
Packit Service 96b5d3
      8: 
Packit Service 96b5d3
      9: #ifndef MORE
Packit Service 96b5d3
     10: #  error  we fumbled more
Packit Service 96b5d3
     11: #endif
Packit Service 96b5d3
     12: 
Packit Service 96b5d3
     13: #if (FOO == 1)
Packit Service 96b5d3
     14: #  error we got iffed
Packit Service 96b5d3
     15: #elif (FOO == 0)
Packit Service 96b5d3
     16: #  error we got FOO zeroed
Packit Service 96b5d3
     17: #else
Packit Service 96b5d3
     18: #  error we got lost
Packit Service 96b5d3
     19: #endif
Packit Service 96b5d3
     20: 
Packit Service 96b5d3
     21: #shell
Packit Service 96b5d3
     22: 
Packit Service 96b5d3
     23: echo "#line 1 shelltext"
Packit Service 96b5d3
     24: echo "foo = bar;"
Packit Service 96b5d3
     25: 
Packit Service 96b5d3
     26: #endshell
Packit Service 96b5d3
     27: 
Packit Service 96b5d3
     28: #define FUMBLE
Packit Service 96b5d3
     29: #undef  MORE
Packit Service 96b5d3
     30: 
Packit Service 96b5d3
     31: #ifndef FUMBLE
Packit Service 96b5d3
     32: #  error  we goofed fumble
Packit Service 96b5d3
     33: #endif
Packit Service 96b5d3
     34: 
Packit Service 96b5d3
     35: #ifdef MORE
Packit Service 96b5d3
     36: #  error  we mumbled more
Packit Service 96b5d3
     37: #endif
Packit Service 96b5d3
_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
echo creating ${testname}.base
Packit Service 96b5d3
# this is the output we should expect to see
Packit Service 96b5d3
cat > ${testname}.base <<_EOF_
Packit Service 96b5d3
Irrelevant bar.
Packit Service 96b5d3
_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
agopts="-DMUMBLE -DFOO=1"
Packit Service 96b5d3
MORE=DOITWRONG
Packit Service 96b5d3
Packit Service 96b5d3
run_ag x1 ${agopts} ${testname}.def
Packit Service 96b5d3
test $? -eq 0 || failure ${agopts}-1 failed
Packit Service 96b5d3
cmp -s ${testname}.base ${testname}.test || \
Packit Service 96b5d3
  failure "`diff ${testname}.base ${testname}.test`"
Packit Service 96b5d3
Packit Service 96b5d3
echo '#assert `echo true`' >> ${testname}.inc
Packit Service 96b5d3
run_ag x2 ${agopts} ${testname}.def
Packit Service 96b5d3
test $? -eq 0 || failure ${agopts}-2 failed
Packit Service 96b5d3
Packit Service 96b5d3
echo '#assert `echo false`' >> ${testname}.inc
Packit Service 96b5d3
run_ag x3 ${agopts} ${testname}.def
Packit Service 96b5d3
test $? -ne 0 || failure ${agopts}-3 failed
Packit Service 96b5d3
Packit Service 96b5d3
${FGREP} -v '#assert' ${testname}.inc > ${testname}2.inc
Packit Service 96b5d3
mv -f ${testname}2.inc ${testname}.inc
Packit Service 96b5d3
Packit Service 96b5d3
echo '#assert (version-compare > autogen-version "5.8.4")' >> ${testname}.inc
Packit Service 96b5d3
run_ag x4 ${agopts} ${testname}.def
Packit Service 96b5d3
test $? -eq 0 || failure ${agopts}-4 failed
Packit Service 96b5d3
Packit Service 96b5d3
echo '#assert (version-compare < autogen-version "5.8.4.63")' >> ${testname}.inc
Packit Service 96b5d3
run_ag x5 ${agopts} ${testname}.def
Packit Service 96b5d3
test $? -ne 0 || failure ${agopts}-5 failed
Packit Service 96b5d3
Packit Service 96b5d3
cleanup
Packit Service 96b5d3
Packit Service 96b5d3
## Local Variables:
Packit Service 96b5d3
## mode: shell-script
Packit Service 96b5d3
## indent-tabs-mode: nil
Packit Service 96b5d3
## sh-indentation: 2
Packit Service 96b5d3
## sh-basic-offset: 2
Packit Service 96b5d3
## End:
Packit Service 96b5d3
Packit Service 96b5d3
# end of directives.test