File: 080-help.exp

package info (click to toggle)
modules 5.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,036 kB
  • sloc: exp: 79,659; sh: 6,142; tcl: 5,900; makefile: 1,493; ansic: 474; python: 265; csh: 202; perl: 47; ruby: 44; lisp: 13
file content (160 lines) | stat: -rw-r--r-- 5,103 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.70-maint/%M%
#   Revision:		%I%
#   First Edition:	95/12/06
#   Last Mod.:		%U%, %G%
#
#   Authors:		Jens Hamisch, Jens.Hamisch@Strawberry.COM
#
#   Description:	Testuite testsequence
#   Command:		help
#   Modulefiles:	help/2.0, bad
#   Sub-Command:
#
#   Comment:	%C{
#			Tests the module command 'help'
#			Help w/o arguments is checked during the testsuites
#			initialization phase, when probing the release of
#			modulecmd.
#			add test regarding the redirection of stdout 
#			help/2.0 => puts stdout
#			help/3.0 => puts stderr
#			both should provide the same stderr output
#		}C%
#
##############################################################################

# skip tests if implicit_default option could not be overridden
if {[is_config_locked implicit_default]} {
    send_user "\tskipping tests as implicit_default could not be overridden\n"
} else {

# ensure avail tests have implicit default enabled
setenv_var MODULES_IMPLICIT_DEFAULT 1

#
#  The affected module file
#

set module "help/2.0"
set modulefile "$modpath/$module"
set modulefile_reld "$reldmodpath/$module"
set modulefile_reldd "$relddmodpath/$module"

# different behavior than C-version: on Tcl-version 'module-log', 'module-verbosity'
# and 'module-user' commandq are not handled and will always return a warning message
# to inform the user.
set err_help "$modlin
Module Specific Help for $modpathre/$module:

Help_out
Help_err
$modlin"
set err_debug_help "((DEBUG|Evaluate modulerc:|Evaluate modulefile:|Get modules:) .*)+
$modlin
.*Module Specific Help for $modpathre/$module:

((DEBUG|Evaluate modulerc:|Evaluate modulefile:|Get modules:) .*)+
DEBUG \\\[#1:help:$module\\\] evaluateModulefile: puts stderr Help_out
.*Help_out.*
DEBUG \\\[#1:help:$module\\\] evaluateModulefile: puts stderr Help_err
.*Help_err.*
(DEBUG .*)+
$modlin
(DEBUG .*)+"
set err_debug2_help "((DEBUG|Evaluate modulerc:|Evaluate modulefile:|Get modules:) .*)+
$modlin
.*Module Specific Help for $modpathre/$module:

((DEBUG|Evaluate modulerc:|Evaluate modulefile:|Get modules:) .*)+
DEBUG \\\[#1:help:$module\\\] evaluateModulefile: putsModfileCmd __modfile_help_0_1 stderr Help_out
.*Help_out.*
DEBUG \\\[#1:help:$module\\\] evaluateModulefile: putsModfileCmd __modfile_help_0_1 stderr Help_err
.*Help_err.*
(DEBUG .*)+
$modlin
(DEBUG .*)+"

set module_2 "bad"
set out_interr "[escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modpath/$module_2/.modulerc 28 {  }]]
$modlin
Module Specific Help for $modpathre/$module_2/before:

[escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modpath/$module_2/before 26 {  }]]
$modlin"

set module_3 "bad2"
set custom {    (procedure "ModulesHelp" line 2)
    invoked from within
"ModulesHelp"}
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $modpath/$module_3/proc {} {  } {} {} $custom]]
set modulefile_3 "$modpath/$module_3/proc"
set modulefile_3_reld "$reldmodpath/$module_3/proc"
set modulefile_3_reldd "$relddmodpath/$module_3/proc"
set out_interr_3 "$modlin
Module Specific Help for $modpathre/$module_3/proc:

$custom
$modlin"

set module_4 "NonExistent"
set out_err_4 "$err_path'$module_4'"


#
#  The tests
#

# different behavior than C-version: on Tcl-version 'stdout' output made in a
# ModulesHelp procedure is not redirected to stderr and will produce an error
# as output will be parsed by the underlying shell. So for this test $module
# has been adapted to output everything to stderr

# test stderr output
testouterr_cmd_re "sh" "help $module" "OK" "$err_help"

skip_if_quick_mode

# test with module passed as full path
testouterr_cmd_re "sh" "help $modulefile" "OK" "$err_help"
testouterr_cmd_re "sh" "help $modulefile_reld" "OK" "$err_help"
testouterr_cmd_re "sh" "help $modulefile_reldd" "OK" "$err_help"

# test debug mode
testouterr_cmd_re "sh" "-D help $module" "OK" "$err_debug_help"
# test multiple debug argument: sets debug2 mode which change result a bit
setenv_var MODULES_AUTO_HANDLING 0
testouterr_cmd_re "sh" "--debug help $module -D" "OK" "$err_debug2_help"
unsetenv_var MODULES_AUTO_HANDLING

# test stdout output: MUST be empty
test_cmd "sh" "help $module" "OK"

# test with erroneous modulefile
testouterr_cmd_re "sh" "help $module_2" "ERR" "$out_interr"

# test with erroneous ModulesHelp proc in modulefile
testouterr_cmd_re "sh" "help $module_3" "ERR" "$out_interr_3"
# test with module passed as full path
testouterr_cmd_re "sh" "help $modulefile_3" "ERR" "$out_interr_3"
testouterr_cmd_re "sh" "help $modulefile_3_reld" "ERR" "$out_interr_3"
testouterr_cmd_re "sh" "help $modulefile_3_reldd" "ERR" "$out_interr_3"

# test on unexistant modulefile
testouterr_cmd "sh" "help $module_4" "ERR" "$out_err_4"

# check error when implicit default is disabled
setenv_var MODULES_IMPLICIT_DEFAULT 0
testouterr_cmd sh "help $module_3" ERR "$err_nodefault'$module_3'"
setenv_var MODULES_IMPLICIT_DEFAULT 1

#
#  Cleanup
#

reset_test_env

}