##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.20-locate/%M%
#   Revision:		%I%
#   First Edition:	1995/12/06
#   Last Mod.:		%U%, %G%
#
#   Authors:		Jens Hamisch, Jens.Hamisch@Strawberry.COM
#
#   Description:	Testuite testsequence
#   Command:		load
#   Modulefiles:	loc_sym/alias1 loc_sym_alias2 loc_sym/alias3
#   Modulefiles:	loc_sym/alias4 loc_sym_alias5 loc_sym/alias6
#   Sub-Command:
#
#   Comment:	%C{
#			Check the 'module-alias' command
#		}C%
#
##############################################################################

#
#  Variables. This test forces a module load command. It will result in the
#    environment variables "_LMFILES_", "LOADEDMODULES" and "testsuite" to
#    be set up
#

set module_1 "loc_sym/alias1"
set modulefile_1 "$env(MODULEPATH)/$module_1"

set module_2 "loc_sym/alias2"
set modulefile_2 "$env(MODULEPATH)/$module_2"

set module_3 "loc_sym/alias3"
set modulefile_3 "$env(MODULEPATH)/$module_3"

set module_4 "loc_sym/alias4"
set modulefile_4 "$env(MODULEPATH)/$module_4"

set module_5 "loc_sym/alias5"
set modulefile_5 "$env(MODULEPATH)/$module_5"

set module_6 "loc_sym/alias6"
set modulefile_6 "$env(MODULEPATH)/$module_6"

#
#  'alias4' will behave different depending on user levels ..
#

set warn_dup "$warn_msgs: Duplicate alias 'foo' found"
set err_dup "$error_msgs: Tcl command execution failed: module-alias.*"

#
#  Only checked for the csh
#

set lmf_csh_1 "setenv _LMFILES_ $modulefile_1 ;"
set lm_csh_1 "setenv LOADEDMODULES $module_1 ;"
set ts_csh_1 "setenv testsuite loc_sym/1.0 ;"

set lmf_csh_2 "setenv _LMFILES_ $modulefile_2 ;"
set lm_csh_2 "setenv LOADEDMODULES $module_2 ;"
set ts_csh_2 "setenv testsuite loc_sym/2.0 ;"

set lmf_csh_3 "setenv _LMFILES_ $modulefile_3 ;"
set lm_csh_3 "setenv LOADEDMODULES $module_3 ;"
set ts_csh_3 "setenv testsuite loc_sym/1.0 ;"

set lmf_csh_4 "setenv _LMFILES_ $modulefile_4 ;"
set lm_csh_4 "setenv LOADEDMODULES $module_4 ;"
set ts_csh_4_nov "$warn_dup.*$err_dup"
set ts_csh_4_adv "setenv testsuite loc_sym/2.0 ;.*$warn_dup"
set ts_csh_4_exp "setenv testsuite loc_sym/2.0 ;"

set lmf_csh_5 "setenv _LMFILES_ $modulefile_5 ;"
set lm_csh_5 "setenv LOADEDMODULES $module_5 ;"
set ts_csh_5 "setenv testsuite loc_sym/default ;"

set lmf_csh_6 "setenv _LMFILES_ $modulefile_6 ;"
set lm_csh_6 "setenv LOADEDMODULES $module_6 ;"
set ts_csh_6 "setenv testsuite loc_sym/1.0 ;"

#
#  The tests
#

test_cmd "csh" "load $module_1" "$lm_csh_1$lmf_csh_1$ts_csh_1"
test_cmd "csh" "load $module_2" "$lm_csh_2$lmf_csh_2$ts_csh_2"
test_cmd "csh" "load $module_3" "$lm_csh_3$lmf_csh_3$ts_csh_3"
test_cmd "csh" "-u exp load $module_4" "$lm_csh_4$lmf_csh_4$ts_csh_4_exp"
testerr_cmd_re "csh" "-u nov load $module_4" "$ts_csh_4_nov"
testouterr_cmd_re "csh" "-u adv load $module_4" "$lm_csh_4$lmf_csh_4$ts_csh_4_exp" "$warn_dup"
test_cmd "csh" "load $module_5" "$lm_csh_5$lmf_csh_5$ts_csh_5"
test_cmd "csh" "load $module_6" "$lm_csh_6$lmf_csh_6$ts_csh_6"

#
#  Cleanup
#

unset warn_dup
unset err_dup

unset ts_csh_1
unset lm_csh_1
unset lmf_csh_1
unset ts_csh_2
unset lm_csh_2
unset lmf_csh_2
unset ts_csh_3
unset lm_csh_3
unset lmf_csh_3
unset ts_csh_4_nov
unset ts_csh_4_adv
unset ts_csh_4_exp
unset lm_csh_4
unset lmf_csh_4
unset ts_csh_5
unset lm_csh_5
unset lmf_csh_5
unset ts_csh_6
unset lm_csh_6
unset lmf_csh_6

unset modulefile_1
unset module_1
unset modulefile_2
unset module_2
unset modulefile_3
unset module_3
unset modulefile_4
unset module_4
unset modulefile_5
unset module_5
unset modulefile_6
unset module_6
