#! /bin/sh # -*- Mode: Shell-script -*- # ---------------------------------------------------------------------- # error.test --- test error functionality # # Author: Bruce Korb # Time-stamp: "2007-07-04 11:29:36 bkorb" # by: bkorb ## ## This file is part of AutoGen. ## AutoGen copyright (c) 1992-2007 by Bruce Korb - all rights reserved ## ## AutoGen is free software: you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by the ## Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## AutoGen is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ## See the GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License along ## with this program. If not, see . ## # # $Id: error.test,v 4.17 2007/07/04 20:51:13 bkorb Exp $ # ---------------------------------------------------------------------- . ./defs # # # # # # # # # # TEMPLATE FILE # # # # # # # # # echo creating ${testname}.tpl cat > ${testname}.tpl <<'_EOF_' <= AutoGen5 template fnord null => THIS TEXT SHOULD BE DELETED!! <= CASE (suffix) =><= == fnord =><= (error "0 this is really okay") =>this is never seen<= * =><= (error "This is a multi-line error to show how to exit your template") =><= ESAC => this is never seen _EOF_ # # # # # # # # # # DEFINITIONS FILE # # # # # # # # # echo creating ${testname}.def cat > ${testname}.def <<'_EOF_' autogen definitions alist; #error The definitions file has a `#error' directive _EOF_ # # # # # # # # # # EXPECTED OUTPUT FILE 1 # # # # # # # echo creating ${testname}.base1 # this is the output we should expect to see cat > ${testname}.base1 <<'_EOF_' #error directive -- in error.def on line 3 The definitions file has a `#error' directive _EOF_ echo ${AGexe} ${testname}.def ${AGexe} ${testname}.def 2> ${testname}.err1 && failure unexpected success ${GREP} -v 'Giving up in' ${testname}.err1 > ${testname}.err cmp -s ${testname}.err ${testname}.base1 || \ failure "expected->actual `diff -c ${testname}.base1 ${testname}.err`" # # # # # # # # # # EXPECTED OUTPUT FILE 2 # # # # # # # echo creating ${testname}.base2 # this is the output we should expect to see cat > ${testname}.base2 <<'_EOF_' DEFINITIONS Warning in error.tpl line 8 for error.fnord: 0 this is really okay Error in template error.tpl, line 13 DEFINITIONS ERROR in error.tpl line 13 for /dev/null: This is a multi-line error to show how to exit your template Failing Guile command: = = = = = (error "This is a multi-line error to show how to exit your template") ================================= _EOF_ agopts="--no-def --base=${testname} --trace-out=${testname}.trc" # this is *supposed* to exit with a failure status echo autogen -T${testname}.tpl ${agopts}2 >&2 ${AGexe} -T${testname}.tpl ${agopts}2 \ 2> ${testname}.err2 \ && failure Unexpected success for AutoGen if test ${GUILE_VERSION} -gt 107000 then ${EGREP} -v 'Giving up in | is deprecated\.' ${testname}.err2 else ${EGREP} -v 'Giving up in ' ${testname}.err2 fi >> ${testname}.trc2 cmp -s ${testname}.base2 ${testname}.trc2 || \ failure "expected->actual `diff -c ${testname}.base2 ${testname}.trc2`" # # # # # # # # # # EXPECTED OUTPUT FILE 3 # # # # # # # echo creating ${testname}.base3 # this is the output we should expect to see cat > ${testname}.base3 <<_EOF_ Killing AutoGen: testing death AutoGen aborting on signal in state EMITTING processing template error2.tpl on line 2 for function EXPR (11) _EOF_ sed '/THIS TEXT/,/ESAC/d;s,this is never seen,<= `die testing death` =>,' \ < ${testname}.tpl > ${testname}2.tpl # this is *supposed* to exit with a failure status echo autogen -T${testname}2.tpl ${agopts}3 >&2 ${AGexe} -T${testname}2.tpl ${agopts}3 \ 2> ${testname}.tmp3 \ && failure Unexpected success for AutoGen sed -e 's,on signal .* in state,on signal in state,' \ -e '/trapped on [1-9]/d' -e '/^Abort/d' -e '/Broken pipe/d' \ ${testname}.tmp3 >> ${testname}.trc3 cmp -s ${testname}.trc3 ${testname}.base3 || \ failure "expected->actual `diff -c ${testname}.base3 ${testname}.trc3`" # # # # # # # # # # EXPECTED OUTPUT FILE 4 # # # # # # # sed 's,^#error.*,this is broken;,' ${testname}.def > ${testname}2.def echo creating ${testname}.base4 # this is the output we should expect to see cat > ${testname}.base4 <<'_EOF_' FSM Error: in state 5 (have_name), event 3 (var_name) is invalid invalid transition: in error2.def on line 2 token in error: var_name: ``is broken; '' [[...]] broken; Likely causes: a mismatched quote, a value that needs quoting, or a missing semi-colon _EOF_ echo ${AGexe} ${testname}.def ${AGexe} ${testname}2.def 2> ${testname}.trc4 && failure unexpected success ${GREP} -v 'Giving up in' ${testname}.trc4 > ${testname}.err4 cmp -s ${testname}.err4 ${testname}.base4 || \ failure "expected->actual `diff -c ${testname}.base4 ${testname}.err4`" # # # # # # # # # # TEMPLATE FILE # # # # # # # # # echo creating ${testname}.tpl5 cat > ${testname}.tpl5 <<'_EOF_' <= AutoGen5 template fnord null => THIS TEXT SHOULD BE DELETED!! <= ENDIF => _EOF_ ${AGexe} -T ${testname}.tpl5 ${agopts}5 \ > /dev/null 2> ${testname}.out5 [ $? -ne 0 ] || failure "${AGexe} was okay with bogus input" ${EGREP} -v 'Giving up in .*functions\.c' ${testname}.out5 > ${testname}.samp5 cat > ${testname}.base5 <<'EOF' Error in template error.tpl5, line 3 Unknown macro or invalid context in error.tpl5 line 3: ENDIF EOF cmp -s ${testname}.base5 ${testname}.samp5 || \ failure "expected->actual `diff -c ${testname}.base5 ${testname}.samp5`" # # # # # # # # # # TEMPLATE FILE # # # # # # # # # echo creating ${testname}.tpl6 cat > ${testname}.tpl6 <<'_EOF_' <= AutoGen5 template fnord null => This is a broken template, "nothing" is not defined. <= ( if (exist? "nothing") (error "it is broken 'cuz it's okay") (stumble-over-unbound-variable) ) => End Of File _EOF_ ${AGexe} -T ${testname}.tpl6 ${agopts}6 \ > /dev/null 2> ${testname}.out6 && \ failure "Your Guile lib exits 0 on failure" cat > ${testname}.base6 <&2 exec 3> ${testname}.base6-tmp echo 'ERROR: Unbound variable: stumble-over-unbound-variable' >&3 sed 1,2d ${testname}.base6 >&3 exec 3>&- mv -f ${testname}.base6-tmp ${testname}.base6 fi cmp -s ${testname}.base6 ${testname}.out6 || \ failure "expected->actual `diff -c ${testname}.base6 ${testname}.out6`" cleanup ## Local Variables: ## Mode: shell-script ## indent-tabs-mode: nil ## sh-indentation: 2 ## End: # end of error.test