##############################################################################
#   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:		use -append
#   Sub-Command:
#
#   Comment:	%C{
#			Check appending a new path to the current lists of
#			module paths.
#		}C%
#
##############################################################################

#
# Variables for this test
#

set path "$modpath.2"
set badpath "$modpath.bad"
set mod_path "$modpath:$path"
set bad_use "$error_msgs: Directory '$badpath' not found"
set loaded_path "$modpath"

set use	"use --append"

#
# The tests ...
#

lappend ans [list setpath MODULEPATH $mod_path]
test_cmd_re "ALL" "$use $path" $ans

#
# test if use non-existent modulefile directory
#

testouterr_cmd "ALL" "$use $badpath" "ERR" "$bad_use"

#
# test with uninitialized MODULEPATH
#

unsetenv_path_var MODULEPATH

set ans [list]
lappend ans [list setpath MODULEPATH $path]
test_cmd_re "ALL" "$use $path" $ans

setenv_path_var MODULEPATH $modpath

#
# test with already loaded path
# re-export and increase reference count (C version does no modification)
#
set ans [list]
lappend ans [list set MODULEPATH_modshare "$loaded_path:2"]
lappend ans [list set MODULEPATH $loaded_path]
test_cmd "ALL" "$use $loaded_path" $ans

#
# Cleanup
#

reset_test_env
