##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.70-maint/%M%
#   Revision:		%I%
#   First Edition:	2017/04/17
#   Last Mod.:		%U%, %G%
#
#   Authors:		Xavier Delaruelle, xavier.delaruelle@cea.fr
#
#   Description:	Testuite testsequence
#   Command:		source
#   Modulefiles:	rctosource, rcnomagic, nonexistent
#   Sub-Command:
#
#   Comment:	%C{
#			Tests the module command 'source'
#		}C%
#
##############################################################################

#
#  Test variables
#

set module_1 "$env(TESTSUITEDIR)/home/rctosource"
set module_2 "$env(TESTSUITEDIR)/home/rcnomagic"
set module_3 "$env(TESTSUITEDIR)/home/nonexistent"
set module_4 "$env(TESTSUITEDIR)/modulefiles/bad2/body"

lappend ans [list set testsuite yes]
set err_csh "$error_msgs: File $module_3 does not exist"

lappend ans2 [list set testsuite yes]
lappend ans2 [list ERR]
set err_csh2 [msg_moderr "$msg_invcmdname \"bad-command\"" {bad-command} $module_4 29 {  }]

#
#  test sourcing rc file with regular module-specific magic cookie
#
testouterr_cmd "csh" "source $module_1" $ans ""

#
#  test sourcing rc file with no module-specific magic cookie
#
testouterr_cmd "csh" "source $module_2" $ans ""

#
# test with nonexistent file
#
testouterr_cmd "csh" "source $module_3" "ERR" "$err_csh"

#
# test with broken file
# env is set until reaching Tcl breaking point
testouterr_cmd "csh" "source $module_4" $ans2 "$err_csh2"

#
#  Cleanup
#

reset_test_env
