| 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/22 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: load, display, help, avail, aliases, whatis |
| 14 |
# Command: apropos, list, switch, unload, test |
| 15 |
# Modulefiles: inforc |
| 16 |
# Sub-Command: |
| 17 |
# |
| 18 |
# Comment: %C{ |
| 19 |
# Test 'module-info' commands when called from a .modulerc file |
| 20 |
# }C% |
| 21 |
# |
| 22 |
############################################################################## |
| 23 |
|
| 24 |
# ensure avail tests are made using in depth mode |
| 25 |
setenv_var MODULES_AVAIL_INDEPTH 1 |
| 26 |
|
| 27 |
# |
| 28 |
# Variables. This test forces a module load command. It will result in the |
| 29 |
# environment variables "_LMFILES_", "LOADEDMODULES" and "testsuite" to |
| 30 |
# be set up |
| 31 |
# |
| 32 |
|
| 33 |
set module "inforc" |
| 34 |
set module2 "inforc/2.0" |
| 35 |
set modulefile2 "$modpath/$module2" |
| 36 |
set modulefilere2 "$modpathre/$module2" |
| 37 |
|
| 38 |
# |
| 39 |
# For sh shell only (no need to check every shells) |
| 40 |
# |
| 41 |
|
| 42 |
lappend ans [list set __MODULES_LMALTNAME "$module2&inforc/bar&inforc/default&inforc"] |
| 43 |
lappend ans [list set _LMFILES_ $modulefile2] |
| 44 |
lappend ans [list set LOADEDMODULES $module2] |
| 45 |
|
| 46 |
set out_rc "type: Tcl |
| 47 |
name: $module/.modulerc |
| 48 |
specified: $module/.modulerc |
| 49 |
shell: sh |
| 50 |
shelltype: sh |
| 51 |
alias $module/foo: $module/1.0 |
| 52 |
version $module/bar: $module/2.0 |
| 53 |
symbols $module/2.0: bar:default" |
| 54 |
set out_rc_load "mode: load\ncommand: load\n$out_rc" |
| 55 |
set out_rc_display "mode: display\ncommand: display\n$out_rc" |
| 56 |
set out_rc_help "mode: help\ncommand: help\n$out_rc" |
| 57 |
set out_rc_test "mode: test\ncommand: test\n$out_rc" |
| 58 |
set out_rc_switch "mode: load\ncommand: switch\n$out_rc" |
| 59 |
|
| 60 |
set header_list $cur_loaded |
| 61 |
set header "$modlin $modpathre $modlin" |
| 62 |
|
| 63 |
# |
| 64 |
# The tests |
| 65 |
# |
| 66 |
|
| 67 |
# test loading |
| 68 |
testouterr_cmd "sh" "load $module" $ans "$out_rc_load" |
| 69 |
|
| 70 |
skip_if_quick_mode |
| 71 |
|
| 72 |
# test displaying |
| 73 |
testouterr_cmd_re "sh" "display $module" "OK" "$out_rc_display\n$modlin\n$modulefilere2:\n\n$modlin" |
| 74 |
|
| 75 |
# test help |
| 76 |
testouterr_cmd_re "sh" "help $module" "OK" "$out_rc_help\n$modlin\nModule Specific Help for $modulefilere2:\n\n$modlin" |
| 77 |
|
| 78 |
# test test |
| 79 |
testouterr_cmd_re "sh" "test $module" "OK" "$out_rc_test\n$modlin\nModule Specific Test for $modulefilere2:\n\nTest result: PASS\n$modlin" |
| 80 |
|
| 81 |
# test avail |
| 82 |
# no output as defined in modulerc if mode is not set |
| 83 |
testouterr_cmd_re "sh" "avail $module" "OK" "$header\n$module/1.0\\s+$module/2.0\\(avail:bar:default\\)\\s+$module/foo\\(@\\)\n\nKey:\n\\(@\\)=module-alias \\(symbolic-version\\)" |
| 84 |
|
| 85 |
# test aliases |
| 86 |
testouterr_cmd_re "sh" "aliases" "OK" ".*$module/aliases -> $module2\n.*" |
| 87 |
|
| 88 |
# test whatis |
| 89 |
# no output as defined in modulerc if mode = whatis |
| 90 |
testouterr_cmd "sh" "whatis $module" "OK" "" |
| 91 |
|
| 92 |
# test apropos |
| 93 |
# no output as defined in modulerc if mode = whatis |
| 94 |
# error found in interpreted module, so an error code is rendered |
| 95 |
testouterr_cmd "sh" "apropos $module" "ERR" "" |
| 96 |
|
| 97 |
# Set up the environment for test that require the module to be loaded |
| 98 |
setenv_loaded_module $module2 $modulefile2 |
| 99 |
setenv_var __MODULES_LMALTNAME "$module2&inforc/bar&inforc/default&inforc" |
| 100 |
|
| 101 |
# test listing |
| 102 |
testouterr_cmd_re "sh" "list" "OK" "$header_list\n 1\\) $module2\\(bar:default\\)\n\nKey:\n\\(symbolic-version\\)" |
| 103 |
|
| 104 |
# test switching |
| 105 |
# modulerc is interpreted on first resolved internally prior switched-on load phase |
| 106 |
testouterr_cmd "sh" "switch $module $module2" $ans {} |
| 107 |
|
| 108 |
|
| 109 |
# test unloading |
| 110 |
set ans [list] |
| 111 |
lappend ans [list unset __MODULES_LMALTNAME] |
| 112 |
lappend ans [list unset _LMFILES_] |
| 113 |
lappend ans [list unset LOADEDMODULES] |
| 114 |
# modulerc is not interpreted when unloading a loaded module |
| 115 |
testouterr_cmd "sh" "unload $module" $ans "" |
| 116 |
|
| 117 |
|
| 118 |
# |
| 119 |
# Cleanup |
| 120 |
# |
| 121 |
|
| 122 |
reset_test_env |