| 1 |
############################################################################## |
| 2 |
# Modules Revision 3.0 |
| 3 |
# Providing a flexible user environment |
| 4 |
# |
| 5 |
# File: modules.70-maint/%M% |
| 6 |
# Revision: %I% |
| 7 |
# First Edition: 95/12/06 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Jens Hamisch, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: display |
| 14 |
# Modulefiles: help/2.0, bad |
| 15 |
# Sub-Command: |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Tests the module command 'display' |
| 19 |
# }C% |
| 20 |
# |
| 21 |
############################################################################## |
| 22 |
|
| 23 |
# skip tests if implicit_default option could not be overridden |
| 24 |
if {[is_config_locked implicit_default]} { |
| 25 |
send_user "\tskipping tests as implicit_default could not be overridden\n" |
| 26 |
} else { |
| 27 |
|
| 28 |
# ensure avail tests have implicit default enabled |
| 29 |
setenv_var MODULES_IMPLICIT_DEFAULT 1 |
| 30 |
|
| 31 |
# |
| 32 |
# Test variables |
| 33 |
# |
| 34 |
|
| 35 |
set module_1 "help" |
| 36 |
set modulefile_1 "$modpath/help/2.0" |
| 37 |
set modulefile_1_reld "$reldmodpath/help/2.0" |
| 38 |
set modulefile_1_reldd "$relddmodpath/help/2.0" |
| 39 |
set module_2 "NonExistent" |
| 40 |
set module_3 "bad" |
| 41 |
set module_4 "test" |
| 42 |
set module_5 "bad2" |
| 43 |
set modulefile_5 "$modpath/$module_5/proc" |
| 44 |
set modulefile_5_reld "$reldmodpath/$module_5/proc" |
| 45 |
set modulefile_5_reldd "$relddmodpath/$module_5/proc" |
| 46 |
set module_6 "setenv/1.0" |
| 47 |
set modulefile_6 "$modpath/setenv/1.0" |
| 48 |
|
| 49 |
# different behavior than C-version: on Tcl-version 'module-log', 'module-verbosity' |
| 50 |
# and 'module-user' commandq are not handled and will always return a warning message |
| 51 |
# to inform the user. Moreover 'x-resource' commands are displayed as defined in |
| 52 |
# modulefile and not displayed as a 'xrdb' command like on C-version |
| 53 |
set out_pat "$modlin |
| 54 |
$modpathre/help/2.0: |
| 55 |
|
| 56 |
set-alias\tal-testsuite {ps -auxww | grep modulecmd} |
| 57 |
unset-alias\tal-testsuite |
| 58 |
setenv\t\ttestsuite yes |
| 59 |
append-path\ttestsuite no |
| 60 |
prepend-path\ttestsuite maybe |
| 61 |
remove-path\ttestsuite yes |
| 62 |
unsetenv\ttestsuite |
| 63 |
x-resource\tmy-prog*my-ress\ttrue |
| 64 |
module-user\tadvanced |
| 65 |
module-verbosity\ton |
| 66 |
module-log\ttrace local7.info |
| 67 |
module-trace\ton |
| 68 |
system\t\tls |
| 69 |
module load\tsetenv/1.0 |
| 70 |
module-alias\tfoo setenv/1.0 |
| 71 |
module-version\tfoo foo bar blah |
| 72 |
module-whatis\t{Some checks for HELP and DISPLAY} |
| 73 |
$modlin" |
| 74 |
set out_debug_pat "((DEBUG|Evaluate modulerc:|Evaluate modulefile:|Get modules:) .*)+ |
| 75 |
$modlin |
| 76 |
$modpathre/help/2.0: |
| 77 |
|
| 78 |
((DEBUG|Evaluate modulerc:|Evaluate modulefile:|Get modules:) .*)+ |
| 79 |
set-alias\tal-testsuite {ps -auxww | grep modulecmd} |
| 80 |
(DEBUG .*)+ |
| 81 |
unset-alias\tal-testsuite |
| 82 |
(DEBUG .*)+ |
| 83 |
setenv\t\ttestsuite yes |
| 84 |
(DEBUG .*)+ |
| 85 |
append-path\ttestsuite no |
| 86 |
(DEBUG .*)+ |
| 87 |
prepend-path\ttestsuite maybe |
| 88 |
(DEBUG .*)+ |
| 89 |
remove-path\ttestsuite yes |
| 90 |
(DEBUG .*)+ |
| 91 |
unsetenv\ttestsuite |
| 92 |
(DEBUG .*)+ |
| 93 |
x-resource\tmy-prog*my-ress\ttrue |
| 94 |
(DEBUG .*)+ |
| 95 |
module-user\tadvanced |
| 96 |
module-verbosity\ton |
| 97 |
module-log\ttrace local7.info |
| 98 |
module-trace\ton |
| 99 |
(DEBUG .*)+ |
| 100 |
system\t\tls |
| 101 |
(DEBUG .*)+ |
| 102 |
module load\tsetenv/1.0 |
| 103 |
(DEBUG .*)+ |
| 104 |
module-alias\tfoo setenv/1.0 |
| 105 |
(DEBUG .*)+ |
| 106 |
module-version\tfoo foo bar blah |
| 107 |
(DEBUG .*)+ |
| 108 |
module-whatis\t{Some checks for HELP and DISPLAY} |
| 109 |
(DEBUG .*)+ |
| 110 |
$modlin |
| 111 |
(DEBUG .*)+" |
| 112 |
|
| 113 |
set out_err "$err_path'$module_2'" |
| 114 |
set out_interr "[escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modpath/$module_3/.modulerc 28 { }]] |
| 115 |
$modlin |
| 116 |
$modpathre/$module_3/before: |
| 117 |
|
| 118 |
[escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modpath/$module_3/before 26 { }]] |
| 119 |
$modlin" |
| 120 |
set out_debug_interr "((DEBUG|Evaluate modulerc:|Evaluate modulefile:|Get modules:) .*)+ |
| 121 |
[escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modpath/$module_3/.modulerc 28 { }]] |
| 122 |
((DEBUG|Evaluate modulerc:|Evaluate modulefile:|Get modules:) .*)+ |
| 123 |
$modlin |
| 124 |
$modpathre/$module_3/before: |
| 125 |
|
| 126 |
((DEBUG|Evaluate modulerc:|Evaluate modulefile:|Get modules:) .*)+ |
| 127 |
[escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modpath/$module_3/before 26 { }]] |
| 128 |
(DEBUG .*)+ |
| 129 |
$modlin |
| 130 |
(DEBUG .*)+ |
| 131 |
DEBUG renderSettings: 2 error\\\(s\\\) detected. |
| 132 |
DEBUG setState: false_rendered set to '1' |
| 133 |
(DEBUG .*)+" |
| 134 |
|
| 135 |
set out_pat_4 "$modlin |
| 136 |
$modpathre/test/2.0: |
| 137 |
|
| 138 |
set-alias\tal-testsuite {ps -auxww | grep modulecmd} |
| 139 |
unset-alias\tal-testsuite |
| 140 |
setenv\t\ttestsuite yes |
| 141 |
append-path\ttestsuite no |
| 142 |
prepend-path\ttestsuite maybe |
| 143 |
remove-path\ttestsuite yes |
| 144 |
unsetenv\ttestsuite |
| 145 |
x-resource\tmy-prog*my-ress:true |
| 146 |
system\t\tls |
| 147 |
module\t\tload setenv/1.0 |
| 148 |
module-alias\tfoo setenv/1.0 |
| 149 |
module-version\tfoo foo bar blah |
| 150 |
module-whatis\t{Some checks for TEST and DISPLAY} |
| 151 |
$modlin" |
| 152 |
|
| 153 |
|
| 154 |
set custom { (procedure "ModulesDisplay" line 2) |
| 155 |
invoked from within |
| 156 |
"ModulesDisplay"} |
| 157 |
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modpath/$module_5/proc {} { } {} {} $custom]] |
| 158 |
set out_interr_5 "$modlin |
| 159 |
$modpathre/$module_5/proc: |
| 160 |
|
| 161 |
setenv\t\ttestsuite yes |
| 162 |
module-whatis\t{erroneous module test} |
| 163 |
$custom |
| 164 |
$modlin" |
| 165 |
|
| 166 |
set out_err_6 "------------------------------------------------------------ |
| 167 |
$modulefile_6: |
| 168 |
|
| 169 |
setenv\t\ttestsuite yes |
| 170 |
------------------------------------------------------------" |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
# |
| 175 |
# The tests |
| 176 |
# |
| 177 |
|
| 178 |
testouterr_cmd_re "csh" "display $module_1" "OK" "$out_pat" |
| 179 |
|
| 180 |
skip_if_quick_mode |
| 181 |
|
| 182 |
# command nickname tests |
| 183 |
testouterr_cmd_re "csh" "show $module_1" "OK" "$out_pat" |
| 184 |
testouterr_cmd_re "csh" "di $module_1" "OK" "$out_pat" |
| 185 |
|
| 186 |
|
| 187 |
# test with module passed as full path |
| 188 |
testouterr_cmd_re "csh" "display $modulefile_1" "OK" "$out_pat" |
| 189 |
testouterr_cmd_re "csh" "display $modulefile_1_reld" "OK" "$out_pat" |
| 190 |
testouterr_cmd_re "csh" "display $modulefile_1_reldd" "OK" "$out_pat" |
| 191 |
|
| 192 |
# setup MODULEPATH with a trailing slash and an empty dir element |
| 193 |
setenv_path_var MODULEPATH {} "$modpath/" |
| 194 |
testouterr_cmd_re "csh" "display $module_1" "OK" "$out_pat" |
| 195 |
|
| 196 |
# restore MODULEPATH |
| 197 |
setenv_path_var MODULEPATH $modpath |
| 198 |
|
| 199 |
# |
| 200 |
# test debug mode |
| 201 |
# |
| 202 |
|
| 203 |
testouterr_cmd_re "csh" "--debug display $module_1" "OK" "$out_debug_pat" |
| 204 |
|
| 205 |
# |
| 206 |
# test exit on error |
| 207 |
# |
| 208 |
testouterr_cmd "csh" "display $module_2" "ERR" "$out_err" |
| 209 |
|
| 210 |
# |
| 211 |
# test with erroneous modulefile |
| 212 |
# |
| 213 |
testouterr_cmd_re "csh" "display $module_3" "ERR" "$out_interr" |
| 214 |
|
| 215 |
# |
| 216 |
# test with erroneous modulefile in debug mode |
| 217 |
# |
| 218 |
testouterr_cmd_re "csh" "--debug display $module_3" "ERR" "$out_debug_interr" |
| 219 |
|
| 220 |
# |
| 221 |
# test on modulefile with ModuleTest proc defined |
| 222 |
# |
| 223 |
testouterr_cmd_re "csh" "display $module_4" "OK" "$out_pat_4" |
| 224 |
|
| 225 |
# |
| 226 |
# test with erroneous ModulesDisplay proc in modulefile |
| 227 |
# |
| 228 |
testouterr_cmd_re "csh" "display $module_5" "ERR" "$out_interr_5" |
| 229 |
|
| 230 |
# test with module passed as full path |
| 231 |
testouterr_cmd_re "csh" "display $modulefile_5" "ERR" "$out_interr_5" |
| 232 |
testouterr_cmd_re "csh" "display $modulefile_5_reld" "ERR" "$out_interr_5" |
| 233 |
testouterr_cmd_re "csh" "display $modulefile_5_reldd" "ERR" "$out_interr_5" |
| 234 |
|
| 235 |
# test small width terminal |
| 236 |
set test_cols 60 |
| 237 |
if {![info exists term_cols]} { |
| 238 |
# skip tests if current terminal width is unknown |
| 239 |
send_user "\tskipping terminal width-specific tests\n" |
| 240 |
# set a specific terminal width |
| 241 |
} elseif {[catch {exec stty cols $test_cols}] || [getTtyCols] ne $test_cols} { |
| 242 |
send_user "\tskipping terminal width-specific tests, cannot set width\n" |
| 243 |
} else { |
| 244 |
|
| 245 |
testouterr_cmd "sh" "display $module_6" "OK" $out_err_6 |
| 246 |
|
| 247 |
# restore terminal width |
| 248 |
exec stty cols $term_cols |
| 249 |
|
| 250 |
} |
| 251 |
|
| 252 |
# |
| 253 |
# test command-line arguments not related to display command |
| 254 |
# |
| 255 |
|
| 256 |
# these command-line arguments are ignored |
| 257 |
testouterr_cmd_re "csh" "display --auto $module_1" "OK" "$out_pat" |
| 258 |
testouterr_cmd_re "csh" "display --no-auto $module_1" "OK" "$out_pat" |
| 259 |
testouterr_cmd_re "csh" "display --force $module_1" "OK" "$out_pat" |
| 260 |
|
| 261 |
# |
| 262 |
# check error when implicit default is disabled |
| 263 |
# |
| 264 |
|
| 265 |
setenv_var MODULES_IMPLICIT_DEFAULT 0 |
| 266 |
testouterr_cmd sh "display $module_1" ERR "$err_nodefault'$module_1'" |
| 267 |
setenv_var MODULES_IMPLICIT_DEFAULT 1 |
| 268 |
|
| 269 |
# |
| 270 |
# display when loaded environment is inconsistent |
| 271 |
# |
| 272 |
|
| 273 |
setenv_loaded_module [list foo bar] "/path/to/foo" |
| 274 |
|
| 275 |
set out_pat_4 "$err_loinconsist |
| 276 |
LOADEDMODULES=foo bar |
| 277 |
_LMFILES_=/path/to/foo" |
| 278 |
testouterr_cmd_re "csh" "display $module_4" ERR $out_pat_4 |
| 279 |
|
| 280 |
|
| 281 |
# |
| 282 |
# Cleanup |
| 283 |
# |
| 284 |
|
| 285 |
reset_test_env |
| 286 |
|
| 287 |
} |