1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
##############################################################################
# Modules Revision 3.0
# Providing a flexible user environment
#
# File: modules.50-cmds/%M%
# Revision: %I%
# First Edition: 2017/01/27
# Last Mod.: %U%, %G%
#
# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr
#
# Description: Testuite testsequence
# Command: load, display, whatis, search, source, restore
# Command: unload, switch, purge, reload, help, test, reset
# Command: stash, stashpop
# Modulefiles: info/command
# Sub-Command:
#
# Comment: %C{
# Tests the 'module-info command' module subcommand with-
# out own suggestion.
# This command does not change behaviour depending on
# the user shell. Tests are made for the bourne shell
# here.
# }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 "info/command"
set modulefile "$modpath/$module"
set modulefilere "$modpathre/$module"
set header_help "Module Specific Help for $modulefilere:"
set header_test "Module Specific Test for $modulefilere:"
set header "$modlin $modpathre $modlin"
#
# The tests
#
lappend ans [list set _LMFILES_ $modulefile]
lappend ans [list set LOADEDMODULES $module]
lappend ansun [list unset _LMFILES_]
lappend ansun [list unset LOADEDMODULES]
# test loading
testouterr_cmd "sh" "load $module" $ans "load"
skip_if_quick_mode
# test try-loading
testouterr_cmd sh "try-load $module" $ans try-load
# test load-any
testouterr_cmd sh "load-any $module" $ans load-any
# test mod-to-sh
# specific test as this subcmd output shell code on report message channel
set tserr [shell_set sh INFOCMD mod-to-sh]
testouterr_cmd sh "mod-to-sh sh $module" [list [list OK nop]] $tserr
# test reset
setenv_var __MODULES_LMINIT "module use --append $modpath:module load $module"
testouterr_cmd sh reset $ans reset\n[msg_load $module]
unsetenv_var __MODULES_LMINIT
# test stash
setenv_var __MODULES_LMINIT "module use --append $modpath:module load $module"
testouterr_cmd sh stash $ans stash\n[msg_load $module]
unsetenv_var __MODULES_LMINIT
# test stashpop
setenv_loaded_module [list $module] [list $modulefile]
testouterr_cmd sh stashpop $ansun stashpop\n[msg_unload $module]
unsetenv_loaded_module
# test displaying
testouterr_cmd_re "sh" "display $module" "OK" "$modlin\n$modulefilere:\n\ndisplay\n$modlin"
# test whatis
testouterr_cmd_re "sh" "whatis $module" "OK" "$header\n\\s+$module: whatis(\\n\\s+\\S*$module\\S*: .*)*"
# test searching
# error found in interpreted module, so an error code is rendered
testouterr_cmd_re "sh" "search search" "ERR" "$header\n\\s+$module: search(\\n\\s+\\S+: search)*"
# test sourcing
testouterr_cmd "sh" "source $modulefile" "OK" "source"
# set HOME to location containing collections
set homewithcoll "$env(HOME)/home"
if {$verbose} {
send_user "\tSetup HOME = $homewithcoll\n"
}
set env(HOME) "$homewithcoll"
# test restoring
testouterr_cmd "sh" "restore infocmd" $ans restore\n[msg_load $module]
# restore default testsuite home
if {$verbose} {
send_user "\tRestore HOME = $ORIG_HOME\n"
}
set env(HOME) $ORIG_HOME
# Set up the environment for test that require the module to be loaded
setenv_loaded_module $module $modulefile
# test unloading
testouterr_cmd "sh" "unload $module" $ansun "unload"
# test switching
testouterr_cmd "sh" "switch $module $module" $ans "switch\nswitch"
# test refreshing
setenv_var __MODULES_LMREFRESH $module
testouterr_cmd sh refresh OK refresh
unsetenv_var __MODULES_LMREFRESH
# test purging
testouterr_cmd "sh" "purge" $ansun "purge"
# test reloading
testouterr_cmd "sh" "reload" $ans "reload\nreload"
testouterr_cmd "sh" "update" $ans "reload\nreload"
# Clean up the just changed environment
unsetenv_loaded_module
# test help
testouterr_cmd_re "sh" "help $module" "OK" "$modlin\n$header_help\n\nhelp\nhelp\n$modlin"
# test test
testouterr_cmd_re "sh" "test $module" "OK" "$modlin\n$header_test\n\ntest\ntest\nTest result: PASS\n$modlin"
setenv_var MODULEPATH $modpath.4
# test spider
setenv_var TESTSUITE_INFO_COMMAND spider
set tserr "spider\n$modpath.4:\ninfo/command\ninfo/commandexp"
testouterr_cmd sh "spider -t $module" OK $tserr
#
# Cleanup
#
reset_test_env
|