##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.70-maint/%M%
#   Revision:		%I%
#   First Edition:	95/12/06
#   Last Mod.:		%U%, %G%
#
#   Authors:		Jens Hamisch, Jens.Hamisch@Strawberry.COM
#
#   Description:	Testuite testsequence
#   Command:		apropos
#   Modulefiles:	whatis/lines, whatis/multiple, whatis/none,
#   Modulefiles:	whatis/string, bad
#   Sub-Command:
#
#   Comment:	%C{
#			Checks the 'module apropos' command. The first
#			invocation creates an apropos cache (which has been
#			removed while initialization of this part of the
#			testsuite), the second one searches case insensitive
#			thrue the cache and the last one lokks up a not-
#			existing pattern.
#		}C%
#
##############################################################################

#
#  Test only for the csh
#

set header "$modlin $modpathre $modlin"

set warn_opt "$warn_msgs: Unsupported option "

set ts_1  "        whatis/lines: Testsuite Whatis Modulefile"
set ts_1a "        whatis/lines: Second line of whatis tokens"
# different behavior than C-version: on Tcl-version multiple arguments provided on a single
# module-whatis call produce a single module-whatis line, not one line per passed argument
set ts_2  "     whatis/multiple: Testsuite Whatis Modulefile"
set ts_3  "         whatis/none: Whatis"
set ts_4  "       whatis/string: Testsuite Whatis Modulefile"
set ts_5  "           bad/after: erroneous module test"
set ts_6  "           bad2/body: erroneous module test"
set ts_7  "           bad2/proc: erroneous module test"

#
#  The tests
#

# expect a break message
# error found in interpreted module, so an error code is rendered
testouterr_cmd_re "csh" "apropos Whatis" "ERR" "$header\n$ts_1\n$ts_1a\n$ts_2\n$ts_4"
# different behavior than C-version: on Tcl-version -i/--icase option is ignored
# but search is always case insensitive
testouterr_cmd_re "csh" "apropos WHATIS" "ERR" "$header\n$ts_1\n$ts_1a\n$ts_2\n$ts_4"
testouterr_cmd_re "csh" "-i apropos WHATIS" "ERR" "$header\n$ts_1\n$ts_1a\n$ts_2\n$ts_4"
testouterr_cmd_re "csh" "--icase apropos WHATIS" "ERR" "$header\n$ts_1\n$ts_1a\n$ts_2\n$ts_4"
testouterr_cmd "csh" "apropos sdlhasdh" "ERR" ""

# display all whatis lines as soon as one match search
testouterr_cmd_re "csh" "apropos token" "ERR" "$header\n$ts_1\n$ts_1a"

# command nickname tests
testouterr_cmd_re "csh" "keyword token" "ERR" "$header\n$ts_1\n$ts_1a"
testouterr_cmd_re "csh" "search token" "ERR" "$header\n$ts_1\n$ts_1a"

#
# test with erroneous modulefile
# should not produce error message
#
testouterr_cmd_re "csh" "apropos erroneous" "ERR" "$header\n$ts_5\n$ts_6\n$ts_7"

# same test in debug mode, should produce error message
testouterr_cmd_re "csh" "-D apropos erroneous" "ERR" "(DEBUG .*)+\n$moderr_msgs:.*$header\n$ts_5\n$ts_6\n$ts_7\nDEBUG unsetState: report_sep_next unset\n\n(DEBUG .*)+"

#
#  Cleanup
#

reset_test_env
