##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.50-cmds/%M%
#   Revision:		%I%
#   First Edition:	2001/11/05
#   Last Mod.:		%U%, %G%
#
#   Authors:		R.K. Owen, <rk@owen.sj.ca.us>
#
#   Description:	Testuite testsequence
#   Command:		load
#   Modulefiles:	loc_dv1/1.0,
#   			loc_dv2/1.0,
#   			loc_dv3/1.0,
#   Sub-Command:
#
#   Comment:	%C{
#			Load a modulefile giving the full path.
#		}C%
#
##############################################################################

set mod11 "loc_dv1/1.0"
set mod21 "loc_dv2/1.0"
set mod31 "loc_dv3/1.0"

set mod11p "$env(MODULEPATH)/$mod11"
set mod21p "$env(MODULEPATH)/$mod21"
set mod31p "$env(MODULEPATH)/$mod31"

set oth11 "version"
set oth11p "$env(MODULEPATH).other/1.1/version"

#
# set up an empty environment
#
set module ""
set modulefile ""
set env(_LMFILES_) "$modulefile"
set env(LOADEDMODULES) "$module"

#
#  load
#  For the different shells ...
#
set module "$mod31"
set modulefile "$mod31p"

set lmf_sh "_LMFILES_=$modulefile ;export _LMFILES_;"
set lm_sh "LOADEDMODULES=$module ;export LOADEDMODULES;"
set ts_sh "TESTSUITE=1.1 ;export TESTSUITE;"

set lmf_csh "setenv _LMFILES_ $modulefile ;"
set lm_csh "setenv LOADEDMODULES $module ;"
set ts_csh "setenv TESTSUITE 1.1 ;"

set lmf_perl "\$ENV{'_LMFILES_'} = '$modulefile';"
set lm_perl "\$ENV{'LOADEDMODULES'} = '$module';"
set ts_perl "\$ENV{'TESTSUITE'} = '1.1';"

set lmf_cmake "set(ENV{_LMFILES_} \"$modulefile\")"
set lm_cmake "set(ENV{LOADEDMODULES} \"$module\")"
set ts_cmake "set(ENV{TESTSUITE} \"1.1\")"

#
#  The tests
#
test_cmd "sh" "load $mod31" "$lm_sh$lmf_sh"
test_cmd "ksh" "load $mod31" "$lm_sh$lmf_sh"
test_cmd "zsh" "load $mod31" "$lm_sh$lmf_sh"
test_cmd "csh" "load $mod31" "$lm_csh$lmf_csh"
test_cmd "tcsh" "load $mod31" "$lm_csh$lmf_csh"
test_cmd "perl" "load $mod31" "$lm_perl$lmf_perl"
test_cmd "cmake" "load $mod31" "$lm_cmake\n$lmf_cmake"

#
# set up a single environment
#
set module "$mod11"
set modulefile "$mod11p"
set env(_LMFILES_) "$modulefile"
set env(LOADEDMODULES) "$module"

#
#  load
#  For the different shells ...
#
set module "$mod11:$mod31"
set modulefile "$mod11p:$mod31p"

set lmf_sh "_LMFILES_=$modulefile ;export _LMFILES_;"
set lm_sh "LOADEDMODULES=$module ;export LOADEDMODULES;"

set lmf_csh "setenv _LMFILES_ $modulefile ;"
set lm_csh "setenv LOADEDMODULES $module ;"

set lmf_perl "\$ENV{'_LMFILES_'} = '$modulefile';"
set lm_perl "\$ENV{'LOADEDMODULES'} = '$module';"

set lmf_cmake "set(ENV{_LMFILES_} \"$modulefile\")"
set lm_cmake "set(ENV{LOADEDMODULES} \"$module\")"

#
#  The tests
#
test_cmd "sh" "load $mod31" "$lm_sh$lmf_sh"
test_cmd "ksh" "load $mod31" "$lm_sh$lmf_sh"
test_cmd "zsh" "load $mod31" "$lm_sh$lmf_sh"
test_cmd "csh" "load $mod31" "$lm_csh$lmf_csh"
test_cmd "tcsh" "load $mod31" "$lm_csh$lmf_csh"
test_cmd "perl" "load $mod31" "$lm_perl$lmf_perl"
test_cmd "cmake" "load $mod31" "$lm_cmake\n$lmf_cmake"

#
# set up a double environment
#
set module "$mod11:$mod21"
set modulefile "$mod11p:$mod21p"
set env(_LMFILES_) "$modulefile"
set env(LOADEDMODULES) "$module"

#
#  load
#  For the different shells ...
#
set module "$mod11:$mod21:$mod31"
set modulefile "$mod11p:$mod21p:$mod31p"

set lmf_sh "_LMFILES_=$modulefile ;export _LMFILES_;"
set lm_sh "LOADEDMODULES=$module ;export LOADEDMODULES;"

set lmf_csh "setenv _LMFILES_ $modulefile ;"
set lm_csh "setenv LOADEDMODULES $module ;"

set lmf_perl "\$ENV{'_LMFILES_'} = '$modulefile';"
set lm_perl "\$ENV{'LOADEDMODULES'} = '$module';"

set lmf_cmake "set(ENV{_LMFILES_} \"$modulefile\")"
set lm_cmake "set(ENV{LOADEDMODULES} \"$module\")"

#
#  The tests
#
test_cmd "sh" "load $mod31" "$lm_sh$lmf_sh"
test_cmd "ksh" "load $mod31" "$lm_sh$lmf_sh"
test_cmd "zsh" "load $mod31" "$lm_sh$lmf_sh"
test_cmd "csh" "load $mod31" "$lm_csh$lmf_csh"
test_cmd "tcsh" "load $mod31" "$lm_csh$lmf_csh"
test_cmd "perl" "load $mod31" "$lm_perl$lmf_perl"
test_cmd "cmake" "load $mod31" "$lm_cmake\n$lmf_cmake"

#
# reference a module not in the path
#
set module "$mod11:$mod21"
set modulefile "$mod11p:$mod21p"
set env(_LMFILES_) "$modulefile"
set env(LOADEDMODULES) "$module"

#
#  load
#  For the different shells ...
#
set module "$mod11:$mod21:$oth11"
set modulefile "$mod11p:$mod21p:$oth11p"

set lmf_sh "_LMFILES_=$modulefile ;export _LMFILES_;"
set lm_sh "LOADEDMODULES=$module ;export LOADEDMODULES;"

set lmf_csh "setenv _LMFILES_ $modulefile ;"
set lm_csh "setenv LOADEDMODULES $module ;"

set lmf_perl "\$ENV{'_LMFILES_'} = '$modulefile';"
set lm_perl "\$ENV{'LOADEDMODULES'} = '$module';"

set lmf_cmake "set(ENV{_LMFILES_} \"$modulefile\")"
set lm_cmake "set(ENV{LOADEDMODULES} \"$module\")"

#
#  The tests
#
test_cmd "sh" "load $oth11p" "$lm_sh$ts_sh$lmf_sh"
test_cmd "ksh" "load $oth11p" "$lm_sh$ts_sh$lmf_sh"
test_cmd "zsh" "load $oth11p" "$lm_sh$ts_sh$lmf_sh"
test_cmd "csh" "load $oth11p" "$lm_csh$ts_csh$lmf_csh"
test_cmd "tcsh" "load $oth11p" "$lm_csh$ts_csh$lmf_csh"
test_cmd "perl" "load $oth11p" "$lm_perl$ts_perl$lmf_perl"
test_cmd "cmake" "load $oth11p" "$lm_cmake\n$ts_cmake\n$lmf_cmake"

#
#  Cleanup
#

unset env(_LMFILES_)
unset env(LOADEDMODULES)

unset lm_sh
unset lmf_sh
unset ts_sh

unset lm_csh
unset lmf_csh
unset ts_csh

unset lm_perl
unset lmf_perl
unset ts_perl

unset lm_cmake
unset lmf_cmake
unset ts_cmake

unset modulefile
unset module

unset mod11
unset mod21
unset mod31
unset mod11p
unset mod21p
unset mod31p

