Debian Codegraph @

testsuite/modules.00-init/140-color.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.00-init/%M%
6 # Revision: %I%
7 # First Edition: 2019/01/08
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command:
14 # Sub-Command:
15 #
16 # Comment: %C{
17 # Check color-related switches and configs.
18 # }C%
19 #
20 ##############################################################################
21
22 # skip tests if implicit_default option could not be overridden
23 if {[is_config_locked implicit_default]} {
24 send_user "\tskipping tests as implicit_default could not be overridden\n"
25 } else {
26
27 # unset test-specific color setup disablement
28 unsetenv_var MODULES_COLOR
29
30 # ensure avail tests are made using in depth mode
31 setenv_var MODULES_AVAIL_INDEPTH 1
32
33 # ensure avail tests have implicit default enabled
34 setenv_var MODULES_IMPLICIT_DEFAULT 1
35
36 # check if stderr terminal attachment state is forced
37 set is_stderr_tty [siteconfig_isStderrTty]
38 if {$verbose} {
39 send_user "\tIs STDERR a TTY? = '$is_stderr_tty'\n"
40 }
41
42 # parse default color sets
43 # no default colors will be set if color set is badly defined
44 if {[catch {array set darkbgcolors [split $install_darkbgcolors {=:}]} errMsg ]} {
45 array set darkbgcolors {}
46 }
47 if {[catch {array set lightbgcolors [split $install_lightbgcolors {=:}]} errMsg ]} {
48 array set lightbgcolors {}
49 }
50
51 # create a specific color set for test purpose
52 foreach sgrkey [list hi db tr se er wa me in mp di al sy de cm] {
53 set customcolors($sgrkey) {37;40}
54 }
55
56 proc colorstr {str sgr {re_mode 0}} {
57 # if render bold or faint just reset that attribute, not all
58 if {$sgr == 1 || $sgr == 2} {
59 set sgrreset 22
60 } else {
61 set sgrreset 0
62 }
63 if {$sgr ne {}} {
64 set str [expr {$re_mode ? "\033\\\[${sgr}m$str\033\\\[${sgrreset}m"\
65 : "\033\[${sgr}m$str\033\[${sgrreset}m"}]
66 }
67 return $str
68 }
69
70 # helper proc to generate color test and expected output
71 proc color_test_case {modarg colorize {sgr {}}} {
72 if {!$::is_stderr_tty && $colorize} {
73 incr colorize -1
74 }
75
76 if {$colorize} {
77 set prefix [colorstr $::error_msgs $sgr]
78 } else {
79 set prefix $::error_msgs
80 }
81
82 if {$modarg ne {}} {
83 append modarg { }
84 }
85
86 testouterr_cmd sh "${modarg}foo" ERR "$prefix: Invalid command 'foo'\n$::err_typehelp"
87 }
88
89 # helper proc to generate background color selection test and expected output
90 proc background_test_case {bg} {
91 if {$bg eq {dark} && [info exists ::darkbgcolors(er)] && $::darkbgcolors(er) ne {}} {
92 set sgr_for_bg $::darkbgcolors(er)
93 } elseif {$bg eq {light} && [info exists ::lightbgcolors(er)] && $::lightbgcolors(er) ne {}} {
94 set sgr_for_bg $::lightbgcolors(er)
95 }
96
97 if {[info exists sgr_for_bg]} {
98 color_test_case {--color} 2 $sgr_for_bg
99 } else {
100 color_test_case {--color} 0
101 }
102 }
103
104 # helper proc to test element color against default and specific color sets
105 proc colorset_test_case {cmd sgrstrlist experr {testifcolorset 0} {testspecifcolor 1}} {
106 # get default color set
107 if {$::install_termbg eq {dark}} {
108 array set defbgcolors [array get ::darkbgcolors]
109 } elseif {$::install_termbg eq {light}} {
110 array set defbgcolors [array get ::lightbgcolors]
111 } else {
112 array set defbgcolors {}
113 }
114 set alldefset 1
115 set sgrmap [list]
116 foreach {sgrkey strtocolor} $sgrstrlist {
117 set sgr [expr {[info exists defbgcolors($sgrkey)] ? $defbgcolors($sgrkey) : {}}]
118 if {$sgr eq {}} {
119 set alldefset 0
120 }
121 lappend sgrmap $strtocolor [colorstr $strtocolor $sgr 1]
122 }
123 if {$alldefset || !$testifcolorset} {
124 testerr_cmd_re sh $cmd [string map $sgrmap $experr]
125 }
126
127 if {$testspecifcolor} {
128 # test against specific color set
129 array set custcolors [array get ::customcolors]
130 foreach {key val} [array get custcolors] {
131 lappend custlist $key=$val
132 }
133 setenv_var MODULES_COLORS [join $custlist :]
134 set sgrmap [list]
135 foreach {sgrkey strtocolor} $sgrstrlist {
136 lappend sgrmap $strtocolor [colorstr $strtocolor $custcolors($sgrkey) 1]
137 }
138 testerr_cmd_re sh $cmd [string map $sgrmap $experr]
139 }
140
141 if {!$testifcolorset} {
142 # empty color definition in specific color set
143 foreach {sgrkey strtocolor} $sgrstrlist {
144 set custcolors($sgrkey) {}
145 }
146 set custlist [list]
147 foreach {key val} [array get custcolors] {
148 lappend custlist $key=$val
149 }
150 setenv_var MODULES_COLORS [join $custlist :]
151 testerr_cmd_re sh $cmd $experr
152
153 # element not referred in specific color set
154 foreach {sgrkey strtocolor} $sgrstrlist {
155 if {[info exists custcolors($sgrkey)]} {
156 unset custcolors($sgrkey)
157 }
158 }
159 set custlist [list]
160 foreach {key val} [array get custcolors] {
161 lappend custlist $key=$val
162 }
163 setenv_var MODULES_COLORS [join $custlist :]
164 testerr_cmd_re sh $cmd $experr
165 }
166
167 unsetenv_var MODULES_COLORS
168 }
169
170
171 #
172 # color enablement checks
173 #
174
175 # ensure a color is set to check enablement
176 set sgr 91
177 setenv_var MODULES_COLORS er=$sgr
178
179 # default configuration test
180 if {$install_color eq {y}} {
181 color_test_case {} 1 $sgr
182 } else {
183 color_test_case {} 0 $sgr
184 }
185
186 skip_if_quick_mode
187
188 # environment variable or/and command-line switch override
189 setenv_var NO_COLOR 0
190 color_test_case {} 0 $sgr
191 setenv_var NO_COLOR 1
192 color_test_case {} 0 $sgr
193 setenv_var NO_COLOR {}
194 color_test_case {} 0 $sgr
195 setenv_var NO_COLOR foo
196 color_test_case {} 0 $sgr
197 unsetenv_var NO_COLOR
198
199 setenv_var CLICOLOR 0
200 color_test_case {} 0 $sgr
201 setenv_var CLICOLOR 1
202 color_test_case {} 1 $sgr
203 setenv_var CLICOLOR_FORCE 0
204 color_test_case {} 1 $sgr
205 setenv_var CLICOLOR_FORCE 1
206 color_test_case {} 1 $sgr
207 unsetenv_var CLICOLOR
208 setenv_var CLICOLOR_FORCE 1
209 color_test_case {} 2 $sgr
210 color_test_case {--color} 2 $sgr
211 color_test_case {--color=always} 2 $sgr
212 color_test_case {--color=auto} 1 $sgr
213 color_test_case {--color=never} 0 $sgr
214 color_test_case {--color=foo} 2 $sgr
215 unsetenv_var CLICOLOR_FORCE
216
217 # NO_COLOR prevails over CLICOLOR and CLICOLOR_FORCE
218 setenv_var NO_COLOR 1
219 setenv_var CLICOLOR 0
220 color_test_case {} 0 $sgr
221 setenv_var CLICOLOR 1
222 color_test_case {} 0 $sgr
223 setenv_var CLICOLOR_FORCE 0
224 color_test_case {} 0 $sgr
225 setenv_var CLICOLOR_FORCE 1
226 color_test_case {} 0 $sgr
227 unsetenv_var CLICOLOR
228 color_test_case {} 0 $sgr
229 unsetenv_var CLICOLOR_FORCE
230 unsetenv_var NO_COLOR
231
232 setenv_var MODULES_COLOR always
233 color_test_case {} 2 $sgr
234 color_test_case {--color} 2 $sgr
235 color_test_case {--color=always} 2 $sgr
236 color_test_case {--color=auto} 1 $sgr
237 color_test_case {--color=never} 0 $sgr
238 color_test_case {--color=foo} 2 $sgr
239
240 setenv_var CLICOLOR 0
241 color_test_case {} 2 $sgr
242 unsetenv_var CLICOLOR
243
244 setenv_var NO_COLOR 1
245 color_test_case {} 2 $sgr
246 unsetenv_var NO_COLOR
247
248 setenv_var MODULES_COLOR auto
249 color_test_case {} 1 $sgr
250 color_test_case {--color} 2 $sgr
251 color_test_case {--color=always} 2 $sgr
252 color_test_case {--color=auto} 1 $sgr
253 color_test_case {--color=never} 0 $sgr
254 color_test_case {--color=foo} 1 $sgr
255
256 setenv_var MODULES_COLOR never
257 color_test_case {} 0 $sgr
258 color_test_case {--color} 2 $sgr
259 color_test_case {--color=always} 2 $sgr
260 color_test_case {--color=auto} 1 $sgr
261 color_test_case {--color=never} 0 $sgr
262 color_test_case {--color=foo} 0 $sgr
263
264 setenv_var CLICOLOR 1
265 color_test_case {} 0 $sgr
266 unsetenv_var CLICOLOR
267
268 setenv_var NO_COLOR 1
269 color_test_case {} 0 $sgr
270 unsetenv_var NO_COLOR
271
272 setenv_var CLICOLOR_FORCE 1
273 color_test_case {} 0 $sgr
274 unsetenv_var CLICOLOR_FORCE
275
276 # no color set, disabled
277 setenv_var MODULES_COLORS {}
278 setenv_var MODULES_COLOR always
279 color_test_case {} 0 $sgr
280 color_test_case {--color} 0 $sgr
281 color_test_case {--color=always} 0 $sgr
282 color_test_case {--color=auto} 0 $sgr
283 color_test_case {--color=never} 0 $sgr
284
285 # color key empty, disabled
286 setenv_var MODULES_COLORS {er=}
287 color_test_case {} 0 $sgr
288 color_test_case {--color} 0 $sgr
289 color_test_case {--color=always} 0 $sgr
290 color_test_case {--color=auto} 0 $sgr
291 color_test_case {--color=never} 0 $sgr
292
293
294 #
295 # defined color set applied
296 #
297
298 # specific bold and faint reset
299 setenv_var MODULES_COLORS er=1
300 color_test_case {--color} 2 1
301 setenv_var MODULES_COLORS er=2
302 color_test_case {--color} 2 2
303
304 # background color dependent selection
305 unsetenv_var MODULES_COLOR
306 unsetenv_var MODULES_COLORS
307 background_test_case $install_termbg
308 setenv_var MODULES_TERM_BACKGROUND dark
309 background_test_case dark
310 setenv_var MODULES_TERM_BACKGROUND foo
311 background_test_case $install_termbg
312 setenv_var MODULES_TERM_BACKGROUND {}
313 background_test_case $install_termbg
314 setenv_var MODULES_TERM_BACKGROUND light
315 background_test_case light
316 # user-specific color set will override all background color selection
317 setenv_var MODULES_COLORS er=1
318 setenv_var MODULES_TERM_BACKGROUND dark
319 color_test_case {--color} 2 1
320 setenv_var MODULES_TERM_BACKGROUND foo
321 color_test_case {--color} 2 1
322 setenv_var MODULES_TERM_BACKGROUND {}
323 color_test_case {--color} 2 1
324 setenv_var MODULES_TERM_BACKGROUND light
325 color_test_case {--color} 2 1
326
327 # badly defined MODULES_COLORS is ignored
328 setenv_var MODULES_COLORS er=1:wa
329 setenv_var MODULES_TERM_BACKGROUND dark
330 background_test_case dark
331 setenv_var MODULES_TERM_BACKGROUND light
332 background_test_case light
333
334 unsetenv_var MODULES_TERM_BACKGROUND
335
336 # also if it happen during first execution steps
337 if {[siteconfig_isStderrTty]} {
338 setenv_var TESTSUITE_ENABLE_SITECONFIG_BROKEN 1
339 set tserr [escre "$error_msgs: Site configuration source failed
340 invalid command name \"unk_foo\"
341 while executing
342 \"unk_foo<EXM>\"
343 (file \"$siteconfig_file\" line 2)<EXM>"]
344 colorset_test_case {--color -V} [list er $error_msgs] $tserr
345 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_BROKEN
346 }
347
348 # test of the various element on all commands that can produce a colored output
349 unsetenv_var MODULES_COLOR
350 unsetenv_var MODULES_COLORS
351
352 # warning (wa)
353 colorset_test_case {--color --create -V} [list wa WARNING] {WARNING: Unsupported option '--create'.*}
354 # ensure command-line switch position has no impact
355 colorset_test_case {--create -V --color} [list wa WARNING] {WARNING: Unsupported option '--create'.*}
356
357 # debug information (db)
358 setenv_var MODULES_COLOR always
359 colorset_test_case {-D -V} [list db "DEBUG setState: cmdline set to '$MODULECMD sh -D -V'"] "DEBUG setState: cmdline set to '$MODULECMD sh -D -V'.*"
360
361 # trace information (tr)
362 colorset_test_case {load -T unk} [list tr "Get modules" tr "{} matching 'unk' in '$modpathre'"] ".*Get modules: {} matching 'unk' in '$modpathre'.*"
363
364 # error (er)
365 colorset_test_case {--foo foo} [list er $error_msgs] "$error_msgs: Invalid option '--foo'\n$err_typehelp"
366 if {[info exists x11_warn]} {
367 colorset_test_case {load x-resource/1} [list er $error_msgs] .*[string map [list "\n" "\n\\s+"] $x11_warn]
368 }
369
370 # module error (me)
371 colorset_test_case {load bad2/body} [list me $moderr_msgs] ".*$moderr_msgs: invalid command.*"
372
373 # info (in)
374 colorset_test_case {load --auto prereq/module} [list in {Loading requirement}] ".*Loading requirement: trace/all_on"
375
376 # highlighted element (hi)
377 colorset_test_case {saveshow testsuite/home/.module/infocmd} [list hi testsuite/home/.module/infocmd] ".*testsuite/home/.module/infocmd:.*"
378 colorset_test_case {display setenv/1.0} [list hi $modpathre/setenv/1.0] ".*$modpathre/setenv/1.0:.*"
379 colorset_test_case {help setenv/1.0} [list hi $modpathre/setenv/1.0] ".*$modpathre/setenv/1.0:.*"
380 colorset_test_case {test setenv/1.0} [list hi $modpathre/setenv/1.0] ".*$modpathre/setenv/1.0:.*"
381 colorset_test_case {avail -l loc_tr} [list hi Package/Alias hi Versions hi {Last mod.}] ".*- Package/Alias -.*- Versions -.*- Last mod. -.*"
382 setenv_var HOME $env(TESTSUITEDIR)/home
383 colorset_test_case {savelist -l} [list hi Collection hi {Last mod.}] "- Collection -.*- Last mod. -.*"
384 setenv_var HOME $env(TESTSUITEDIR)
385 # matched strings
386 colorset_test_case {avail loc_t} [list hi loc_t] ".*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*"
387 colorset_test_case {avail -l loc_t} [list hi loc_t] ".*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*"
388 colorset_test_case {avail -t loc_t} [list hi loc_t] ".*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*"
389 colorset_test_case {avail loc_tr} [list hi loc_tr] ".*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*loc_tr.*"
390 colorset_test_case {avail loc_tr/3 loc_tr/1} [list hi loc_tr/1 hi loc_tr/3] ".*loc_tr/1.0.*loc_tr/3.0.*"
391 colorset_test_case {spider loc_tr/3.0 loc_tr/1} [list hi loc_tr/1 hi loc_tr/3.0] ".*loc_tr/1.0.*loc_tr/3.0.*"
392 colorset_test_case {whatis loc_tr} [list hi loc_tr] ".*\\s+loc_tr/1.0: .*\\s+loc_tr/2.0: .*\\s+loc_tr/3.0: .*"
393 colorset_test_case {whatis loc_tr/2.0 loc_tr/1.0} [list hi loc_tr/1.0 hi loc_tr/2.0] ".*\\s+loc_tr/1.0: .*\\s+loc_tr/2.0: .*"
394 colorset_test_case {search loc_tr} [list hi loc_tr] ".*: loc_tr/1.0\n.*: loc_tr/2.0\n.*: loc_tr/3.0"
395 # matched strings expressed with the advanced version specifiers
396 setenv_var MODULES_ADVANCED_VERSION_SPEC 1
397 colorset_test_case {avail loc_tr@1} [list hi loc_tr/1] ".*loc_tr/1.0.*"
398 colorset_test_case {avail loc_tr@1,2} [list hi loc_tr/1 hi loc_tr/2] ".*loc_tr/1.0.*loc_tr/2.0.*"
399 colorset_test_case {avail loc_tr@1:3} [list hi loc_tr/1 hi loc_tr/3] ".*loc_tr/1.0.*loc_tr/3.0.*"
400 colorset_test_case {avail [email protected]:} [list hi loc_tr/1.0] ".*loc_tr/1.0.*"
401 colorset_test_case {avail loc_tr@:2.0} [list hi loc_tr/2.0] ".*loc_tr/2.0.*"
402 colorset_test_case {whatis [email protected]} [list hi loc_tr/1.0] ".*\\s+loc_tr/1.0:.*"
403 colorset_test_case {whatis loc_tr@:2} [list hi loc_tr/2] ".*\\s+loc_tr/1.0: .*\\s+loc_tr/2.0: .*"
404 colorset_test_case {whatis loc_tr@1:3.0} [list hi loc_tr/1 hi loc_tr/3.0] ".*\\s+loc_tr/1.0: .*\\s+loc_tr/3.0: .*"
405 unsetenv_var MODULES_ADVANCED_VERSION_SPEC
406
407 # modulepath (mp)
408 colorset_test_case {use} [list mp $modpathre] "Search path for module files \\(in search order\\):\n $modpathre"
409 colorset_test_case {avail loc_tr} [list mp $modpathre] ".*- $modpathre -.*"
410 colorset_test_case {avail -t --no-indepth loc_tr} [list mp $modpathre] ".*$modpathre:.*"
411 colorset_test_case {avail -l --no-indepth loc_tr} [list mp $modpathre] ".*$modpathre:.*"
412
413 # modulepath (mp) and via
414 setenv_var __MODULES_LMUSE loc_tr/1.0&$modpath
415 setenv_loaded_module [list loc_tr/1.0] [list $modpath/loc_tr/1.0]
416 colorset_test_case {avail -o +via loc_tr} [list mp $modpathre] ".*- $modpathre \\(via loc_tr/1.0\\) -.*"
417 unsetenv_var __MODULES_LMUSE
418 unsetenv_loaded_module
419
420 # tag separator (se) / module symbolic version (sy)
421 colorset_test_case {avail loc_tr} [list se \\( se \\) se : sy reg sy cur sy stable] ".*loc_tr.*/\\(reg\\).*loc_tr.*/1.0\\(cur:stable\\).*"
422 colorset_test_case {avail -t loc_tr} [list se \\( se \\) se : sy reg sy cur sy stable] ".*loc_tr.*/\\(reg\\).*loc_tr.*/1.0\\(cur:stable\\).*"
423 colorset_test_case {avail -l loc_tr} [list se : sy reg sy cur sy stable] ".*loc_tr.*/\\s+reg.*loc_tr.*/1.0\\s+cur:stable.*"
424
425 # directory (di)
426 colorset_test_case {avail --no-indepth} [list di loc_tr] ".*loc_tr/.*"
427 colorset_test_case {avail -t} [list di loc_tr] ".*loc_tr/.*"
428 colorset_test_case {avail -l} [list di loc_tr] ".*loc_tr/.*"
429
430 # module alias (al) / module default version (de)
431 colorset_test_case {avail} [list al loc_rc6/bar de loc_rc6/1.2] ".*loc_rc6/1.2.*loc_rc6/bar.*"
432 colorset_test_case {avail -l} [list al loc_rc6/bar de loc_rc6/1.2] ".*loc_rc6/1.2.*loc_rc6/bar.*"
433 colorset_test_case {avail -t} [list al loc_rc6/bar de loc_rc6/1.2] ".*loc_rc6/1.2.*loc_rc6/bar.*"
434 # check @ and default symbols disappear when color is there
435 if {($::install_termbg eq {dark} && (![info exists darkbgcolors(de)] || $darkbgcolors(de) eq {}))\
436 || ($::install_termbg eq {light} && (![info exists lightbgcolors(de)] || $lightbgcolors(de) eq {}))} {
437 colorset_test_case {avail loc_rc6} [list hi loc_rc6 se \\( se \\) se : sy new sy default] ".*loc_rc6/1.2.*\\(default:new\\).*loc_rc6/bar.* .*" 1 0
438 colorset_test_case {avail -C _rc6} [list hi _rc6 se \\( se \\) se : sy new sy default] ".*loc_rc6/1.2.*\\(default:new\\).*loc_rc6/bar.* .*" 1 0
439 } else {
440 colorset_test_case {avail loc_rc6} [list hi loc_rc6 se \\( se \\) sy new] ".*loc_rc6/1.2.*\\(new\\).*loc_rc6/bar.* .*" 1
441 colorset_test_case {avail -C _rc6} [list hi _rc6 se \\( se \\) sy new] ".*loc_rc6/1.2.*\\(new\\).*loc_rc6/bar.* .*" 1
442 }
443
444 # highlighted element (hi) /module alias (al) / module symbolic version (sy)
445 colorset_test_case {aliases} [list hi Aliases hi Versions al loc_rc6/bar sy loc_rc6/default sy loc_rc6/new] ".*- Aliases -.*\nloc_rc6/bar -> .*- Versions -.*\nloc_rc6/default -> .*\nloc_rc6/new -> .*"
446
447 # tag separator (se) / module symbolic version (sy) / module default version (de)
448 setenv_loaded_module [list loc_tr/1.0 loc_rc6/1.2] [list $modpath/loc_tr/1.0 $modpath/loc_rc6/1.2]
449 setenv_var __MODULES_LMALTNAME loc_tr/1.0&loc_tr/cur&loc_tr/stable:loc_rc6/1.2&loc_rc6/default&loc_rc6&loc_rc6/new&al|loc_rc6/1&al|loc_rc6/bar
450 colorset_test_case {list} [list se : se \\( se \\) sy new sy cur sy stable de loc_rc6/1.2] ".*loc_tr/1.0\\(cur:stable\\).*loc_rc6/1.2\\(new\\).*" 1
451 colorset_test_case {list -l} [list se : sy new sy cur sy stable de loc_rc6/1.2] ".*loc_tr/1.0\\s+cur:stable\\s+.*loc_rc6/1.2\\s+new\\s+.*" 1
452 colorset_test_case {list -l} [list hi Package hi Versions hi {Last mod.}] ".*- Package -.*- Versions -.*- Last mod. -.*"
453 colorset_test_case {list -t} [list] ".*loc_tr/1.0\nloc_rc6/1.2" 0
454
455 # highlighted element (hi) on list
456 setenv_var __MODULES_LMALTNAME loc_tr/1.0&loc_tr/cur:loc_rc6/1.2&al|loc_rc6/1&al|loc_rc6/bar
457 colorset_test_case {list loc} [list hi loc se : se \\( se \\) sy new sy cur sy stable] ".*loc_tr/1.0\\(cur\\).*loc_rc6/1.2.*" 1
458 colorset_test_case {list -C tr} [list hi tr se : se \\( se \\) sy new sy cur sy stable] ".*loc_tr/1.0\\(cur\\).*" 1
459 colorset_test_case {list loc loc_rc} [list hi loc se : se \\( se \\) sy new sy cur sy stable] ".*loc_tr/1.0\\(cur\\).*loc_rc6/1.2.*" 1
460 colorset_test_case {list -C rc tr} [list hi rc hi tr se : se \\( se \\) sy new sy cur sy stable] ".*loc_tr/1.0\\(cur\\).*loc_rc6/1.2.*" 1
461
462 unsetenv_loaded_module
463 unsetenv_var __MODULES_LMALTNAME
464
465 # highlighted element (hi) on savelist
466 setenv_var HOME $env(HOME)/home
467 set tserr ".* 1\\) infocmd 2\\) infocmdexp "
468 colorset_test_case {savelist info} [list hi info] $tserr 1
469 set tserr ".*
470 1\\) coll1 3\\) coll3 5\\) coll6.target 7\\) infocmdexp
471 2\\) coll2 4\\) coll4.target 6\\) infocmd "
472 colorset_test_case {savelist -w 80 coll info} [list hi coll hi info] $tserr 1
473 setenv_var HOME $ORIG_HOME
474
475 # modulefile or collection command report (cm)
476 colorset_test_case {saveshow testsuite/home/.module/infocmd} [list cm module] ".*module use --append .*\nmodule load info/command.*"
477 colorset_test_case {display setenv/1.0} [list cm setenv] ".*setenv\t\ttestsuite yes.*"
478
479 # test cumulated sgr codes
480 setenv_var MODULES_COLORS {hi=1:db=2:tr=2:se=2:er=91:wa=93:me=95:in=94:mp=1;94:di=94:al=96:de=4}
481 testerr_cmd_re sh {avail -t loc_dv7/2} ".*\033\\\[4;94m\033\\\[1mloc_dv7/2\033\\\[22m.0\033\\\[0m/\n\033\\\[1mloc_dv7/2\033\\\[22m.0/1.0"
482 testerr_cmd_re sh {avail -t loc_tr/a} ".*\033\\\[4;96m\033\\\[1mloc_tr/a\033\\\[22ml2\033\\\[0m.*"
483 unsetenv_var MODULES_COLORS
484
485
486 #
487 # block output rendering
488 #
489
490 set test_cols 61
491 if {![info exists term_cols]} {
492 # skip tests if current terminal width is unknown
493 send_user "\tskipping terminal width-specific tests\n"
494 # set a specific terminal width
495 } elseif {[catch {exec stty cols $test_cols}] || [getTtyCols] ne $test_cols} {
496 send_user "\tskipping terminal width-specific tests, cannot set width\n"
497 } else {
498
499 setenv_var MODULES_COLORS er=31
500 set tserr "[colorstr $error_msgs 31]: Module cannot be loaded due to missing prereq.
501 HINT: the following module must be loaded first:
502 trace/all_on"
503 testerr_cmd sh {load --color --no-auto prereq/full} [msg_load prereq/full $tserr]
504 unsetenv_var MODULES_COLORS
505
506 # restore terminal width
507 exec stty cols $term_cols
508 }
509
510 # test twice calls to getConf term_background and getConf colors procedures
511 if {[siteconfig_isStderrTty]} {
512 setenv_var TESTSUITE_ENABLE_SITECONFIG_TWICEINITCOLORS 1
513 colorset_test_case {--foo foo} [list er $error_msgs] "$error_msgs: Invalid option '--foo'\n$err_typehelp"
514 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_TWICEINITCOLORS
515 }
516
517
518 #
519 # indesym rendering tests
520 #
521
522 setenv_path_var MODULEPATH $modpath.2
523 setenv_var MODULES_ADVANCED_VERSION_SPEC 0
524 setenv_var MODULES_COLORS {hi=1:db=2:tr=2:se=2:er=91:wa=93:me=95:in=94:mp=1;94:di=94:al=96:de=4:sy=95}
525 set tserr "[sgr 95][sgr 1]hide3/sym[sgr 22][sgr 0]
526
527 Key:
528 [sgr 95]symbolic-version[sgr 0] "
529 testouterr_cmd_re sh {avail --color=always -o key:indesym hide3/sym} OK $tserr
530 set tserr "[sgr 1]hide3/sub2[sgr 22]/4.0
531 [sgr 1]hide3/sub2[sgr 22]/5.0
532 [sgr 95][sgr 1]hide3/sub2[sgr 22]/default[sgr 0]
533 [sgr 95][sgr 1]hide3/sub2[sgr 22]/new[sgr 0]
534 [sgr 95][sgr 1]hide3/sub2[sgr 22]/sym[sgr 0]
535
536 Key:
537 [sgr 95]symbolic-version[sgr 0] "
538 testouterr_cmd_re sh {avail -w 20 --color=always -o key:indesym hide3/sub2} OK $tserr
539 testouterr_cmd_re sh {avail -w 20 --color=always -o key:indesym:dirwsym hide3/sub2} OK $tserr
540 set tserr "[sgr 95][sgr 1]hide3/sub2/default[sgr 22][sgr 0]
541
542 Key:
543 [sgr 95]symbolic-version[sgr 0] "
544 testouterr_cmd_re sh {avail --color=always -o key:indesym hide3/sub2/default} OK $tserr
545 # no color definition for symbolic versions
546 setenv_var MODULES_COLORS {hi=1:db=2:tr=2:se=2:er=91:wa=93:me=95:in=94:mp=1;94:di=94:al=96:de=4}
547 set tserr "[sgr 1]hide3/sym[sgr 22] "
548 testouterr_cmd_re sh {avail --color=always -o key:indesym hide3/sym} OK $tserr
549 unsetenv_var MODULES_COLORS
550 unsetenv_var MODULES_ADVANCED_VERSION_SPEC
551 setenv_path_var MODULEPATH $modpath
552
553
554 #
555 # alias/indesym rendering tests on list
556 #
557
558 setenv_var MODULES_COLORS {hi=1:db=2:tr=2:se=2:er=91:wa=93:me=95:in=94:mp=1;94:di=94:al=96:de=4:sy=95}
559 setenv_loaded_module [list foo/1.0] [list $modpath.3/foo/1.0]
560 setenv_var __MODULES_LMALTNAME foo/1.0&foo/bar&foo&al|alfoo
561
562 #FIXME
563 set tserr " 1\\) [sgr 96]alfoo[sgr 0] 2\\) foo/1.0[sgr 2]\\([sgr 22][sgr 95]bar[sgr 0][sgr 2]\\)[sgr 22]
564
565 Key:
566 [sgr 2]\\([sgr 22][sgr 95]symbolic-version[sgr 0][sgr 2]\\)[sgr 22] [sgr 96]module-alias[sgr 0] "
567 testouterr_cmd_re sh {list --color=always -o alias:idx:sym:key} OK $tserr
568 set tserr " 1\\) [sgr 95]foo/bar[sgr 0]
569 2\\) [sgr 96]alfoo[sgr 0]
570 3\\) foo/1.0
571
572 Key:
573 [sgr 95]symbolic-version[sgr 0] [sgr 96]module-alias[sgr 0] "
574 testouterr_cmd_re sh {list --color=always -t -o alias:idx:indesym:sym:key} OK $tserr
575
576 unsetenv_var __MODULES_LMALTNAME
577 unsetenv_loaded_module
578 unsetenv_var MODULES_COLORS
579
580
581 #
582 # Clean up variables used in this test case
583 #
584
585 reset_test_env
586
587 # remove procs
588 rename colorstr {}
589 rename color_test_case {}
590 rename background_test_case {}
591 rename colorset_test_case {}
592
593 }