##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.50-cmds/%M%
#   Revision:		%I%
#   First Edition:	2001/06/20
#   Last Mod.:		%U%, %G%
#
#   Authors:		R.K. Owen,  rk@owen.sj.ca.us
#
#   Description:	Testuite testsequence
#   Command:		load & unload
#   Modulefiles:	versions/1.1, versions/1.2, versions/1.3
#   Sub-Command:
#
#   Comment:	%C{
#			Tests the module versioning capability.
#		}C%
#
##############################################################################

if { $verbose > 0 } {
	send_user "\tLoad of first version onto stack...\n"
}

set env(MODULEPATH) "$modulepath"
set env(MODULE_VERSION) "$version1"
set env(MODULE_VERSION_STACK) "$module_version_stack1"

#
#  For the different shells ...
#
set mvs_sh "MODULE_VERSION_STACK=$module_version_stack2 ;export MODULE_VERSION_STACK;"
set mv_sh "MODULE_VERSION=$version2 ;export MODULE_VERSION;"
set lmf_sh "_LMFILES_=$modulefile2 ;export _LMFILES_;"
set lm_sh "LOADEDMODULES=$module2 ;export LOADEDMODULES;"

set mvs_csh "setenv MODULE_VERSION_STACK $module_version_stack2 ;"
set mv_csh "setenv MODULE_VERSION $version2 ;"
set lmf_csh "setenv _LMFILES_ $modulefile2 ;"
set lm_csh "setenv LOADEDMODULES $module2 ;"

set mvs_perl "\$ENV{'MODULE_VERSION_STACK'} = '$module_version_stack2';"
set mv_perl "\$ENV{'MODULE_VERSION'} = '$version2';"
set lmf_perl "\$ENV{'_LMFILES_'} = '$modulefile2';"
set lm_perl "\$ENV{'LOADEDMODULES'} = '$module2';"

set mvs_cmake "set(ENV{MODULE_VERSION_STACK} \"$module_version_stack2\")"
set mv_cmake "set(ENV{MODULE_VERSION} \"$version2\")"
set lmf_cmake "set(ENV{_LMFILES_} \"$modulefile2\")"
set lm_cmake "set(ENV{LOADEDMODULES} \"$module2\")"

#
#  The tests
#
# load

test_cmd "sh" "load $module2" "$lm_sh$mv_sh$mvs_sh$lmf_sh"
test_cmd "ksh" "load $module2" "$lm_sh$mv_sh$mvs_sh$lmf_sh"
test_cmd "zsh" "load $module2" "$lm_sh$mv_sh$mvs_sh$lmf_sh"
test_cmd "csh" "load $module2" "$lm_csh$mv_csh$mvs_csh$lmf_csh"
test_cmd "tcsh" "load $module2" "$lm_csh$mv_csh$mvs_csh$lmf_csh"
test_cmd "perl" "load $module2" "$lm_perl$mv_perl$mvs_perl$lmf_perl"
test_cmd "cmake" "load $module2" "$lm_cmake\n$mv_cmake\n$mvs_cmake\n$lmf_cmake"

#
#  Cleanup
#

unset lm_sh
unset lmf_sh
unset mv_sh
unset mvs_sh

unset lm_csh
unset lmf_csh
unset mv_csh
unset mvs_csh

unset lm_perl
unset lmf_perl
unset mv_perl
unset mvs_perl

unset lm_cmake
unset lmf_cmake
unset mv_cmake
unset mvs_cmake

#
#  Clean up the environment, too
#

unset env(MODULEPATH)
unset env(MODULE_VERSION)
unset env(MODULE_VERSION_STACK)

