summaryrefslogtreecommitdiff
path: root/autoopts/test/stdopts.test
diff options
context:
space:
mode:
Diffstat (limited to 'autoopts/test/stdopts.test')
-rwxr-xr-xautoopts/test/stdopts.test161
1 files changed, 161 insertions, 0 deletions
diff --git a/autoopts/test/stdopts.test b/autoopts/test/stdopts.test
new file mode 100755
index 0000000..21ba56c
--- /dev/null
+++ b/autoopts/test/stdopts.test
@@ -0,0 +1,161 @@
+#! /bin/sh
+# -*- Mode: Shell-script -*-
+# ----------------------------------------------------------------------
+# stdopts.test --- test standard options
+#
+# Time-stamp: "2013-03-10 07:14:45 bkorb"
+# Author: Bruce Korb <bkorb@gnu.org>
+##
+## This file is part of AutoOpts, a companion to AutoGen.
+## AutoOpts is free software.
+## AutoOpts is Copyright (c) 1992-2012 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:
+##
+## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3
+## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3
+## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
+#
+# ----------------------------------------------------------------------
+
+. ./defs
+
+# # # # # # # # # # DEFINITIONS FILE # # # # # # # # #
+
+echo "creating ${testname}.def in `pwd`"
+cat > ${testname}.def <<- _EOF_
+
+ AutoGen Definitions options;
+
+ prog-name = test_${testname};
+ prog-title = "${testname} test";
+ config-header = 'config.h';
+ test-main;
+ long-opts;
+
+ #define VERBOSE_ENUM
+ #define VERBOSE_FLAG
+
+ #include stdoptions
+ _EOF_
+
+${AG_L} ${testname}.def || \
+ failure AutoGen could not process
+
+compile "-?"
+
+# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # #
+
+echo creating ${testname}.hlp
+clean_help > ${testname}.hbase <<- _EOF_
+ test_stdopts - stdopts test
+ USAGE: stdopts [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
+
+ The following options are commonly used and are provided and supported
+ by AutoOpts:
+
+ Flg Arg Option-Name Description
+ -V KWd verbose run program with progress info
+
+ version, usage and configuration options:
+
+ Flg Arg Option-Name Description
+ -? no help Display extended usage information and exit
+ -! no more-help Extended usage information passed thru pager
+
+ Options are specified by doubled hyphens and their name or by a single
+ hyphen and the flag character.
+
+ The valid "verbose" option keywords are:
+ silent quiet brief informative verbose
+ or an integer from 0 through 4
+ _EOF_
+
+# When building with DEBUG set, we get an unanticipated option:
+#
+${GREP} -v 'run program with debugging info' ${testname}.help > ${testname}.hres
+
+cmp -s ${testname}.h[br]* || \
+ failure "MISCOMPARE: `diff ${testname}.h[br]*`"
+
+./${testname} --verbose=exp > /dev/null 2>&1 && \
+ failure ${testname} accepted ambiguous keyword
+
+./${testname} --verbose=inf > ${testname}.out || \
+ failure ${testname} did not handle its options
+
+cat > ${testname}.oex <<_EOF_
+OPTION_CT=1
+export OPTION_CT
+TEST_STDOPTS_VERBOSE='informative'
+export TEST_STDOPTS_VERBOSE
+_EOF_
+
+cmp -s ${testname}.o* || \
+ failure "`diff ${testname}.o??`"
+
+# # # # # # # # # # USAGE OPTION # # # # # # # # # # #
+
+( ${SED} "s/${testname}/${testname}-2/g" ${testname}.def
+ echo 'usage-opt;'
+) > ${testname}-2.def
+
+testname=${testname}-2
+
+${AG_L} ${testname}.def || {
+ testname=${testname%-2}
+ failure AutoGen could not process
+}
+
+compile "--usage"
+
+clean_help > ${testname}.hbase <<- _EOF_
+ test_stdopts-2 - stdopts-2 test
+ USAGE: stdopts-2 [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
+ Flg Arg Option-Name Description
+ -V KWd verbose run program with progress info
+ -? no help Display extended usage information and exit
+ -! no more-help Extended usage information passed thru pager
+ -u no usage Abbreviated usage to stdout
+
+ Options are specified by doubled hyphens and their name or by a single
+ hyphen and the flag character.
+ _EOF_
+
+# When building with DEBUG set, we get an unanticipated option:
+#
+${GREP} -v 'run program with debugging info' ${testname}.help > ${testname}.hres
+
+cmp -s ${testname}.h[br]* || {
+ testname=${testname%-2}
+ failure "MISCOMPARE: `diff ${testname}-2.h[br]*`"
+}
+
+use=`
+ set +x
+ exec 2>&1
+ exec 1>/dev/null
+ ./${testname} --usage`
+test $? -eq 0 || failure usage failure
+test "X${use}" = X || failure misdirected usage
+
+testname=${testname%-2}
+cleanup
+
+## Local Variables:
+## mode: shell-script
+## indent-tabs-mode: nil
+## sh-indentation: 2
+## End:
+
+# end of stdopts.test