| 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: help |
| 14 |
# Modulefiles: help/2.0, bad |
| 15 |
# Sub-Command: |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Tests the module command 'help' |
| 19 |
# Help w/o arguments is checked during the testsuites |
| 20 |
# initialization phase, when probing the release of |
| 21 |
# modulecmd. |
| 22 |
# add test regarding the redirection of stdout |
| 23 |
# help/2.0 => puts stdout |
| 24 |
# help/3.0 => puts stderr |
| 25 |
# both should provide the same stderr output |
| 26 |
# }C% |
| 27 |
# |
| 28 |
############################################################################## |
| 29 |
|
| 30 |
# skip tests if implicit_default option could not be overridden |
| 31 |
if {[is_config_locked implicit_default]} { |
| 32 |
send_user "\tskipping tests as implicit_default could not be overridden\n" |
| 33 |
} else { |
| 34 |
|
| 35 |
# ensure avail tests have implicit default enabled |
| 36 |
setenv_var MODULES_IMPLICIT_DEFAULT 1 |
| 37 |
|
| 38 |
# |
| 39 |
# The affected module file |
| 40 |
# |
| 41 |
|
| 42 |
set module "help/2.0" |
| 43 |
set modulefile "$modpath/$module" |
| 44 |
set modulefile_reld "$reldmodpath/$module" |
| 45 |
set modulefile_reldd "$relddmodpath/$module" |
| 46 |
|
| 47 |
# different behavior than C-version: on Tcl-version 'module-log', 'module-verbosity' |
| 48 |
# and 'module-user' commandq are not handled and will always return a warning message |
| 49 |
# to inform the user. |
| 50 |
set err_help "$modlin |
| 51 |
Module Specific Help for $modpathre/$module: |
| 52 |
|
| 53 |
Help_out |
| 54 |
Help_err |
| 55 |
$modlin" |
| 56 |
set err_debug_help "((DEBUG|Evaluate modulerc:|Evaluate modulefile:|Get modules:) .*)+ |
| 57 |
$modlin |
| 58 |
.*Module Specific Help for $modpathre/$module: |
| 59 |
|
| 60 |
((DEBUG|Evaluate modulerc:|Evaluate modulefile:|Get modules:) .*)+ |
| 61 |
DEBUG \\\[#1:help:$module\\\] evaluateModulefile: puts stderr Help_out |
| 62 |
.*Help_out.* |
| 63 |
DEBUG \\\[#1:help:$module\\\] evaluateModulefile: puts stderr Help_err |
| 64 |
.*Help_err.* |
| 65 |
(DEBUG .*)+ |
| 66 |
$modlin |
| 67 |
(DEBUG .*)+" |
| 68 |
set err_debug2_help "((DEBUG|Evaluate modulerc:|Evaluate modulefile:|Get modules:) .*)+ |
| 69 |
$modlin |
| 70 |
.*Module Specific Help for $modpathre/$module: |
| 71 |
|
| 72 |
((DEBUG|Evaluate modulerc:|Evaluate modulefile:|Get modules:) .*)+ |
| 73 |
DEBUG \\\[#1:help:$module\\\] evaluateModulefile: putsModfileCmd __modfile_help_0_1 stderr Help_out |
| 74 |
.*Help_out.* |
| 75 |
DEBUG \\\[#1:help:$module\\\] evaluateModulefile: putsModfileCmd __modfile_help_0_1 stderr Help_err |
| 76 |
.*Help_err.* |
| 77 |
(DEBUG .*)+ |
| 78 |
$modlin |
| 79 |
(DEBUG .*)+" |
| 80 |
|
| 81 |
set module_2 "bad" |
| 82 |
set out_interr "[escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modpath/$module_2/.modulerc 28 { }]] |
| 83 |
$modlin |
| 84 |
Module Specific Help for $modpathre/$module_2/before: |
| 85 |
|
| 86 |
[escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modpath/$module_2/before 26 { }]] |
| 87 |
$modlin" |
| 88 |
|
| 89 |
set module_3 "bad2" |
| 90 |
set custom { (procedure "ModulesHelp" line 2) |
| 91 |
invoked from within |
| 92 |
"ModulesHelp"} |
| 93 |
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modpath/$module_3/proc {} { } {} {} $custom]] |
| 94 |
set modulefile_3 "$modpath/$module_3/proc" |
| 95 |
set modulefile_3_reld "$reldmodpath/$module_3/proc" |
| 96 |
set modulefile_3_reldd "$relddmodpath/$module_3/proc" |
| 97 |
set out_interr_3 "$modlin |
| 98 |
Module Specific Help for $modpathre/$module_3/proc: |
| 99 |
|
| 100 |
$custom |
| 101 |
$modlin" |
| 102 |
|
| 103 |
set module_4 "NonExistent" |
| 104 |
set out_err_4 "$err_path'$module_4'" |
| 105 |
|
| 106 |
|
| 107 |
# |
| 108 |
# The tests |
| 109 |
# |
| 110 |
|
| 111 |
# different behavior than C-version: on Tcl-version 'stdout' output made in a |
| 112 |
# ModulesHelp procedure is not redirected to stderr and will produce an error |
| 113 |
# as output will be parsed by the underlying shell. So for this test $module |
| 114 |
# has been adapted to output everything to stderr |
| 115 |
|
| 116 |
# test stderr output |
| 117 |
testouterr_cmd_re "sh" "help $module" "OK" "$err_help" |
| 118 |
|
| 119 |
skip_if_quick_mode |
| 120 |
|
| 121 |
# test with module passed as full path |
| 122 |
testouterr_cmd_re "sh" "help $modulefile" "OK" "$err_help" |
| 123 |
testouterr_cmd_re "sh" "help $modulefile_reld" "OK" "$err_help" |
| 124 |
testouterr_cmd_re "sh" "help $modulefile_reldd" "OK" "$err_help" |
| 125 |
|
| 126 |
# test debug mode |
| 127 |
testouterr_cmd_re "sh" "-D help $module" "OK" "$err_debug_help" |
| 128 |
# test multiple debug argument: sets debug2 mode which change result a bit |
| 129 |
setenv_var MODULES_AUTO_HANDLING 0 |
| 130 |
testouterr_cmd_re "sh" "--debug help $module -D" "OK" "$err_debug2_help" |
| 131 |
unsetenv_var MODULES_AUTO_HANDLING |
| 132 |
|
| 133 |
# test stdout output: MUST be empty |
| 134 |
test_cmd "sh" "help $module" "OK" |
| 135 |
|
| 136 |
# test with erroneous modulefile |
| 137 |
testouterr_cmd_re "sh" "help $module_2" "ERR" "$out_interr" |
| 138 |
|
| 139 |
# test with erroneous ModulesHelp proc in modulefile |
| 140 |
testouterr_cmd_re "sh" "help $module_3" "ERR" "$out_interr_3" |
| 141 |
# test with module passed as full path |
| 142 |
testouterr_cmd_re "sh" "help $modulefile_3" "ERR" "$out_interr_3" |
| 143 |
testouterr_cmd_re "sh" "help $modulefile_3_reld" "ERR" "$out_interr_3" |
| 144 |
testouterr_cmd_re "sh" "help $modulefile_3_reldd" "ERR" "$out_interr_3" |
| 145 |
|
| 146 |
# test on unexistant modulefile |
| 147 |
testouterr_cmd "sh" "help $module_4" "ERR" "$out_err_4" |
| 148 |
|
| 149 |
# check error when implicit default is disabled |
| 150 |
setenv_var MODULES_IMPLICIT_DEFAULT 0 |
| 151 |
testouterr_cmd sh "help $module_3" ERR "$err_nodefault'$module_3'" |
| 152 |
setenv_var MODULES_IMPLICIT_DEFAULT 1 |
| 153 |
|
| 154 |
# |
| 155 |
# Cleanup |
| 156 |
# |
| 157 |
|
| 158 |
reset_test_env |
| 159 |
|
| 160 |
} |