##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.00-init/%M%
#   Revision:		%I%
#   First Edition:	95/12/06
#   Last Mod.:		%U%, %G%
#
#   Authors:		Jens Hamisch, Jens.Hamisch@Strawberry.COM
#
#   Description:	Testuite testsequence
#   Command:
#   Sub-Command:
#
#   Comment:	%C{
#			Check all valid command line switches in long
#			and short presentation.
#		}C%
#
##############################################################################

#
# The following answers are to be expected in this testcase ...
#

set ign_prefix "$warn_msgs: Unsupported option"
set bad_prefix "$error_msgs: Invalid option"
set bad_longarg "$bad_prefix '--foobar'"
set bad_shortarg "$bad_prefix '-z'"
set pos_ans	"Modules Release(.*)Usage: module(.*)Loading \/(.*)Switches:(.*)"
set pos_display_ans "$modlin\n$modpathre/loc_fq/1.0:\n\n$modlin"

#
# The tests
#

if { $verbose > 0 } {
    send_user "\tChecking command line arguments ...\n"
}

# no error when help asked
testouterr_cmd_re "sh" "--help" "" "$pos_ans"
testouterr_cmd_re "sh" "-h" "" "$pos_ans"
# no command means help
testouterr_cmd_re "sh" "" "OK" "$pos_ans"

# invalid option leads to error code
testouterr_cmd "ALL" "--foobar display loc_fq/2.0" "ERR" "$bad_longarg\n$err_typehelp"
testouterr_cmd "ALL" "-z display loc_fq/2.0" "ERR" "$bad_shortarg\n$err_typehelp"


# ignore C-version specific command-line switches, no error returned
testouterr_cmd_re "sh" "--terse display loc_fq/1.0" "OK" "$pos_display_ans"
testouterr_cmd_re "sh" "--long display loc_fq/1.0" "OK" "$pos_display_ans"
testouterr_cmd_re "sh" "--silent --terse display loc_fq/1.0" "OK" "$pos_display_ans"
testouterr_cmd_re "sh" "--verbose display loc_fq/1.0" "OK" "$pos_display_ans"
testouterr_cmd_re "sh" "--userlvl=expert display loc_fq/1.0" "OK" "$ign_prefix '--userlvl=expert'\n$pos_display_ans"
testouterr_cmd_re "sh" "--icase display loc_fq/1.0" "OK" $pos_display_ans

# different behavior than C-version: Tcl-version ignores long and short
# form of C-version specific switches but no other intermediates forms
testouterr_cmd "sh" "--for display loc_fq/1.0" "ERR" "$bad_prefix '--for'\n$err_typehelp"
testouterr_cmd "sh" "--ter display loc_fq/1.0" "ERR" "$bad_prefix '--ter'\n$err_typehelp"
testouterr_cmd "sh" "--lon display loc_fq/1.0" "ERR" "$bad_prefix '--lon'\n$err_typehelp"
testouterr_cmd "sh" "--sil display loc_fq/1.0" "ERR" "$bad_prefix '--sil'\n$err_typehelp"
testouterr_cmd "sh" "--verb display loc_fq/1.0" "ERR" "$bad_prefix '--verb'\n$err_typehelp"
testouterr_cmd "sh" "--use=expert display loc_fq/1.0" "ERR" "$bad_prefix '--use=expert'\n$err_typehelp"
testouterr_cmd "sh" "--ica display loc_fq/1.0" "ERR" "$bad_prefix '--ica'\n$err_typehelp"

testouterr_cmd_re "sh" "-t display loc_fq/1.0" "OK" "$pos_display_ans"
testouterr_cmd_re "sh" "-l display loc_fq/1.0" "OK" "$pos_display_ans"
testouterr_cmd_re "sh" "-t -s display loc_fq/1.0" "OK" "$pos_display_ans"
testouterr_cmd_re "sh" "-v display loc_fq/1.0" "OK" "$pos_display_ans"
testouterr_cmd_re "sh" "-u expert display loc_fq/1.0" "OK" "$ign_prefix '-u'\n$pos_display_ans"
testouterr_cmd_re "sh" "-i display loc_fq/1.0" "OK" $pos_display_ans

testouterr_cmd "sh" "--use=exp display loc_fq/1.0" "ERR" "$bad_prefix '--use=exp'\n$err_typehelp"
testouterr_cmd "sh" "--use=novice display loc_fq/1.0" "ERR" "$bad_prefix '--use=novice'\n$err_typehelp"
testouterr_cmd "sh" "--use=nov display loc_fq/1.0" "ERR" "$bad_prefix '--use=nov'\n$err_typehelp"
testouterr_cmd "sh" "--use=advanced display loc_fq/1.0" "ERR" "$bad_prefix '--use=advanced'\n$err_typehelp"
testouterr_cmd "sh" "--use=adv display loc_fq/1.0" "ERR" "$bad_prefix '--use=adv'\n$err_typehelp"
testouterr_cmd "sh" "--u novice display loc_fq/1.0" "ERR" "$bad_prefix '--u'\n$err_typehelp"
testouterr_cmd "sh" "--u advanced display loc_fq/1.0" "ERR" "$bad_prefix '--u'\n$err_typehelp"

# different behavior than C-version: Tcl-version ignores C-version specific
# switches so no error is raised when a bad value is passed to these switches
testouterr_cmd_re "sh" "--userlvl=foobar display loc_fq/1.0" "OK" "$ign_prefix '--userlvl=foobar'\n$pos_display_ans"


#
#  Clean up variables used in this test case
#

reset_test_env
