##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.10-use/%M%
#   Revision:		%I%
#   First Edition:	95/12/06
#   Last Mod.:		%U%, %G%
#
#   Authors:		Jens Hamisch, Jens.Hamisch@Strawberry.COM
#
#   Description:	Testuite testsequence
#   Command:		unuse
#   Sub-Command:
#
#   Comment:	%C{
#			Check removing a path for the list of modulefile
#			paths in $MODULEPATH
#			Also it's not an error to unload a bad dir.
#		}C%
#
##############################################################################

#
# Variables for this test
#

set path "$env(TESTSUITEDIR)/modulefiles.other"
set badpath "$env(TESTSUITEDIR)/modulefiles.bad"
set mod_path "$env(MODULEPATH)"
set bad_use ""

set use	"unuse"

#
# Put a new entry to unuse to the MODULEPATH
#

if { $verbose > 0 } {
    send_user "Setup MODULEPATH = $path:$mod_path\n"
}
set env(MODULEPATH) "$path:$mod_path"


#
# test the bad first
#

testerr_cmd "sh" "$use $badpath" "$bad_use"
testerr_cmd "ksh" "$use $badpath" "$bad_use"
testerr_cmd "zsh" "$use $badpath" "$bad_use"
testerr_cmd "csh" "$use $badpath" "$bad_use"
testerr_cmd "tcsh" "$use $badpath" "$bad_use"
testerr_cmd "perl" "$use $badpath" "$bad_use"
testerr_cmd "cmake" "$use $badpath" "$bad_use"

#
# The tests ...
#   do these last so the .modulesbeginenv is left in a good state for 070-Maint
#

test_cmd "sh" "$use $path" "MODULEPATH=$mod_path ;export MODULEPATH;"
test_cmd "ksh" "$use $path" "MODULEPATH=$mod_path ;export MODULEPATH;"
test_cmd "zsh" "$use $path" "MODULEPATH=$mod_path ;export MODULEPATH;"
test_cmd "csh" "$use $path" "setenv MODULEPATH $mod_path ;"
test_cmd "tcsh" "$use $path" "setenv MODULEPATH $mod_path ;"
test_cmd "perl" "$use $path" "\$ENV{'MODULEPATH'} = '$mod_path';"
test_cmd "cmake" "$use $path" "set(ENV{MODULEPATH} \"$mod_path\")"
#
# Cleanup
#

if { $verbose > 0 } {
    send_user "Resetting MODULEPATH\n"
}
set env(MODULEPATH) "$mod_path"

unset path
unset mod_path
unset use
unset badpath
unset bad_use
