##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.20-locate/%M%
#   Revision:		%I%
#   First Edition:	2020/02/04
#   Last Mod.:		%U%, %G%
#
#   Authors:		Xavier Delaruelle, xavier.delaruelle@cea.fr
#
#   Description:	Testuite testsequence
#   Command:		display, avail, load, list, unload, whatis, path,
#                   purge, reload
#   Modulefiles:
#   Sub-Command:
#
#   Comment:	%C{
#           Modulefiles and modulepaths containing a whitespace
#           in their name
#		}C%
#
##############################################################################

# ensure avail tests are made using in depth mode
setenv_var MODULES_AVAIL_INDEPTH 1

# ensure avail tests have implicit default enabled
setenv_var MODULES_IMPLICIT_DEFAULT 1

# ensure regular avail search match is set for these tests
setenv_var MODULES_SEARCH_MATCH starts_with

# ensure auto symbolic versions are not set for these tests
setenv_var MODULES_ADVANCED_VERSION_SPEC 0

set key_sym "\n\nKey:\n(symbolic-version)  "

#
# tests of modules with whitespace in modulepath without whitespace
#
set mp $modpath.2
set mpre $modpathre.2
setenv_path_var MODULEPATH $mp

# unknown module
testouterr_cmd sh {avail -t un\ k} OK {}
testouterr_cmd sh {whatis un\ k} ERR "$err_path'{un k}'"
testouterr_cmd sh {load un\ k} ERR "$err_path'{un k}'"
testouterr_cmd sh {path un\ k} OK "$err_path'{un k}'"
testouterr_cmd sh {display un\ k} ERR "$err_path'{un k}'"

# regular module (wspace in module directory name)
testouterr_cmd sh {avail -t space\ ya/1} OK "$mp:\nspace ya/1(ns)"
testouterr_cmd_re sh {whatis space\ ya/1} OK "$modlin $mpre $modlin\n\\s+space ya/1: space ya/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "space ya/1"]
lappend ans [list setpath _LMFILES_ "$mp/space ya/1"]
lappend ans [list setpath MODULES_LMALTNAME "space ya/1&space ya/ns"]
testouterr_cmd sh {load space\ ya/1} $ans {}
testouterr_cmd sh {path space\ ya/1} [list [list text "{$mp/space ya/1}"]] {}
testouterr_cmd_re sh {display space\ ya/1} OK "$modlin\n$mpre/space ya/1:\n\nmodule-whatis\t{space ya/1}\n$modlin"
setenv_loaded_module [list "space ya/1"] [list "$mp/space ya/1"]
setenv_path_var MODULES_LMALTNAME "space ya/1&space ya/ns"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space ya/1(ns)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ ya/1} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# regular module (wspace in module version)
testouterr_cmd sh {avail -t spacen/2\ s} OK "$mp:\nspacen/2 s"
testouterr_cmd_re sh {whatis spacen/2\ s} OK "$modlin $mpre $modlin\n\\s+spacen/2 s: spacen/2 s"
set ans [list]
lappend ans [list setpath LOADEDMODULES "spacen/2 s"]
lappend ans [list setpath _LMFILES_ "$mp/spacen/2 s"]
testouterr_cmd sh {load spacen/2\ s} $ans {}
testouterr_cmd sh {path spacen/2\ s} [list [list text "{$mp/spacen/2 s}"]] {}
testouterr_cmd_re sh {display spacen/2\ s} OK "$modlin\n$mpre/spacen/2 s:\n\nmodule-whatis\t{spacen/2 s}\n$modlin"
setenv_loaded_module [list "spacen/2 s"] [list "$mp/spacen/2 s"]
testouterr_cmd sh {list} OK "$cur_loaded\n 1) spacen/2 s  "
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
testouterr_cmd sh {unload spacen/2\ s} $ans {}
unsetenv_loaded_module

# alias module (wspace in alias name)
testouterr_cmd sh {avail -t space\ ya/al} OK "$mp:\nspace ya/al(@)"
testouterr_cmd_re sh {whatis space\ ya/al} OK "$modlin $mpre $modlin\n\\s+spacen/1: spacen/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "spacen/1"]
lappend ans [list setpath _LMFILES_ "$mp/spacen/1"]
lappend ans [list setpath MODULES_LMALTNAME "spacen/1&spacen/w s&al|space ya/al"]
testouterr_cmd sh {load space\ ya/al} $ans {}
testouterr_cmd sh {path space\ ya/al} [list [list text "{$mp/spacen/1}"]] {}
testouterr_cmd_re sh {display space\ ya/al} OK "$modlin\n$mpre/spacen/1:\n\nmodule-whatis\tspacen/1\n$modlin"
setenv_loaded_module [list "spacen/1"] [list "$mp/spacen/1"]
setenv_path_var MODULES_LMALTNAME "spacen/1&spacen/w s&al|space ya/al"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) spacen/1(w s)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ ya/al} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# alias module (wspace in alias target)
testouterr_cmd sh {avail -t spacen/al} OK "$mp:\nspacen/al(@)"
testouterr_cmd_re sh {whatis spacen/al} OK "$modlin $mpre $modlin\n\\s+space ya/1: space ya/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "space ya/1"]
lappend ans [list setpath _LMFILES_ "$mp/space ya/1"]
lappend ans [list setpath MODULES_LMALTNAME "space ya/1&space ya/ns&al|spacen/al"]
testouterr_cmd sh {load spacen/al} $ans {}
testouterr_cmd sh {path spacen/al} [list [list text "{$mp/space ya/1}"]] {}
testouterr_cmd_re sh {display spacen/al} OK "$modlin\n$mpre/space ya/1:\n\nmodule-whatis\t{space ya/1}\n$modlin"
setenv_loaded_module [list "space ya/1"] [list "$mp/space ya/1"]
setenv_path_var MODULES_LMALTNAME "space ya/1&space ya/ns&al|spacen/al"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space ya/1(ns)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload spacen/al} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# symbolic version module (wspace in symbol name)
testouterr_cmd sh {avail -t spacen/w\ s} OK "$mp:\nspacen/1(w s)"
testouterr_cmd_re sh {whatis spacen/w\ s} OK "$modlin $mpre $modlin\n\\s+spacen/1: spacen/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "spacen/1"]
lappend ans [list setpath _LMFILES_ "$mp/spacen/1"]
lappend ans [list setpath MODULES_LMALTNAME "spacen/1&spacen/w s"]
testouterr_cmd sh {load spacen/w\ s} $ans {}
testouterr_cmd sh {path spacen/w\ s} [list [list text "{$mp/spacen/1}"]] {}
testouterr_cmd_re sh {display spacen/w\ s} OK "$modlin\n$mpre/spacen/1:\n\nmodule-whatis\tspacen/1\n$modlin"
setenv_loaded_module [list "spacen/1"] [list "$mp/spacen/1"]
setenv_path_var MODULES_LMALTNAME "spacen/1&spacen/w s"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) spacen/1(w s)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload spacen/w\ s} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# symbolic version module (wspace in symbol target)
testouterr_cmd sh {avail -t space\ ya/ns} OK "$mp:\nspace ya/1(ns)"
testouterr_cmd_re sh {whatis space\ ya/ns} OK "$modlin $mpre $modlin\n\\s+space ya/1: space ya/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "space ya/1"]
lappend ans [list setpath _LMFILES_ "$mp/space ya/1"]
lappend ans [list setpath MODULES_LMALTNAME "space ya/1&space ya/ns"]
testouterr_cmd sh {load space\ ya/ns} $ans {}
testouterr_cmd sh {path space\ ya/ns} [list [list text "{$mp/space ya/1}"]] {}
testouterr_cmd_re sh {display space\ ya/ns} OK "$modlin\n$mpre/space ya/1:\n\nmodule-whatis\t{space ya/1}\n$modlin"
setenv_loaded_module [list "space ya/1"] [list "$mp/space ya/1"]
setenv_path_var MODULES_LMALTNAME "space ya/1&space ya/ns"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space ya/1(ns)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ ya/ns} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# default version
testouterr_cmd sh {avail -t space\ ya/default} OK "$mp:\nspace ya/2(default)"
testouterr_cmd_re sh {whatis space\ ya/default} OK "$modlin $mpre $modlin\n\\s+space ya/2: space ya/2"
set ans [list]
lappend ans [list setpath LOADEDMODULES "space ya/2"]
lappend ans [list setpath _LMFILES_ "$mp/space ya/2"]
lappend ans [list setpath MODULES_LMALTNAME "space ya/2&space ya/default&space ya"]
testouterr_cmd sh {load space\ ya} $ans {}
testouterr_cmd sh {path space\ ya} [list [list text "{$mp/space ya/2}"]] {}
testouterr_cmd_re sh {display space\ ya} OK "$modlin\n$mpre/space ya/2:\n\nmodule-whatis\t{space ya/2}\n$modlin"
setenv_loaded_module [list "space ya/2"] [list "$mp/space ya/2"]
setenv_path_var MODULES_LMALTNAME "space ya/2&space ya/default&space ya"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space ya/2(default)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ ya} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# virtual module (wspace in virtual module name)
testouterr_cmd sh {avail -t spacen/vw\ s} OK "$mp:\nspacen/vw s"
testouterr_cmd_re sh {whatis spacen/vw\ s} OK "$modlin $mpre $modlin\n\\s+spacen/vw s: spacen/vw s"
set ans [list]
lappend ans [list setpath LOADEDMODULES "spacen/vw s"]
lappend ans [list setpath _LMFILES_ "$mp/spacen/1"]
testouterr_cmd sh {load spacen/vw\ s} $ans {}
testouterr_cmd sh {path spacen/vw\ s} [list [list text "{$mp/spacen/1}"]] {}
testouterr_cmd_re sh {display spacen/vw\ s} OK "$modlin\n$mpre/spacen/1:\n\nmodule-whatis\t{spacen/vw s}\n$modlin"
setenv_loaded_module [list "spacen/vw s"] [list "$mp/spacen/1"]
testouterr_cmd sh {list} OK "$cur_loaded\n 1) spacen/vw s  "
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
testouterr_cmd sh {unload spacen/vw\ s} $ans {}
unsetenv_loaded_module

# virtual module (wspace in virtual module target)
testouterr_cmd sh {avail -t spacen/vns} OK "$mp:\nspacen/vns"
testouterr_cmd_re sh {whatis spacen/vns} OK "$modlin $mpre $modlin\n\\s+spacen/vns: spacen/vns"
set ans [list]
lappend ans [list setpath LOADEDMODULES "spacen/vns"]
lappend ans [list setpath _LMFILES_ "$mp/space ya/1"]
testouterr_cmd sh {load spacen/vns} $ans {}
testouterr_cmd sh {path spacen/vns} [list [list text "{$mp/space ya/1}"]] {}
testouterr_cmd_re sh {display spacen/vns} OK "$modlin\n$mpre/space ya/1:\n\nmodule-whatis\tspacen/vns\n$modlin"
setenv_loaded_module [list "spacen/vns"] [list "$mp/space ya/1"]
testouterr_cmd sh {list} OK "$cur_loaded\n 1) spacen/vns  "
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
testouterr_cmd sh {unload spacen/vns} $ans {}
unsetenv_loaded_module

# directory with symbol (wspace in symbol name)
testouterr_cmd sh {avail -t spacenb/dw\ s} OK "$mp:\nspacenb/(dw s)\nspacenb/1"
testouterr_cmd_re sh {whatis spacenb/dw\ s} OK "$modlin $mpre $modlin\n\\s+spacenb/1: spacenb/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "spacenb/1"]
lappend ans [list setpath _LMFILES_ "$mp/spacenb/1"]
lappend ans [list setpath MODULES_LMALTNAME "spacenb/1&spacenb/dw s"]
testouterr_cmd sh {load spacenb/dw\ s} $ans {}
testouterr_cmd sh {path spacenb/dw\ s} [list [list text "{$mp/spacenb/1}"]] {}
testouterr_cmd_re sh {display spacenb/dw\ s} OK "$modlin\n$mpre/spacenb/1:\n\nmodule-whatis\tspacenb/1\n$modlin"
setenv_loaded_module [list "spacenb/1"] [list "$mp/spacenb/1"]
setenv_path_var MODULES_LMALTNAME "spacenb/1&spacenb/dw s"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) spacenb/1(dw s)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload spacenb/dw\ s} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# directory with symbol (wspace in directory name)
testouterr_cmd sh {avail -t space\ yb/dns} OK "$mp:\nspace yb/(dns)\nspace yb/1"
testouterr_cmd_re sh {whatis space\ yb/dns} OK "$modlin $mpre $modlin\n\\s+space yb/1: space yb/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "space yb/1"]
lappend ans [list setpath _LMFILES_ "$mp/space yb/1"]
lappend ans [list setpath MODULES_LMALTNAME "space yb/1&space yb/dns"]
testouterr_cmd sh {load space\ yb/dns} $ans {}
testouterr_cmd sh {path space\ yb/dns} [list [list text "{$mp/space yb/1}"]] {}
testouterr_cmd_re sh {display space\ yb/dns} OK "$modlin\n$mpre/space yb/1:\n\nmodule-whatis\t{space yb/1}\n$modlin"
setenv_loaded_module [list "space yb/1"] [list "$mp/space yb/1"]
setenv_path_var MODULES_LMALTNAME "space yb/1&space yb/dns"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space yb/1(dns)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ yb/dns} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# prereq chain with wspace in prereq source or target
# test ReqLo mechanism
set ans [list]
lappend ans [list setpath LOADEDMODULES "space yc/3:spacenc/2:space yc/2"]
lappend ans [list setpath _LMFILES_ "$mp/space yc/3:$mp/spacenc/2:$mp/space yc/2"]
lappend ans [list setpath MODULES_LMPREREQ "spacenc/2&{space yc/3}:space yc/2&spacenc/2"]
lappend ans [list setpath MODULES_LMCONFLICT "space yc/3&spacenc/3"]
lappend ans [list setpath MODULES_LMNOTUASKED "space yc/3:spacenc/2"]
testouterr_cmd_re sh {load --auto space\ yc/2} $ans [msg_top_load {'space yc/2'} {} {{'space yc/3'} {spacenc/2}} {}]
# test DepUn mechanism
setenv_loaded_module [list "space yc/3" "spacenc/2" "space yc/2"] [list "$mp/space yc/3" "$mp/spacenc/2" "$mp/space yc/2"] [list "space yc/3" "spacenc/2"]
setenv_path_var MODULES_LMCONFLICT "space yc/3&spacenc/3"
setenv_path_var MODULES_LMPREREQ "spacenc/2&{space yc/3}:space yc/2&spacenc/2"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMPREREQ]
lappend ans [list unsetpath MODULES_LMNOTUASKED]
lappend ans [list unsetpath MODULES_LMCONFLICT]
testouterr_cmd_re sh {unload --auto space\ yc/3} $ans [msg_top_unload {'space yc/3'} {{'space yc/2'} {spacenc/2}} {} {}]
# test UReqUn mechanism
testouterr_cmd_re sh {unload --auto space\ yc/2} $ans [msg_top_unload {'space yc/2'} {} {{spacenc/2} {'space yc/3'}} {}]

# test purge and reload actions
testouterr_cmd_re sh {purge} $ans {}
set ans [list]
lappend ans [list setpath LOADEDMODULES "space yc/3:spacenc/2:space yc/2"]
lappend ans [list setpath _LMFILES_ "$mp/space yc/3:$mp/spacenc/2:$mp/space yc/2"]
lappend ans [list setpath MODULES_LMNOTUASKED "space yc/3:spacenc/2"]
lappend ans [list setpath MODULES_LMPREREQ "spacenc/2&{space yc/3}:space yc/2&spacenc/2"]
lappend ans [list setpath MODULES_LMCONFLICT "space yc/3&spacenc/3"]
testouterr_cmd_re sh {reload} $ans {}
unsetenv_path_var MODULES_LMPREREQ

# test conflict
testouterr_cmd_re sh {load --auto spacenc/3} ERR [msg_load spacenc/3 [err_conflict space\ yc/3]]
setenv_loaded_module [list "spacenc/3"] [list "$mp/spacenc/3"]
setenv_path_var MODULES_LMCONFLICT "spacenc/3&{space yc/3}"
testouterr_cmd_re sh {load --auto space\ yc/3} ERR [msg_load "'space yc/3'" [err_conflict spacenc/3]]
unsetenv_path_var MODULES_LMCONFLICT

# test OR-prereq
setenv_loaded_module [list "space yc/5"] [list "$mp/space yc/5"]
set ans [list]
lappend ans [list setpath LOADEDMODULES "space yc/5:spacenc/4"]
lappend ans [list setpath _LMFILES_ "$mp/space yc/5:$mp/spacenc/4"]
lappend ans [list setpath MODULES_LMPREREQ "spacenc/4&{space yc/4}|{space yc/5}"]
testouterr_cmd_re sh {load --auto spacenc/4} $ans {}
setenv_loaded_module [list "space yc/5" "spacenc/4"] [list "$mp/space yc/5" "$mp/spacenc/4"]
setenv_path_var MODULES_LMPREREQ "spacenc/4&{space yc/4}|{space yc/5}"
set ans [list]
lappend ans [list setpath LOADEDMODULES "space yc/5:space yc/4:spacenc/4"]
lappend ans [list setpath _LMFILES_ "$mp/space yc/5:$mp/space yc/4:$mp/spacenc/4"]
lappend ans [list setpath MODULES_LMPREREQ "spacenc/4&{space yc/4}|{space yc/5}"]
testouterr_cmd_re sh {load --auto space\ yc/4} $ans [msg_top_load {'space yc/4'} {} {} spacenc/4]
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMPREREQ]
testouterr_cmd_re sh {unload --auto space\ yc/5} $ans [msg_top_unload {'space yc/5'} spacenc/4 {} {}]
setenv_loaded_module [list "space yc/5" "space yc/4" "spacenc/4"] [list "$mp/space yc/5" "$mp/space yc/4" "$mp/spacenc/4"]
set ans [list]
lappend ans [list setpath LOADEDMODULES "space yc/5:spacenc/4"]
lappend ans [list setpath _LMFILES_ "$mp/space yc/5:$mp/spacenc/4"]
lappend ans [list setpath MODULES_LMPREREQ "spacenc/4&{space yc/4}|{space yc/5}"]
testouterr_cmd_re sh {unload --auto space\ yc/4} $ans [msg_top_unload {'space yc/4'} {} {} spacenc/4]
unsetenv_loaded_module
unsetenv_path_var MODULES_LMPREREQ

# ml command tests
set ans [list]
lappend ans [list setpath LOADEDMODULES "space ya/2"]
lappend ans [list setpath _LMFILES_ "$mp/space ya/2"]
lappend ans [list setpath MODULES_LMALTNAME "space ya/2&space ya/default&space ya"]
testouterr_cmd_re sh {ml space\ ya} $ans {}
setenv_loaded_module [list "space ya/2"] [list "$mp/space ya/2"]
setenv_path_var MODULES_LMALTNAME "space ya/2&space ya/default&space ya"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {ml -space\ ya} $ans {}
set ans [list]
lappend ans [list setpath LOADEDMODULES "space yc/5"]
lappend ans [list setpath _LMFILES_ "$mp/space yc/5"]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd_re sh {ml -space\ ya space\ yc} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# implicit_default tests (if config not locked)
if {![is_config_locked implicit_default]} {
    setenv_var MODULES_IMPLICIT_DEFAULT 0
    set ans [list]
    lappend ans [list setpath LOADEDMODULES "space ya/2"]
    lappend ans [list setpath _LMFILES_ "$mp/space ya/2"]
    lappend ans [list setpath MODULES_LMALTNAME "space ya/2&space ya/default&space ya"]
    testouterr_cmd sh {load space\ ya} $ans {}
    testouterr_cmd sh {load space\ yb} ERR "$err_nodefault'space yb'"
    setenv_var MODULES_IMPLICIT_DEFAULT 1
}


#
# tests of modules without whitespace in modulepath with whitespace
#
set mp "$modpath wspace"
set mpre "$modpathre wspace"
if {!$is_symlink_supported} {
    send_user "\tskipping tests over '$mp' modulepath as symbolic links are not supported on filesystem\n"
} else {

setenv_path_var MODULEPATH $mp

# unknown module
testouterr_cmd sh {avail -t un\ k} OK {}
testouterr_cmd sh {whatis un\ k} ERR "$err_path'{un k}'"
testouterr_cmd sh {load un\ k} ERR "$err_path'{un k}'"
testouterr_cmd sh {path un\ k} OK "$err_path'{un k}'"
testouterr_cmd sh {display un\ k} ERR "$err_path'{un k}'"

# regular module (wspace in module directory name)
testouterr_cmd sh {avail -t space\ ya/1} OK "$mp:\nspace ya/1(ns)"
testouterr_cmd_re sh {whatis space\ ya/1} OK "$modlin $mpre $modlin\n\\s+space ya/1: space ya/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "space ya/1"]
lappend ans [list setpath _LMFILES_ "$mp/space ya/1"]
lappend ans [list setpath MODULES_LMALTNAME "space ya/1&space ya/ns"]
testouterr_cmd sh {load space\ ya/1} $ans {}
testouterr_cmd sh {path space\ ya/1} [list [list text "{$mp/space ya/1}"]] {}
testouterr_cmd_re sh {display space\ ya/1} OK "$modlin\n$mpre/space ya/1:\n\nmodule-whatis\t{space ya/1}\n$modlin"
setenv_loaded_module [list "space\ ya/1"] [list "$mp/space ya/1"]
setenv_path_var MODULES_LMALTNAME "space ya/1&space ya/ns"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space ya/1(ns)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ ya/1} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# regular module (wspace in module version)
testouterr_cmd sh {avail -t spacen/2\ s} OK "$mp:\nspacen/2 s"
testouterr_cmd_re sh {whatis spacen/2\ s} OK "$modlin $mpre $modlin\n\\s+spacen/2 s: spacen/2 s"
set ans [list]
lappend ans [list setpath LOADEDMODULES "spacen/2 s"]
lappend ans [list setpath _LMFILES_ "$mp/spacen/2 s"]
testouterr_cmd sh {load spacen/2\ s} $ans {}
testouterr_cmd sh {path spacen/2\ s} [list [list text "{$mp/spacen/2 s}"]] {}
testouterr_cmd_re sh {display spacen/2\ s} OK "$modlin\n$mpre/spacen/2 s:\n\nmodule-whatis\t{spacen/2 s}\n$modlin"
setenv_loaded_module [list "spacen/2 s"] [list "$mp/spacen/2 s"]
testouterr_cmd sh {list} OK "$cur_loaded\n 1) spacen/2 s  "
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
testouterr_cmd sh {unload spacen/2\ s} $ans {}
unsetenv_loaded_module

# alias module (wspace in alias name)
testouterr_cmd sh {avail -t space\ ya/al} OK "$mp:\nspace ya/al(@)"
testouterr_cmd_re sh {whatis space\ ya/al} OK "$modlin $mpre $modlin\n\\s+spacen/1: spacen/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "spacen/1"]
lappend ans [list setpath _LMFILES_ "$mp/spacen/1"]
lappend ans [list setpath MODULES_LMALTNAME "spacen/1&spacen/w s&al|space ya/al"]
testouterr_cmd sh {load space\ ya/al} $ans {}
testouterr_cmd sh {path space\ ya/al} [list [list text "{$mp/spacen/1}"]] {}
testouterr_cmd_re sh {display space\ ya/al} OK "$modlin\n$mpre/spacen/1:\n\nmodule-whatis\tspacen/1\n$modlin"
setenv_loaded_module [list "spacen/1"] [list "$mp/spacen/1"]
setenv_path_var MODULES_LMALTNAME "spacen/1&spacen/w s&al|space ya/al"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) spacen/1(w s)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ ya/al} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# alias module (wspace in alias target)
testouterr_cmd sh {avail -t spacen/al} OK "$mp:\nspacen/al(@)"
testouterr_cmd_re sh {whatis spacen/al} OK "$modlin $mpre $modlin\n\\s+space ya/1: space ya/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "space ya/1"]
lappend ans [list setpath _LMFILES_ "$mp/space ya/1"]
lappend ans [list setpath MODULES_LMALTNAME "space ya/1&space ya/ns&al|spacen/al"]
testouterr_cmd sh {load spacen/al} $ans {}
testouterr_cmd sh {path spacen/al} [list [list text "{$mp/space ya/1}"]] {}
testouterr_cmd_re sh {display spacen/al} OK "$modlin\n$mpre/space ya/1:\n\nmodule-whatis\t{space ya/1}\n$modlin"
setenv_loaded_module [list "space ya/1"] [list "$mp/space ya/1"]
setenv_path_var MODULES_LMALTNAME "space ya/1&space ya/ns&al|spacen/al"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space ya/1(ns)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload spacen/al} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# symbolic version module (wspace in symbol name)
testouterr_cmd sh {avail -t spacen/w\ s} OK "$mp:\nspacen/1(w s)"
testouterr_cmd_re sh {whatis spacen/w\ s} OK "$modlin $mpre $modlin\n\\s+spacen/1: spacen/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "spacen/1"]
lappend ans [list setpath _LMFILES_ "$mp/spacen/1"]
lappend ans [list setpath MODULES_LMALTNAME "spacen/1&spacen/w s"]
testouterr_cmd sh {load spacen/w\ s} $ans {}
testouterr_cmd sh {path spacen/w\ s} [list [list text "{$mp/spacen/1}"]] {}
testouterr_cmd_re sh {display spacen/w\ s} OK "$modlin\n$mpre/spacen/1:\n\nmodule-whatis\tspacen/1\n$modlin"
setenv_loaded_module [list "spacen/1"] [list "$mp/spacen/1"]
setenv_path_var MODULES_LMALTNAME "spacen/1&spacen/w s"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) spacen/1(w s)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload spacen/w\ s} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# symbolic version module (wspace in symbol target)
testouterr_cmd sh {avail -t space\ ya/ns} OK "$mp:\nspace ya/1(ns)"
testouterr_cmd_re sh {whatis space\ ya/ns} OK "$modlin $mpre $modlin\n\\s+space ya/1: space ya/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "space ya/1"]
lappend ans [list setpath _LMFILES_ "$mp/space ya/1"]
lappend ans [list setpath MODULES_LMALTNAME "space ya/1&space ya/ns"]
testouterr_cmd sh {load space\ ya/ns} $ans {}
testouterr_cmd sh {path space\ ya/ns} [list [list text "{$mp/space ya/1}"]] {}
testouterr_cmd_re sh {display space\ ya/ns} OK "$modlin\n$mpre/space ya/1:\n\nmodule-whatis\t{space ya/1}\n$modlin"
setenv_loaded_module [list "space ya/1"] [list "$mp/space ya/1"]
setenv_path_var MODULES_LMALTNAME "space ya/1&space ya/ns"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space ya/1(ns)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ ya/ns} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# default version
testouterr_cmd sh {avail -t space\ ya/default} OK "$mp:\nspace ya/2(default)"
testouterr_cmd_re sh {whatis space\ ya/default} OK "$modlin $mpre $modlin\n\\s+space ya/2: space ya/2"
set ans [list]
lappend ans [list setpath LOADEDMODULES "space ya/2"]
lappend ans [list setpath _LMFILES_ "$mp/space ya/2"]
lappend ans [list setpath MODULES_LMALTNAME "space ya/2&space ya/default&space ya"]
testouterr_cmd sh {load space\ ya} $ans {}
testouterr_cmd sh {path space\ ya} [list [list text "{$mp/space ya/2}"]] {}
testouterr_cmd_re sh {display space\ ya} OK "$modlin\n$mpre/space ya/2:\n\nmodule-whatis\t{space ya/2}\n$modlin"
setenv_loaded_module [list "space ya/2"] [list "$mp/space ya/2"]
setenv_path_var MODULES_LMALTNAME "space ya/2&space ya/default&space ya"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space ya/2(default)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ ya} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# virtual module (wspace in virtual module name)
testouterr_cmd sh {avail -t spacen/vw\ s} OK "$mp:\nspacen/vw s"
testouterr_cmd_re sh {whatis spacen/vw\ s} OK "$modlin $mpre $modlin\n\\s+spacen/vw s: spacen/vw s"
set ans [list]
lappend ans [list setpath LOADEDMODULES "spacen/vw s"]
lappend ans [list setpath _LMFILES_ "$mp/spacen/1"]
testouterr_cmd sh {load spacen/vw\ s} $ans {}
testouterr_cmd sh {path spacen/vw\ s} [list [list text "{$mp/spacen/1}"]] {}
testouterr_cmd_re sh {display spacen/vw\ s} OK "$modlin\n$mpre/spacen/1:\n\nmodule-whatis\t{spacen/vw s}\n$modlin"
setenv_loaded_module [list "spacen/vw s"] [list "$mp/spacen/1"]
testouterr_cmd sh {list} OK "$cur_loaded\n 1) spacen/vw s  "
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
testouterr_cmd sh {unload spacen/vw\ s} $ans {}
unsetenv_loaded_module

# virtual module (wspace in virtual module target)
testouterr_cmd sh {avail -t spacen/vns} OK "$mp:\nspacen/vns"
testouterr_cmd_re sh {whatis spacen/vns} OK "$modlin $mpre $modlin\n\\s+spacen/vns: spacen/vns"
set ans [list]
lappend ans [list setpath LOADEDMODULES "spacen/vns"]
lappend ans [list setpath _LMFILES_ "$mp/space ya/1"]
testouterr_cmd sh {load spacen/vns} $ans {}
testouterr_cmd sh {path spacen/vns} [list [list text "{$mp/space ya/1}"]] {}
testouterr_cmd_re sh {display spacen/vns} OK "$modlin\n$mpre/space ya/1:\n\nmodule-whatis\tspacen/vns\n$modlin"
setenv_loaded_module [list "spacen/vns"] [list "$mp/space ya/1"]
testouterr_cmd sh {list} OK "$cur_loaded\n 1) spacen/vns  "
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
testouterr_cmd sh {unload spacen/vns} $ans {}
unsetenv_loaded_module

# directory with symbol (wspace in symbol name)
testouterr_cmd sh {avail -t spacenb/dw\ s} OK "$mp:\nspacenb/(dw s)\nspacenb/1"
testouterr_cmd_re sh {whatis spacenb/dw\ s} OK "$modlin $mpre $modlin\n\\s+spacenb/1: spacenb/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "spacenb/1"]
lappend ans [list setpath _LMFILES_ "$mp/spacenb/1"]
lappend ans [list setpath MODULES_LMALTNAME "spacenb/1&spacenb/dw s"]
testouterr_cmd sh {load spacenb/dw\ s} $ans {}
testouterr_cmd sh {path spacenb/dw\ s} [list [list text "{$mp/spacenb/1}"]] {}
testouterr_cmd_re sh {display spacenb/dw\ s} OK "$modlin\n$mpre/spacenb/1:\n\nmodule-whatis\tspacenb/1\n$modlin"
setenv_loaded_module [list "spacenb/1"] [list "$mp/spacenb/1"]
setenv_path_var MODULES_LMALTNAME "spacenb/1&spacenb/dw s"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) spacenb/1(dw s)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload spacenb/dw\ s} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# directory with symbol (wspace in directory name)
testouterr_cmd sh {avail -t space\ yb/dns} OK "$mp:\nspace yb/(dns)\nspace yb/1"
testouterr_cmd_re sh {whatis space\ yb/dns} OK "$modlin $mpre $modlin\n\\s+space yb/1: space yb/1"
set ans [list]
lappend ans [list setpath LOADEDMODULES "space yb/1"]
lappend ans [list setpath _LMFILES_ "$mp/space yb/1"]
lappend ans [list setpath MODULES_LMALTNAME "space yb/1&space yb/dns"]
testouterr_cmd sh {load space\ yb/dns} $ans {}
testouterr_cmd sh {path space\ yb/dns} [list [list text "{$mp/space yb/1}"]] {}
testouterr_cmd_re sh {display space\ yb/dns} OK "$modlin\n$mpre/space yb/1:\n\nmodule-whatis\t{space yb/1}\n$modlin"
setenv_loaded_module [list "space yb/1"] [list "$mp/space yb/1"]
setenv_path_var MODULES_LMALTNAME "space yb/1&space yb/dns"
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space yb/1(dns)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ yb/dns} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

}

#
# tests of modules finishing with whitespace in modulepath finishing by a whitespace
#
set mp "$modpath wspac "
set mpre "$modpathre wspac "
# create modulepath finishing by space on the file (it crashes git checkout on Windows if saved in repo)
if {!$is_symlink_supported || [catch {file link -symbolic $mp modulefiles.2}]} {
    send_user "\tskipping tests over '$mp' modulepath as symbolic links are not supported on filesystem\n"
} else {

# generate modulefiles that cannot be recorded in git repository
create_endspace_test_modulefiles

setenv_path_var MODULEPATH $mp

# unknown module
testouterr_cmd sh {avail -t un\ k} OK {}
testouterr_cmd sh {whatis un\ k} ERR "$err_path'{un k}'"
testouterr_cmd sh {load un\ k} ERR "$err_path'{un k}'"
testouterr_cmd sh {path un\ k} OK "$err_path'{un k}'"
testouterr_cmd sh {display un\ k} ERR "$err_path'{un k}'"

# add another modulepath
set ans [list]
lappend ans [list setpath MODULEPATH "$modpath:$mp"]
testouterr_cmd_re sh "use $modpath" $ans {}
set ans [list]
lappend ans [list unsetpath MODULEPATH]
testouterr_cmd sh "unuse $modpath\\ wspac\\ " $ans {}

# module whose name and target finish with space character
testouterr_cmd sh {avail -t space\ y\ /1\ } OK "$mp:\nspace y /1 (n )"
testouterr_cmd_re sh {whatis space\ y\ /1\ } OK "$modlin $mpre $modlin\n\\s+space y /1 : space y /1 "
set ans [list]
lappend ans [list setpath LOADEDMODULES "space y /1 "]
lappend ans [list setpath _LMFILES_ "$mp/space y /1 "]
lappend ans [list setpath MODULES_LMALTNAME "space y /1 &space y /n &al|space y /a "]
testouterr_cmd sh {load space\ y\ /1\ } $ans {}
testouterr_cmd sh {path space\ y\ /1\ } [list [list text "{$mp/space y /1 }"]] {}
testouterr_cmd_re sh {display space\ y\ /1\ } OK "$modlin\n$mpre/space y /1 :\n\nmodule-whatis\t{space y /1 }\n$modlin"
setenv_loaded_module [list "space\ y\ /1 "] [list "$mp/space y /1 "]
setenv_path_var MODULES_LMALTNAME "space y /1 &space y /n &al|space y /a "
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space y /1 (n )  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ y\ /1\ } $ans {}
# add another module
set ans [list]
lappend ans [list setpath LOADEDMODULES "space y /1 :space y /2.2"]
lappend ans [list setpath _LMFILES_ "$mp/space y /1 :$mp/space y /2.2"]
lappend ans [list setpath MODULES_LMALTNAME "space y /1 &space y /n &al|space y /a :space y /2.2&space y /default&space y "]
testouterr_cmd_re sh {load space\ y\ /2.2} $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# alias whose name and target finish with space character
testouterr_cmd sh {avail -t space\ y\ /a\ } OK "$mp:\nspace y /a (@)"
testouterr_cmd_re sh {whatis space\ y\ /a\ } OK "$modlin $mpre $modlin\n\\s+space y /1 : space y /1 "
set ans [list]
lappend ans [list setpath LOADEDMODULES "space y /1 "]
lappend ans [list setpath _LMFILES_ "$mp/space y /1 "]
lappend ans [list setpath MODULES_LMALTNAME "space y /1 &space y /n &al|space y /a "]
testouterr_cmd sh {load space\ y\ /a\ } $ans {}
testouterr_cmd sh {path space\ y\ /a\ } [list [list text "{$mp/space y /1 }"]] {}
testouterr_cmd_re sh {display space\ y\ /a\ } OK "$modlin\n$mpre/space y /1 :\n\nmodule-whatis\t{space y /1 }\n$modlin"
setenv_loaded_module [list "space y /1 "] [list "$mp/space y /1 "]
setenv_path_var MODULES_LMALTNAME "space y /1 &space y /n &al|space y /a "
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space y /1 (n )  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ y\ /a\ } $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# symbolic version whose name and target finish with space character
testouterr_cmd sh {avail -t space\ y\ /n\ } OK "$mp:\nspace y /1 (n )"
testouterr_cmd_re sh {whatis space\ y\ /n\ } OK "$modlin $mpre $modlin\n\\s+space y /1 : space y /1 "
set ans [list]
lappend ans [list setpath LOADEDMODULES "space y /1 "]
lappend ans [list setpath _LMFILES_ "$mp/space y /1 "]
lappend ans [list setpath MODULES_LMALTNAME "space y /1 &space y /n &al|space y /a "]
testouterr_cmd sh {load space\ y\ /n\ } $ans {}
testouterr_cmd sh {path space\ y\ /n\ } [list [list text "{$mp/space y /1 }"]] {}
testouterr_cmd_re sh {display space\ y\ /n\ } OK "$modlin\n$mpre/space y /1 :\n\nmodule-whatis\t{space y /1 }\n$modlin"
setenv_loaded_module [list "space y /1 "] [list "$mp/space y /1 "]
setenv_path_var MODULES_LMALTNAME "space y /1 &space y /n &al|space y /a "
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space y /1 (n )  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ y\ /n\ } $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# default version
testouterr_cmd sh {avail -t space\ y\ /default} OK "$mp:\nspace y /2.2(default)"
testouterr_cmd_re sh {whatis space\ y\ /default} OK "$modlin $mpre $modlin\n\\s+space y /2.2: space y /2.2"
set ans [list]
lappend ans [list setpath LOADEDMODULES "space y /2.2"]
lappend ans [list setpath _LMFILES_ "$mp/space y /2.2"]
lappend ans [list setpath MODULES_LMALTNAME "space y /2.2&space y /default&space y "]
testouterr_cmd sh {load space\ y\ } $ans {}
testouterr_cmd sh {path space\ y\ } [list [list text "{$mp/space y /2.2}"]] {}
testouterr_cmd_re sh {display space\ y\ } OK "$modlin\n$mpre/space y /2.2:\n\nmodule-whatis\t{space y /2.2}\n$modlin"
setenv_loaded_module [list "space y /2.2"] [list "$mp/space y /2.2"]
setenv_path_var MODULES_LMALTNAME "space y /2.2&space y /default&space y "
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space y /2.2(default)  $key_sym"
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
lappend ans [list unsetpath MODULES_LMALTNAME]
testouterr_cmd sh {unload space\ y\ } $ans {}
unsetenv_loaded_module
unsetenv_path_var MODULES_LMALTNAME

# virtual module whose name and target finish with space character
testouterr_cmd sh {avail -t space\ y\ /v\ } OK "$mp:\nspace y /v "
testouterr_cmd_re sh {whatis space\ y\ /v\ } OK "$modlin $mpre $modlin\n\\s+space y /v : space y /v "
set ans [list]
lappend ans [list setpath LOADEDMODULES "space y /v "]
lappend ans [list setpath _LMFILES_ "$mp/space y /1 "]
testouterr_cmd sh {load space\ y\ /v\ } $ans {}
testouterr_cmd sh {path space\ y\ /v\ } [list [list text "{$mp/space y /1 }"]] {}
testouterr_cmd_re sh {display space\ y\ /v\ } OK "$modlin\n$mpre/space y /1 :\n\nmodule-whatis\t{space y /v }\n$modlin"
setenv_loaded_module [list "space y /v "] [list "$mp/space y /1 "]
testouterr_cmd sh {list} OK "$cur_loaded\n 1) space y /v   "
set ans [list]
lappend ans [list unsetpath LOADEDMODULES]
lappend ans [list unsetpath _LMFILES_]
testouterr_cmd sh {unload space\ y\ /v\ } $ans {}
unsetenv_loaded_module

# delete modulepath link created for the test
file delete $mp

# delete generated modulefiles
delete_endspace_test_modulefiles

}


#
#  Cleanup
#

reset_test_env
