##############################################################################
#   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, display
#   Modulefiles:	loc_sym/1.0, loc_sym/exec1, loc_sym/exec2
#   Sub-Command:
#
#   Comment:	%C{
#			Tests the execution of symbolic moduleversions and
#			module aliases
#		}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 "loc_sym/1.0"
set modulefile "$modpath/$module"
set modulefilere "$modpathre/$module"

set module_1 "loc_sym/exec1"
set modulefile_1 "$modpath/$module_1"
set modulefilere_1 "$modpathre/$module_1"

set module_2 "loc_sym/exec2"
set modulefile_2 "$modpath/$module_2"
set modulefilere_2 "$modpathre/$module_2"

set module_3 "loc_sym/exec3"
set modulefile_3 "$modpath/$module_3"
set modulefilere_3 "$modpathre/$module_3"

#
#  Only checked for the csh
#

set disp_csh_1 "module-alias\tfoo loc_sym/1.0"
set disp_csh_2 "module-alias\tloc_sym2/1.0 loc_sym/1.0\nmodule-version\tloc_sym2/1.0 foo"
set disp_csh_3 "module-virtual\tloc_sym2/2.0 1.0"
set disp_csh "setenv\t\ttestsuite yes"
set disp_1 "$modlin\n$modulefilere_1:\n\n$disp_csh_1\n$modlin"
set disp_2 "$modlin\n$modulefilere_2:\n\n$disp_csh_2\n$modlin"
set disp_3 "$modlin\n$modulefilere_3:\n\n$disp_csh_3\n$modlin"
set disp "$modulefilere:\n\n$disp_csh\n$modlin"

#
#  The tests
#

lappend ans [list setpath LOADEDMODULES "$module_1:$module"]
lappend ans [list setpath _LMFILES_ "$modulefile_1:$modulefile"]
lappend ans [list setpath MODULES_LMALTNAME $module&al|foo]
lappend ans [list set testsuite yes]
test_cmd_re "csh" "load $module_1 foo" $ans
testouterr_cmd_re "sh" "display $module_1 foo" "OK" "$disp_1\n$disp"

set ans [list]
lappend ans [list setpath LOADEDMODULES "$module_2:$module"]
lappend ans [list setpath _LMFILES_ "$modulefile_2:$modulefile"]
if {[is_conf_enabled advversspec implicitdefault]} {
    lappend ans [list setpath MODULES_LMALTNAME $module&loc_sym2/foo&loc_sym/foo&al|loc_sym2/1.0&as|loc_sym2/default&as|loc_sym2/latest]
} else {
    lappend ans [list setpath MODULES_LMALTNAME $module&loc_sym2/foo&loc_sym/foo&al|loc_sym2/1.0]
}
lappend ans [list set testsuite yes]
test_cmd_re "csh" "load $module_2 loc_sym2/foo" $ans
testouterr_cmd_re "sh" "display $module_2 loc_sym2/foo" "OK" "$disp_2\n$disp"

set ans [list]
lappend ans [list setpath LOADEDMODULES "$module_3:loc_sym2/2.0"]
lappend ans [list setpath _LMFILES_ "$modulefile_3:$modulefile"]
if {[is_conf_enabled advversspec implicitdefault]} {
    lappend ans [list setpath MODULES_LMALTNAME loc_sym2/2.0&as|loc_sym2/default&as|loc_sym2/latest]
}
lappend ans [list set testsuite yes]
test_cmd_re "csh" "load $module_3 loc_sym2/2.0" $ans
testouterr_cmd_re "sh" "display $module_3 loc_sym2/2.0" "OK" "$disp_3\n$disp"

#
#  Cleanup
#

reset_test_env
