##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.35-trace/%M%
#   Revision:		%I%
#   First Edition:	1995/12/06
#   Last Mod.:		%U%, %G%
#
#   Authors:		Jens Hamisch, Jens.Hamisch@Strawberry.COM
#
#   Description:	Testuite testsequence
#   Command:		load
#   Modulefiles:	trace/colon, trace/disptrac
#   Sub-Command:
#
#   Comment:	%C{
#			Changes tracing on for the module command load' in
#			a way, that tracing is turned on for two subsets of all
#			modulefiles. 
#			This is done by a +' being specified in the pattern
#			passed to the module-trace' subcommand. This should
#			result in some error messages depending on the user
#			level.
#		}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 "trace/colon"
set modulefile "$env(MODULEPATH)/$module"

set disp_module "trace/disptrac"
set disp_modulefile "$env(MODULEPATH)/$disp_module"

set err_colon	"$error_msgs: Tcl command execution failed: module-trace on load -module .*"
set wrn_colon	"$warn_msgs: Spurious colon in pattern .*'"

#
#  setenv commands we expect to see
#

set tr_ap "setenv trace_apropos $trace_apropos ;"
set tr_av "setenv trace_avail $trace_avail ;"
set tr_cl "setenv trace_clear $trace_clear ;"
set tr_di "setenv trace_display $trace_disp ;"
set tr_he "setenv trace_help $trace_help ;"
set tr_in "setenv trace_init $trace_init ;"
set tr_li "setenv trace_list $trace_list ;"
set tr_ld "setenv trace_load +\[\\^/\]\\*/2.0:+\[\\^/\]\\*/3.0:$trace_load ;"
set tr_pu "setenv trace_purge $trace_purge ;"
set tr_sw "setenv trace_switch $trace_switch ;"
set tr_ul "setenv trace_unload $trace_unload ;"
set tr_un "setenv trace_unuse $trace_unuse ;"
set tr_up "setenv trace_update $trace_update ;"
set tr_us "setenv trace_use $trace_use ;"
set tr_wi "setenv trace_whatis $trace_whatis ;"

#
#  We only do check the csh ...
#

set lmf1 "setenv _LMFILES_ $modulefile"
set lm1 "setenv LOADEDMODULES $module"

set lmf "$lmf1:$disp_modulefile ;"
set lm "$lm1:$disp_module ;"

set exp "$lm$lmf$tr_ap$tr_av$tr_cl$tr_di$tr_he$tr_in$tr_li"
set exp "$exp$tr_ld$tr_pu$tr_sw$tr_ul$tr_un$tr_up$tr_us$tr_wi"

set expnov	"$wrn_colon.*$err_colon"
set expadv	"$lmf1 ;$lm1 ;$wrn_colon.*"

#
#  The tests
#

test_cmd "csh" "--user=exp load $module trace/disptrac" "$exp"
testouterr_cmd_re "csh" "--user=nov load $module" "" "$expnov"
testouterr_cmd_re "csh" "--user=adv load $module" "$lm1 ;$lmf1 ;" "$wrn_colon.*"

#
#  Cleanup
#

unset lm1
unset lmf1
unset lm
unset lmf
unset exp
unset expnov
unset expadv

unset err_colon
unset wrn_colon

unset disp_modulefile
unset disp_module

unset modulefile
unset module
