| 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: 1995/12/06 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Jens Hamisch, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: unload |
| 14 |
# Modulefiles: remove/2.0 |
| 15 |
# Sub-Command: |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Tests the reverse 'remove-path' module subcommand for |
| 19 |
# all allowed shell types. |
| 20 |
# }C% |
| 21 |
# |
| 22 |
# Trouble: %T{ |
| 23 |
# Removal of a 'remove-path' command *SHOULD* result in |
| 24 |
# the once removed path being restored. |
| 25 |
# |
| 26 |
# To be discussed: |
| 27 |
# |
| 28 |
# - We cannot determine, if the path really *HAS |
| 29 |
# BEEN* removed or if the part to be removed has |
| 30 |
# never been part of the path |
| 31 |
# }T% |
| 32 |
# |
| 33 |
############################################################################## |
| 34 |
|
| 35 |
skip_if_quick_mode |
| 36 |
|
| 37 |
# |
| 38 |
# Variables. This test forces a module unload command. It will result in the |
| 39 |
# environment variables "_LMFILES_", "LOADEDMODULES" and "PATH" to |
| 40 |
# be set up |
| 41 |
# |
| 42 |
|
| 43 |
set module "remove/2.0" |
| 44 |
set modulefile "$modpath/$module" |
| 45 |
|
| 46 |
set old_path $env(PATH) |
| 47 |
set ts_path "/this/is/the/modules/testsuite" |
| 48 |
set new_path "$old_path:$ts_path" |
| 49 |
|
| 50 |
# |
| 51 |
# Set up the environment for reversal ... |
| 52 |
# |
| 53 |
|
| 54 |
setenv_loaded_module $module $modulefile |
| 55 |
|
| 56 |
# |
| 57 |
# For the different shells ... |
| 58 |
# |
| 59 |
|
| 60 |
lappend ans [list unset _LMFILES_] |
| 61 |
lappend ans [list unset LOADEDMODULES] |
| 62 |
|
| 63 |
# |
| 64 |
# The tests |
| 65 |
# |
| 66 |
|
| 67 |
test_cmd "ALL" "unload $module" $ans |
| 68 |
|
| 69 |
# |
| 70 |
# Try bad argument list: missing variable name |
| 71 |
# |
| 72 |
|
| 73 |
set module "remove/0.3" |
| 74 |
set modulefile "$modpath/$module" |
| 75 |
setenv_loaded_module $module $modulefile |
| 76 |
set ts_err [msg_moderr "remove-path $msg_needenvvarname" {remove-path } $modulefile 24] |
| 77 |
testouterr_cmd "sh" "unload $module" "ERR" [msg_unload $module $ts_err] |
| 78 |
|
| 79 |
# |
| 80 |
# Try bad argument list: missing variable value |
| 81 |
# |
| 82 |
|
| 83 |
set module "remove/0.4" |
| 84 |
set modulefile "$modpath/$module" |
| 85 |
setenv_loaded_module $module $modulefile |
| 86 |
set ts_err [msg_moderr "remove-path $msg_needenvvarval PATH" {remove-path PATH} $modulefile 24] |
| 87 |
testouterr_cmd "sh" "unload $module" "ERR" [msg_unload $module $ts_err] |
| 88 |
|
| 89 |
# |
| 90 |
# Try bad argument list: empty variable name |
| 91 |
# |
| 92 |
|
| 93 |
set module "remove/0.5" |
| 94 |
set modulefile "$modpath/$module" |
| 95 |
setenv_loaded_module $module $modulefile |
| 96 |
set ts_err [msg_moderr "remove-path $msg_validenvvarname" {remove-path {}} $modulefile 24] |
| 97 |
testouterr_cmd "sh" "unload $module" "ERR" [msg_unload $module $ts_err] |
| 98 |
|
| 99 |
# |
| 100 |
# Try command switches passed after variable name |
| 101 |
# |
| 102 |
|
| 103 |
setenv_path_var testsuite --delim=, |
| 104 |
setenv_path_var testsuite2 , foo |
| 105 |
set module "remove/1.8" |
| 106 |
set modulefile "$modpath/$module" |
| 107 |
setenv_loaded_module $module $modulefile |
| 108 |
set ans [list] |
| 109 |
lappend ans [list unset _LMFILES_] |
| 110 |
lappend ans [list unset LOADEDMODULES] |
| 111 |
testouterr_cmd_re "sh" "unload $module" $ans {} |
| 112 |
unsetenv_path_var testsuite |
| 113 |
unsetenv_path_var testsuite2 |
| 114 |
|
| 115 |
|
| 116 |
# |
| 117 |
# Remove multiple paths passed as one string |
| 118 |
# |
| 119 |
|
| 120 |
set module "remove/2.3" |
| 121 |
set modulefile "$modpath/$module" |
| 122 |
|
| 123 |
set env(__MODULES_SHARE_FOO) "/path/to/dir1:1" |
| 124 |
set env(FOO) "/path/to/dir1" |
| 125 |
setenv_loaded_module $module $modulefile |
| 126 |
|
| 127 |
set ans [list] |
| 128 |
lappend ans [list unset _LMFILES_] |
| 129 |
lappend ans [list unset LOADEDMODULES] |
| 130 |
|
| 131 |
testouterr_cmd "sh" "unload $module" $ans "" |
| 132 |
|
| 133 |
# |
| 134 |
# Remove multiple paths passed as multiple strings |
| 135 |
# |
| 136 |
|
| 137 |
set module "remove/2.4" |
| 138 |
set modulefile "$modpath/$module" |
| 139 |
setenv_loaded_module $module $modulefile |
| 140 |
|
| 141 |
testouterr_cmd "sh" "unload $module" $ans "" |
| 142 |
|
| 143 |
# |
| 144 |
# Try pass invalid option to remove-path |
| 145 |
# |
| 146 |
|
| 147 |
set module remove/8.0 |
| 148 |
set modulefile $modpath/$module |
| 149 |
setenv_loaded_module $module $modulefile |
| 150 |
set ts_err [msg_moderr {invalid option '-delim=,' for remove-path} {remove-path -delim=, FOO bar} $modulefile 2] |
| 151 |
testouterr_cmd sh "unload $module" ERR [msg_unload $module $ts_err] |
| 152 |
|
| 153 |
# |
| 154 |
# Cleanup |
| 155 |
# |
| 156 |
|
| 157 |
reset_test_env |