##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.50-cmds/%M%
#   Revision:		%I%
#   First Edition:	2017/11/27
#   Last Mod.:		%U%, %G%
#
#   Authors:		Xavier Delaruelle, xavier.delaruelle@cea.fr
#
#   Description:	Testuite testsequence
#   Command:		load
#   Modulefiles:	info/issaved
#   Sub-Command:
#
#   Comment:	%C{
#			Tests the 'is-saved' modulefile subcommand for all
#			allowed shell types.
#		}C%
#
##############################################################################

set module "info/issaved"
set modulefile "$modpath/$module"

# set HOME to location containing collections
set homewithcoll "$env(HOME)/home"
if { $verbose > 0 } {
    send_user "\tSetup HOME = $homewithcoll\n"
}
set env(HOME) "$homewithcoll"


#
#  The tests
#

lappend ans [list set testsuite1 1]
lappend ans [list set testsuite2 0]
lappend ans [list set testsuite3 0]
lappend ans [list set testsuite4 1]
lappend ans [list set testsuite5 1]
lappend ans [list set testsuite6 1]
lappend ans [list set testsuite7 0]
lappend ans [list setpath LOADEDMODULES $module]
lappend ans [list setpath _LMFILES_ $modulefile]

testouterr_cmd "ALL" "load $module" $ans ""

# define a collection target
if { $verbose > 0 } {
    send_user "\tSetup MODULES_COLLECTION_TARGET = 'target'\n"
}
set env(MODULES_COLLECTION_TARGET) "target"

set ans [list]
lappend ans [list set testsuite1 1]
lappend ans [list set testsuite2 0]
lappend ans [list set testsuite3 0]
lappend ans [list set testsuite4 0]
lappend ans [list set testsuite5 0]
lappend ans [list set testsuite6 0]
lappend ans [list set testsuite7 1]
lappend ans [list setpath LOADEDMODULES $module]
lappend ans [list setpath _LMFILES_ $modulefile]

testouterr_cmd "ALL" "load $module" $ans ""

# define a collection target with no collection related to it
if { $verbose > 0 } {
    send_user "\tSetup MODULES_COLLECTION_TARGET = 'foo'\n"
}
set env(MODULES_COLLECTION_TARGET) "foo"

set ans [list]
lappend ans [list set testsuite1 0]
lappend ans [list set testsuite2 0]
lappend ans [list set testsuite3 0]
lappend ans [list set testsuite4 0]
lappend ans [list set testsuite5 0]
lappend ans [list set testsuite6 0]
lappend ans [list set testsuite7 0]
lappend ans [list setpath LOADEDMODULES $module]
lappend ans [list setpath _LMFILES_ $modulefile]

testouterr_cmd "sh" "load $module" $ans ""


#
#  Cleanup
#

reset_test_env
