Debian Codegraph @

testsuite/modules.50-cmds/282-info-command.exp

raw
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/27
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command: load, display, whatis, search, source, restore
14 # Command: unload, switch, purge, reload, help, test, reset
15 # Command: stash, stashpop
16 # Modulefiles: info/command
17 # Sub-Command:
18 #
19 # Comment: %C{
20 # Tests the 'module-info command' module subcommand with-
21 # out own suggestion.
22 # This command does not change behaviour depending on
23 # the user shell. Tests are made for the bourne shell
24 # here.
25 # }C%
26 #
27 ##############################################################################
28
29 #
30 # Variables. This test forces a module load command. It will result in the
31 # environment variables "_LMFILES_", "LOADEDMODULES" and "testsuite" to
32 # be set up
33 #
34
35 set module "info/command"
36 set modulefile "$modpath/$module"
37 set modulefilere "$modpathre/$module"
38
39 set header_help "Module Specific Help for $modulefilere:"
40 set header_test "Module Specific Test for $modulefilere:"
41 set header "$modlin $modpathre $modlin"
42
43 #
44 # The tests
45 #
46
47 lappend ans [list set _LMFILES_ $modulefile]
48 lappend ans [list set LOADEDMODULES $module]
49
50 lappend ansun [list unset _LMFILES_]
51 lappend ansun [list unset LOADEDMODULES]
52
53 # test loading
54 testouterr_cmd "sh" "load $module" $ans "load"
55
56 skip_if_quick_mode
57
58 # test try-loading
59 testouterr_cmd sh "try-load $module" $ans try-load
60
61 # test load-any
62 testouterr_cmd sh "load-any $module" $ans load-any
63
64 # test mod-to-sh
65 # specific test as this subcmd output shell code on report message channel
66 set tserr [shell_set sh INFOCMD mod-to-sh]
67 testouterr_cmd sh "mod-to-sh sh $module" [list [list OK nop]] $tserr
68
69 # test reset
70 setenv_var __MODULES_LMINIT "module use --append $modpath:module load $module"
71 testouterr_cmd sh reset $ans reset\n[msg_load $module]
72 unsetenv_var __MODULES_LMINIT
73
74 # test stash
75 setenv_var __MODULES_LMINIT "module use --append $modpath:module load $module"
76 testouterr_cmd sh stash $ans stash\n[msg_load $module]
77 unsetenv_var __MODULES_LMINIT
78
79 # test stashpop
80 setenv_loaded_module [list $module] [list $modulefile]
81 testouterr_cmd sh stashpop $ansun stashpop\n[msg_unload $module]
82 unsetenv_loaded_module
83
84 # test displaying
85 testouterr_cmd_re "sh" "display $module" "OK" "$modlin\n$modulefilere:\n\ndisplay\n$modlin"
86
87 # test whatis
88 testouterr_cmd_re "sh" "whatis $module" "OK" "$header\n\\s+$module: whatis(\\n\\s+\\S*$module\\S*: .*)*"
89
90 # test searching
91 # error found in interpreted module, so an error code is rendered
92 testouterr_cmd_re "sh" "search search" "ERR" "$header\n\\s+$module: search(\\n\\s+\\S+: search)*"
93
94 # test sourcing
95 testouterr_cmd "sh" "source $modulefile" "OK" "source"
96
97 # set HOME to location containing collections
98 set homewithcoll "$env(HOME)/home"
99 if {$verbose} {
100 send_user "\tSetup HOME = $homewithcoll\n"
101 }
102 set env(HOME) "$homewithcoll"
103
104 # test restoring
105 testouterr_cmd "sh" "restore infocmd" $ans restore\n[msg_load $module]
106
107 # restore default testsuite home
108 if {$verbose} {
109 send_user "\tRestore HOME = $ORIG_HOME\n"
110 }
111 set env(HOME) $ORIG_HOME
112
113 # Set up the environment for test that require the module to be loaded
114 setenv_loaded_module $module $modulefile
115
116 # test unloading
117 testouterr_cmd "sh" "unload $module" $ansun "unload"
118
119 # test switching
120 testouterr_cmd "sh" "switch $module $module" $ans "switch\nswitch"
121
122 # test refreshing
123 setenv_var __MODULES_LMREFRESH $module
124 testouterr_cmd sh refresh OK refresh
125 unsetenv_var __MODULES_LMREFRESH
126
127 # test purging
128 testouterr_cmd "sh" "purge" $ansun "purge"
129
130 # test reloading
131 testouterr_cmd "sh" "reload" $ans "reload\nreload"
132 testouterr_cmd "sh" "update" $ans "reload\nreload"
133
134 # Clean up the just changed environment
135 unsetenv_loaded_module
136
137 # test help
138 testouterr_cmd_re "sh" "help $module" "OK" "$modlin\n$header_help\n\nhelp\nhelp\n$modlin"
139
140 # test test
141 testouterr_cmd_re "sh" "test $module" "OK" "$modlin\n$header_test\n\ntest\ntest\nTest result: PASS\n$modlin"
142
143
144 setenv_var MODULEPATH $modpath.4
145
146 # test spider
147 setenv_var TESTSUITE_INFO_COMMAND spider
148 set tserr "spider\n$modpath.4:\ninfo/command\ninfo/commandexp"
149 testouterr_cmd sh "spider -t $module" OK $tserr
150
151
152 #
153 # Cleanup
154 #
155
156 reset_test_env