| 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: 2018/03/18 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: load, unload, display, help, test, path, switch, |
| 14 |
# source, whatis, apropos, paths, purge, reload, |
| 15 |
# aliases, savelist, autoinit, save, restore, saveshow, |
| 16 |
# saverm, is-saved, use, unuse, is-loaded, is-used, |
| 17 |
# is-avail, info-loaded, append-path, prepend-path, |
| 18 |
# remove-path |
| 19 |
# Modulefiles: |
| 20 |
# Sub-Command: |
| 21 |
# |
| 22 |
# Comment: %C{ |
| 23 |
# Test commands with an empty string argument passed on command-line |
| 24 |
# }C% |
| 25 |
# |
| 26 |
############################################################################## |
| 27 |
|
| 28 |
skip_if_quick_mode |
| 29 |
|
| 30 |
set module1 "/path/to/mod1" |
| 31 |
set modulefile1 "$module1" |
| 32 |
set module2 "loc_dv1/1.0" |
| 33 |
set modulefile2 "$modpath/$module2" |
| 34 |
|
| 35 |
# setup specific environment (with current path as modulepath and a module |
| 36 |
# loaded with full path name) to check passed empty argument is not mismatched |
| 37 |
# with something else due to these conditions |
| 38 |
setenv_path_var MODULEPATH $modpath [pwd] |
| 39 |
setenv_loaded_module $module1 $modulefile1 |
| 40 |
|
| 41 |
|
| 42 |
# wrong arg number if command does not accept any argument |
| 43 |
foreach cmd [list purge reload aliases autoinit] { |
| 44 |
testouterr_cmd "sh" "$cmd " "ERR" "$error_msgs: Unexpected number of args for '$cmd' command\n$err_typehelp" |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
# on most commands, empty arg leads to error |
| 49 |
foreach cmd [list load unload display help test whatis] { |
| 50 |
testouterr_cmd "sh" "$cmd " "ERR" $err_emptymodname |
| 51 |
} |
| 52 |
foreach cmd [list "save" "restore" "saveshow" "saverm" "is-saved"] { |
| 53 |
testouterr_cmd "sh" "$cmd " "ERR" $err_emptycollname |
| 54 |
} |
| 55 |
foreach cmd [list "use" "unuse"] { |
| 56 |
testouterr_cmd "sh" "$cmd " "ERR" $err_emptydirname |
| 57 |
} |
| 58 |
testouterr_cmd "sh" "source " "ERR" $err_emptyfilename |
| 59 |
testouterr_cmd "sh" "swap $module2" "ERR" [msg_switch {} $module2 $err_emptymodname] |
| 60 |
|
| 61 |
# switch: an empty second arg leads to one name rule |
| 62 |
set ans [list] |
| 63 |
lappend ans [list set _LMFILES_ "$modulefile1:$modulefile2"] |
| 64 |
lappend ans [list set LOADEDMODULES "$module1:$module2"] |
| 65 |
testouterr_cmd_re "sh" "swap $module2 " $ans "" |
| 66 |
|
| 67 |
# path: empty result returned |
| 68 |
set ans [list] |
| 69 |
lappend ans [list text ""] |
| 70 |
testouterr_cmd "sh" "path " $ans $err_emptymodname |
| 71 |
|
| 72 |
|
| 73 |
# return false or empty, no error reported |
| 74 |
foreach cmd [list is-loaded is-used is-avail] { |
| 75 |
testouterr_cmd "sh" "$cmd " "ERR" "" |
| 76 |
} |
| 77 |
testouterr_cmd "sh" "info-loaded " $ans "" |
| 78 |
|
| 79 |
|
| 80 |
# also leads to error for path management commands except if only variable value is empty |
| 81 |
set ans [list] |
| 82 |
lappend ans [list setpath FOO ""] |
| 83 |
testouterr_cmd "sh" "append-path " "ERR" "$error_msgs: append-path $msg_validenvvarname" |
| 84 |
testouterr_cmd "sh" "append-path -d " "ERR" "$error_msgs: append-path $msg_nonemptydelim" |
| 85 |
testouterr_cmd "sh" "append-path FOO " $ans "" |
| 86 |
testouterr_cmd "sh" "prepend-path " "ERR" "$error_msgs: prepend-path $msg_validenvvarname" |
| 87 |
testouterr_cmd "sh" "prepend-path -d " "ERR" "$error_msgs: prepend-path $msg_nonemptydelim" |
| 88 |
testouterr_cmd "sh" "prepend-path FOO " $ans "" |
| 89 |
testouterr_cmd "sh" "remove-path " "ERR" "$error_msgs: remove-path $msg_validenvvarname" |
| 90 |
testouterr_cmd "sh" "remove-path -d " "ERR" "$error_msgs: remove-path $msg_nonemptydelim" |
| 91 |
set ans [list] |
| 92 |
lappend ans [list unset FOO ""] |
| 93 |
testouterr_cmd "sh" "remove-path FOO " $ans "" |
| 94 |
|
| 95 |
# restore MODULEPATH |
| 96 |
setenv_path_var MODULEPATH $modpath |
| 97 |
|
| 98 |
# error rendered as some evaluated modules produce error |
| 99 |
testouterr_cmd_re sh {apropos } ERR .+ |
| 100 |
testouterr_cmd_re sh {avail } OK .+ |
| 101 |
testouterr_cmd_re sh {list } OK .+ |
| 102 |
testouterr_cmd_re sh {savelist } OK [msg_no_named_coll] |
| 103 |
# except for non-wild search like paths sub-command |
| 104 |
testouterr_cmd_re "sh" "paths " "" ".+" |
| 105 |
|
| 106 |
|
| 107 |
# |
| 108 |
# Cleanup |
| 109 |
# |
| 110 |
|
| 111 |
reset_test_env |