#! /bin/sh # -*- Mode: Shell-script -*- # ---------------------------------------------------------------------- # argument.test --- test argument program attribute # make sure that when it is not specified # then option processing consumes all args. # # Time-stamp: "2007-07-04 10:12:54 bkorb" # Author: Bruce Korb ## ## This file is part of AutoOpts, a companion to AutoGen. ## AutoOpts is free software. ## AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved ## ## AutoOpts is available under any one of two licenses. The license ## in use must be one of these two and the choice is under the control ## of the user of the license. ## ## The GNU Lesser General Public License, version 3 or later ## See the files "COPYING.lgplv3" and "COPYING.gplv3" ## ## The Modified Berkeley Software Distribution License ## See the file "COPYING.mbsd" ## ## These files have the following md5sums: ## ## 239588c55c22c60ffe159946a760a33e pkg/libopts/COPYING.gplv3 ## fa82ca978890795162346e661b47161a pkg/libopts/COPYING.lgplv3 ## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd # # $Id: argument.test,v 4.8 2007/07/04 21:36:39 bkorb Exp $ # ---------------------------------------------------------------------- . ./defs # # # # # # # # # # DEFINITIONS FILE # # # # # # # # # echo "creating ${testname}.def in `pwd`" export testname test_main argument long_opts ${SHELLX} ${stdopts} option:'opt init' second=020 || \ failure "Could not run stdopts.def" echo ${AG_L} ${testname}.def ${AG_L} ${testname}.def || \ failure AutoGen could not process compile "-?" # # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # basehlp=${testname}.hlp echo creating ${basehlp} cat > ${basehlp} <<'_EOF_' test_argument - Test AutoOpts for argument USAGE: argument [ - [] ]... Flg Arg Option-Name Description -o Str option The option option descrip -s Num second The second option descrip -? no help Display usage information and exit -! no more-help Extended usage information passed thru pager _EOF_ cmp -s ${testname}.h*lp || \ failure "`diff ${basehlp} ${testname}.help`" ./${testname} mumble 2> /dev/null && \ failure ${testname} should not accept non-options ./${testname} -s mumble 2> /dev/null && \ failure ${testname} should not accept bad options ./${testname} -o string -s 99 > /dev/null || \ failure ${testname} did not handle its options exec 3> ${testname}2.def sed '/arg-type = number/q' ${testname}.def >&3 cat >&3 <<- _EOF_ arg-range = "-1"; arg-range = "3->021"; }; include = '#include '; _EOF_ exec 3>&- ${AG_L} ${testname}2.def || \ failure AutoGen could not process ( sed '/TEST MAIN PROCEDURE:/,$d;s/_ARGUMENT_/_ARGUMENT2_/' ${testname}2.c cat < XX mv ${testname}2.c ${testname}2.c.save mv -f XX ${testname}2.c Csrc=${testname}2 compile "-?" cat > ${testname}2.hlp <<'_EOF_' test_argument - Test AutoOpts for argument USAGE: argument2 [ - [] ]... Flg Arg Option-Name Description -o Str option The option option descrip -s Num second The second option descrip it must lie in one of the ranges: -1 exactly, or 3 to 17 -? no help Display usage information and exit -! no more-help Extended usage information passed thru pager _EOF_ cmp -s ${testname}2.hlp ${testname}2.help || \ failure "`diff ${testname}.hlp ${testname}.help`" ./${testname}2 -o string -s 99 > /dev/null && \ failure ${testname} did not handle oversized option ./${testname}2 -o string -s 10 > /dev/null || \ failure ${testname} did not handle its options cleanup ## Local Variables: ## Mode: shell-script ## indent-tabs-mode: nil ## sh-indentation: 2 ## End: # end of argument.test