| 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/11/25 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: load |
| 14 |
# Modulefiles: modbad |
| 15 |
# Sub-Command: |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Tests 'module' sub-commands that cannot be called |
| 19 |
# outside of command line |
| 20 |
# }C% |
| 21 |
# |
| 22 |
############################################################################## |
| 23 |
|
| 24 |
skip_if_quick_mode |
| 25 |
|
| 26 |
setenv_path_var MODULEPATH $modpath $modpath.3 |
| 27 |
|
| 28 |
foreach subcmd [list append-path prepend-path remove-path autoinit help is-loaded is-saved is-used is-avail path paths info-loaded clear config sh-to-mod edit refresh state lint mod-to-sh reset stash stashclear stashlist stashpop stashrm stashshow cachebuild cacheclear spider] { |
| 29 |
set module "modbad/$subcmd" |
| 30 |
if {$subcmd in {refresh source state lint mod-to-sh reset stash stashclear stashlist stashpop stashrm stashshow cachebuild cacheclear spider}} { |
| 31 |
set modulefile "$modpath.3/$module" |
| 32 |
set modulefilere "$modpathre.3/$module" |
| 33 |
} else { |
| 34 |
set modulefile "$modpath/$module" |
| 35 |
set modulefilere "$modpathre/$module" |
| 36 |
} |
| 37 |
|
| 38 |
switch -- $subcmd { |
| 39 |
{append-path} - {prepend-path} - {remove-path} { |
| 40 |
set subcmdargs " FOO bar" |
| 41 |
} |
| 42 |
{is-loaded} - {is-saved} - {is-used} - {is-avail} - {info-loaded} - {path} - {paths} { |
| 43 |
set subcmdargs " bar" |
| 44 |
} |
| 45 |
default { |
| 46 |
set subcmdargs "" |
| 47 |
} |
| 48 |
} |
| 49 |
set moderr [msg_moderr "module: Command '$subcmd' not supported" "<EXM>module $subcmd$subcmdargs" $modulefile 27] |
| 50 |
testouterr_cmd_re "sh" "load $module" "ERR" [escre [msg_load $module $moderr]] |
| 51 |
|
| 52 |
# no subcommand check on display, so no error |
| 53 |
testouterr_cmd_re "sh" "display $module" "OK" "$modlin\n$modulefilere:\n\nmodule\t\t$subcmd$subcmdargs\nmodule\t\thelp\n$modlin" |
| 54 |
} |
| 55 |
|
| 56 |
set module "modbad/foo" |
| 57 |
set modulefile "$modpath/$module" |
| 58 |
set modulefilere "$modpathre/$module" |
| 59 |
set moderr [msg_moderr {module: Invalid command 'foo'} {module foo} $modulefile 27] |
| 60 |
|
| 61 |
testouterr_cmd "sh" "load $module" "ERR" [msg_load $module $moderr] |
| 62 |
testouterr_cmd_re "sh" "display $module" "OK" "$modlin\n$modulefilere:\n\nmodule\t\tfoo\nmodule\t\thelp\n$modlin" |
| 63 |
|
| 64 |
set module "modbad/empty" |
| 65 |
set modulefile "$modpath/$module" |
| 66 |
set modulefilere "$modpathre/$module" |
| 67 |
|
| 68 |
set moderr [msg_moderr {module: Command 'help' not supported} "module {}" $modulefile 27] |
| 69 |
testouterr_cmd "sh" "load $module" "ERR" [msg_load $module $moderr] |
| 70 |
|
| 71 |
testouterr_cmd_re "sh" "display $module" "OK" "$modlin\n$modulefilere:\n\nmodule\t\t{}\nmodule\t\thelp\n$modlin" |
| 72 |
|
| 73 |
|
| 74 |
# |
| 75 |
# Cleanup |
| 76 |
# |
| 77 |
|
| 78 |
reset_test_env |