##############################################################################
#   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/version13, loc_sym/version14, loc_sym/getvers8
#   Sub-Command:
#
#   Comment:	%C{
#			Tests error conditions with the module version command
#			depending on different user levels.
#		}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/version13"
set modulefile_1 "$modpath/$module_1"

set module_2 "loc_sym/version14"
set modulefile_2 "$modpath/$module_2"

set module_3 "loc_sym/getvers8"
set modulefile_3 "$modpath/$module_3"

#
#  The warning messages
#

# different behavior than C-version: error or warning messages for resolution
# loop or an already defined symbolic version are a bit different on Tcl-version
set prob_dup "$warn_msgs: Symbolic version 'loc_sym/foo' already defined"
set err_loop "$error_msgs: Resolution loop on 'loc_sym/1.0' detected"

#
#  Only checked for the csh
#

lappend ans [list set testsuite "bar:blah:foo"]
lappend ans [list setpath LOADEDMODULES $module_1]
lappend ans [list setpath _LMFILES_ $modulefile_1]
testouterr_cmd "csh" "load $module_1" $ans [msg_load $module_1 $prob_dup]

# different behavior than C-version: resolution loop is found at module-version
# registering time on Tcl-version, so loop is not saved and error message is
# output at that time. Then the 'module-info symbols' will not return the
# looping symbol '1.0' as it has not been registered.
set ans [list]
lappend ans [list set testsuite "bar:foo"]
lappend ans [list setpath LOADEDMODULES $module_2]
lappend ans [list setpath _LMFILES_ $modulefile_2]
lappend ans [list ERR]
testouterr_cmd "csh" "load $module_2" $ans [msg_load $module_2 $err_loop]

# different behavior than C-version: resolution loop is found at module-version
# registering time on Tcl-version, so loop is not saved and error message is
# output at that time. Then the 'module-info version' will not return the
# '*undef*' value as no loop has been registered.
set ans [list]
lappend ans [list set testsuite "loc_sym/1.0"]
lappend ans [list setpath LOADEDMODULES $module_3]
lappend ans [list setpath _LMFILES_ $modulefile_3]
lappend ans [list ERR]
testouterr_cmd "csh" "load $module_3" $ans [msg_load $module_3 $err_loop]

#
#  Cleanup
#

reset_test_env
