Blame autoopts/test/stdopts.test

Packit Service 96b5d3
#! /bin/sh
Packit Service 96b5d3
#  -*- Mode: Shell-script -*-
Packit Service 96b5d3
# ----------------------------------------------------------------------
Packit Service 96b5d3
# stdopts.test ---   test standard options
Packit Service 96b5d3
#
Packit Service 96b5d3
# Author:            Bruce Korb <bkorb@gnu.org>
Packit Service 96b5d3
##
Packit Service 96b5d3
##  This file is part of AutoOpts, a companion to AutoGen.
Packit Service 96b5d3
##  AutoOpts is free software.
Packit Service 96b5d3
##  AutoOpts is Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
Packit Service 96b5d3
##
Packit Service 96b5d3
##  AutoOpts is available under any one of two licenses.  The license
Packit Service 96b5d3
##  in use must be one of these two and the choice is under the control
Packit Service 96b5d3
##  of the user of the license.
Packit Service 96b5d3
##
Packit Service 96b5d3
##   The GNU Lesser General Public License, version 3 or later
Packit Service 96b5d3
##      See the files "COPYING.lgplv3" and "COPYING.gplv3"
Packit Service 96b5d3
##
Packit Service 96b5d3
##   The Modified Berkeley Software Distribution License
Packit Service 96b5d3
##      See the file "COPYING.mbsd"
Packit Service 96b5d3
##
Packit Service 96b5d3
##  These files have the following sha256 sums:
Packit Service 96b5d3
##
Packit Service 96b5d3
##  8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95  COPYING.gplv3
Packit Service 96b5d3
##  4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b  COPYING.lgplv3
Packit Service 96b5d3
##  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
Packit Service 96b5d3
#
Packit Service 96b5d3
# ----------------------------------------------------------------------
Packit Service 96b5d3
Packit Service 96b5d3
. ./defs
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # DEFINITIONS FILE # # # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
echo "creating ${testname}.def in `pwd`"
Packit Service 96b5d3
cat > ${testname}.def <<- _EOF_
Packit Service 96b5d3
Packit Service 96b5d3
	AutoGen Definitions options;
Packit Service 96b5d3
Packit Service 96b5d3
	prog-name = test_${testname};
Packit Service 96b5d3
	prog-title = "${testname} test";
Packit Service 96b5d3
	config-header = 'config.h';
Packit Service 96b5d3
	no-xlate = anything;
Packit Service 96b5d3
	main = {
Packit Service 96b5d3
	    main-type = main;
Packit Service 96b5d3
	    main-text = <<- _EndMain_
Packit Service 96b5d3
		\    (void)optionProcess(&test_${testname}Options, argc, argv);
Packit Service 96b5d3
		\    optionPutShell(&test_${testname}Options);
Packit Service 96b5d3
		\    return ferror(stdout) ? 1 : 0;
Packit Service 96b5d3
		_EndMain_;
Packit Service 96b5d3
	};
Packit Service 96b5d3
	long-opts;
Packit Service 96b5d3
Packit Service 96b5d3
	#define VERBOSE_ENUM
Packit Service 96b5d3
	#define VERBOSE_FLAG
Packit Service 96b5d3
Packit Service 96b5d3
	#include stdoptions
Packit Service 96b5d3
	_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
${AG_L} ${testname}.def || \
Packit Service 96b5d3
  failure AutoGen could not process
Packit Service 96b5d3
Packit Service 96b5d3
compile "-?"
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
echo creating ${testname}.hlp
Packit Service 96b5d3
clean_help > ${testname}.hbase <<- _EOF_
Packit Service 96b5d3
	test_stdopts - stdopts test
Packit Service 96b5d3
	Usage:  stdopts [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
Packit Service 96b5d3
Packit Service 96b5d3
	The following options are commonly used and are provided and supported
Packit Service 96b5d3
	by AutoOpts:
Packit Service 96b5d3
Packit Service 96b5d3
	  Flg Arg Option-Name    Description
Packit Service 96b5d3
	   -V KWd verbose        run program with progress info
Packit Service 96b5d3
Packit Service 96b5d3
	Version, usage and configuration options:
Packit Service 96b5d3
Packit Service 96b5d3
	  Flg Arg Option-Name    Description
Packit Service 96b5d3
	   -? no  help           display extended usage information and exit
Packit Service 96b5d3
	   -! no  more-help      extended usage information passed thru pager
Packit Service 96b5d3
Packit Service 96b5d3
	Options are specified by doubled hyphens and their name or by a single
Packit Service 96b5d3
	hyphen and the flag character.
Packit Service 96b5d3
Packit Service 96b5d3
	The valid "verbose" option keywords are:
Packit Service 96b5d3
	  silent quiet brief informative verbose
Packit Service 96b5d3
	  or an integer from 0 through 4
Packit Service 96b5d3
	_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
#  When building with DEBUG set, we get an unanticipated option:
Packit Service 96b5d3
#
Packit Service 96b5d3
${GREP} -v 'run program with debugging info' ${testname}.help > ${testname}.hres
Packit Service 96b5d3
Packit Service 96b5d3
cmp -s ${testname}.h[br]* || \
Packit Service 96b5d3
  failure "MISCOMPARE: `diff ${testname}.h[br]*`"
Packit Service 96b5d3
Packit Service 96b5d3
./${testname} --verbose=exp > /dev/null 2>&1 && \
Packit Service 96b5d3
  failure ${testname} accepted ambiguous keyword
Packit Service 96b5d3
Packit Service 96b5d3
./${testname} --verbose=inf > ${testname}.out || \
Packit Service 96b5d3
  failure ${testname} did not handle its options
Packit Service 96b5d3
Packit Service 96b5d3
cat > ${testname}.oex <<_EOF_
Packit Service 96b5d3
OPTION_CT=1
Packit Service 96b5d3
export OPTION_CT
Packit Service 96b5d3
TEST_STDOPTS_VERBOSE='informative'
Packit Service 96b5d3
export TEST_STDOPTS_VERBOSE
Packit Service 96b5d3
_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
cmp -s ${testname}.o* || \
Packit Service 96b5d3
  failure "`diff ${testname}.o??`"
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # USAGE OPTION # # # # # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
( ${SED} "s/${testname}/${testname}-2/g
Packit Service 96b5d3
	s/-2Options/_2Options/g" ${testname}.def
Packit Service 96b5d3
  echo 'usage-opt;'
Packit Service 96b5d3
) > ${testname}-2.def
Packit Service 96b5d3
Packit Service 96b5d3
testname=${testname}-2
Packit Service 96b5d3
Packit Service 96b5d3
${AG_L} ${testname}.def || {
Packit Service 96b5d3
    testname=${testname%-2}
Packit Service 96b5d3
    failure AutoGen could not process
Packit Service 96b5d3
}
Packit Service 96b5d3
Packit Service 96b5d3
compile "--usage"
Packit Service 96b5d3
Packit Service 96b5d3
clean_help > ${testname}.hbase <<- _EOF_
Packit Service 96b5d3
	test_stdopts-2 - stdopts-2 test
Packit Service 96b5d3
	Usage:  stdopts-2 [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
Packit Service 96b5d3
	  Flg Arg Option-Name    Description
Packit Service 96b5d3
	   -V KWd verbose        run program with progress info
Packit Service 96b5d3
	   -? no  help           display extended usage information and exit
Packit Service 96b5d3
	   -! no  more-help      extended usage information passed thru pager
Packit Service 96b5d3
	   -u no  usage          abbreviated usage to stdout
Packit Service 96b5d3
Packit Service 96b5d3
	Options are specified by doubled hyphens and their name or by a single
Packit Service 96b5d3
	hyphen and the flag character.
Packit Service 96b5d3
	_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
#  When building with DEBUG set, we get an unanticipated option:
Packit Service 96b5d3
#
Packit Service 96b5d3
${GREP} -v 'run program with debugging info' ${testname}.help > ${testname}.hres
Packit Service 96b5d3
Packit Service 96b5d3
cmp -s ${testname}.h[br]* || {
Packit Service 96b5d3
    testname=${testname%-2}
Packit Service 96b5d3
    failure "MISCOMPARE: `diff ${testname}-2.h[br]*`"
Packit Service 96b5d3
}
Packit Service 96b5d3
Packit Service 96b5d3
use=`
Packit Service 96b5d3
  set +x
Packit Service 96b5d3
  exec 2>&1
Packit Service 96b5d3
  exec 1>/dev/null
Packit Service 96b5d3
  ./${testname} --usage`
Packit Service 96b5d3
test $? -eq 0       || failure usage failure
Packit Service 96b5d3
test "X${use}" = X  || failure misdirected usage
Packit Service 96b5d3
Packit Service 96b5d3
testname=${testname%-2}
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
## End:
Packit Service 96b5d3
Packit Service 96b5d3
# end of stdopts.test