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