Debian Codegraph @

testsuite/install.00-init/040-subshell.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: 2017/05/07
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 module command propagation in sub shells
18
19 # }C%
20 #
21 ##############################################################################
22
23
24 set bad_cmd "$error_msgs: Invalid command 'foo'"
25 set zsh_nf "command not found: module"
26 set zsh_nf_ml "command not found: ml"
27 set tcsh_nf "module: Command not found."
28 set tcsh_nf_ml "ml: Command not found."
29 if {$os_name eq "sunos"} {
30 set csh_nf "module: Command not found"
31 set csh_nf_ml "ml: Command not found"
32 } else {
33 set csh_nf $tcsh_nf
34 set csh_nf_ml $tcsh_nf_ml
35 }
36 set fish_nf "fish: Unknown command:? '?module"
37 set fish_nf_ml "fish: Unknown command:? '?ml"
38 if {$os_name eq "sunos"} {
39 set sh_nf "module: not found \\\[No such file or directory\\\]"
40 set sh_nf_ml "ml: not found \\\[No such file or directory\\\]"
41 } elseif {$os_name eq "freebsd"} {
42 set sh_nf "eval: module: not found"
43 set sh_nf_ml "eval: ml: not found"
44 } else {
45 set sh_nf "(.*: )?module: not found"
46 set sh_nf_ml "ml: not found"
47 }
48
49 #
50 # The tests
51 #
52
53 if {$verbose} {
54 send_user "\tChecking module command propagation in sub shell\n"
55 }
56
57 set shell_level "sub"
58 foreach shell $shell_list {
59 # No module command propagation available for some shells
60 switch -- $shell {
61 zsh {
62 testall_cmd_re "$shell" "module --version" {} ".*$zsh_nf" 127
63 testall_cmd_re "$shell" "module foo" {} ".*$zsh_nf" 127
64 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module list -t" {} ".*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf" 252
65 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module unload null\; module list -t" {} ".*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf" 123
66 if {$install_ml eq {y}} {
67 testall_cmd_re "$shell" "ml use $share_modpath\; ml purge\; ml null\; ml -null\; ml" {} ".*$zsh_nf_ml\n.*$zsh_nf_ml\n.*$zsh_nf_ml\n.*$zsh_nf_ml\n.*$zsh_nf_ml" 123
68 }
69 }
70 csh {
71 testall_cmd_re "$shell" "module --version" {} "$csh_nf" 1
72 testall_cmd_re "$shell" "module foo" {} "$csh_nf" 1
73 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module list -t" {} ".*$csh_nf\n.*$csh_nf\n.*$csh_nf\n.*$csh_nf" 4
74 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module unload null\; module list -t" {} ".*$csh_nf\n.*$csh_nf\n.*$csh_nf\n.*$csh_nf\n.*$csh_nf" 5
75 if {$install_ml eq {y}} {
76 testall_cmd_re "$shell" "ml use $share_modpath\; ml purge\; ml null\; ml -null\; ml" {} ".*$csh_nf_ml\n.*$csh_nf_ml\n.*$csh_nf_ml\n.*$csh_nf_ml\n.*$csh_nf_ml" 5
77 }
78 }
79 tcsh {
80 testall_cmd_re "$shell" "module --version" {} "$tcsh_nf" 1
81 testall_cmd_re "$shell" "module foo" {} "$tcsh_nf" 1
82 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module list -t" {} ".*$tcsh_nf\n.*$tcsh_nf\n.*$tcsh_nf\n.*$tcsh_nf" 4
83 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module unload null\; module list -t" {} ".*$tcsh_nf\n.*$tcsh_nf\n.*$tcsh_nf\n.*$tcsh_nf\n.*$tcsh_nf" 5
84 if {$install_ml eq {y}} {
85 testall_cmd_re "$shell" "ml use $share_modpath\; ml purge\; ml null\; ml -null\; ml" {} ".*$tcsh_nf_ml\n.*$tcsh_nf_ml\n.*$tcsh_nf_ml\n.*$tcsh_nf_ml\n.*$tcsh_nf_ml" 5
86 }
87 }
88 fish {
89 testall_cmd_re "$shell" "module --version" {} "$fish_nf.*" [expr {$fish_version_is31 ? {1} : {127}}]
90 testall_cmd_re "$shell" "module foo" {} "$fish_nf.*" [expr {$fish_version_is31 ? {1} : {127}}]
91 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module list -t" {} ".*$fish_nf.*$fish_nf.*$fish_nf.*$fish_nf.*" [expr {$fish_version_is31 ? {4} : [expr {$fish_version_ge32 ? {255} : {252}}]}]
92 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module unload null\; module list -t" {} ".*$fish_nf.*$fish_nf.*$fish_nf.*$fish_nf.*$fish_nf.*" [expr {$fish_version_is31 ? {5} : [expr {$fish_version_ge32 ? {255} : {123}}]}]
93 if {$install_ml eq {y}} {
94 testall_cmd_re "$shell" "ml use $share_modpath\; ml purge\; ml null\; ml -null\; ml" {} ".*$fish_nf_ml.*$fish_nf_ml.*$fish_nf_ml.*$fish_nf_ml.*$fish_nf_ml.*" [expr {$fish_version_is31 ? {5} : [expr {$fish_version_ge32 ? {255} : {123}}]}]
95 }
96 }
97 default {
98 if {$shell eq "sh" && $sh_strict} {
99 testall_cmd_re "$shell" "module --version" {} "$sh_nf" 127
100 testall_cmd_re "$shell" "module foo" {} "$sh_nf" 127
101 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module list -t" {} ".*$sh_nf\n.*$sh_nf\n.*$sh_nf\n.*$sh_nf" 252
102 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module unload null\; module list -t" {} ".*$sh_nf\n.*$sh_nf\n.*$sh_nf\n.*$sh_nf\n.*$sh_nf" 123
103 if {$install_ml eq {y}} {
104 testall_cmd_re "$shell" "ml use $share_modpath\; ml purge\; ml null\; ml -null\; ml" {} ".*$sh_nf_ml\n.*$sh_nf_ml\n.*$sh_nf_ml\n.*$sh_nf_ml\n.*$sh_nf_ml" 123
105 }
106 } else {
107 testall_cmd_re "$shell" "module --version" {} "Modules Release \\S+ (\\S+)" 0
108 testall_cmd "$shell" "module foo" "" "$bad_cmd\n$type_help" 1
109 testall_cmd "$shell" "module use $share_modpath\; module purge\; module load null\; module list -t" "" "$cur_loaded\nnull" 0
110 testall_cmd "$shell" "module use $share_modpath\; module purge\; module load null\; module unload null\; module list -t" "" "$no_loaded" 0
111 if {$install_ml eq {y}} {
112 testall_cmd "$shell" "ml use $share_modpath\; ml purge\; ml null\; ml -null\; ml" "" "$no_loaded" 0
113 }
114 }
115 }
116 }
117 }
118
119 if {$verbose} {
120 send_user "\tChecking module command propagation in sub sub shell\n"
121 }
122
123 set shell_level "subsub"
124 foreach shell $shell_list {
125 # No module command propagation available for some shells
126 switch -- $shell {
127 zsh {
128 testall_cmd_re "$shell" "module --version" {} ".*$zsh_nf" 127
129 testall_cmd_re "$shell" "module foo" {} ".*$zsh_nf" 127
130 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module list -t" {} ".*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf" 252
131 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module unload null\; module list -t" {} ".*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf\n.*$zsh_nf" 123
132 if {$install_ml eq {y}} {
133 testall_cmd_re "$shell" "ml use $share_modpath\; ml purge\; ml null\; ml -null\; ml" {} ".*$zsh_nf_ml\n.*$zsh_nf_ml\n.*$zsh_nf_ml\n.*$zsh_nf_ml\n.*$zsh_nf_ml" 123
134 }
135 }
136 csh {
137 testall_cmd_re "$shell" "module --version" {} "$csh_nf" 1
138 testall_cmd_re "$shell" "module foo" {} "$csh_nf" 1
139 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module list -t" {} ".*$csh_nf\n.*$csh_nf\n.*$csh_nf\n.*$csh_nf" 4
140 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module unload null\; module list -t" {} ".*$csh_nf\n.*$csh_nf\n.*$csh_nf\n.*$csh_nf\n.*$csh_nf" 5
141 if {$install_ml eq {y}} {
142 testall_cmd_re "$shell" "ml use $share_modpath\; ml purge\; ml null\; ml -null\; ml" {} ".*$csh_nf_ml\n.*$csh_nf_ml\n.*$csh_nf_ml\n.*$csh_nf_ml\n.*$csh_nf_ml" 5
143 }
144 }
145 tcsh {
146 testall_cmd_re "$shell" "module --version" {} "$tcsh_nf" 1
147 testall_cmd_re "$shell" "module foo" {} "$tcsh_nf" 1
148 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module list -t" {} ".*$tcsh_nf\n.*$tcsh_nf\n.*$tcsh_nf\n.*$tcsh_nf" 4
149 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module unload null\; module list -t" {} ".*$tcsh_nf\n.*$tcsh_nf\n.*$tcsh_nf\n.*$tcsh_nf\n.*$tcsh_nf" 5
150 if {$install_ml eq {y}} {
151 testall_cmd_re "$shell" "ml use $share_modpath\; ml purge\; ml null\; ml -null\; ml" {} ".*$tcsh_nf_ml\n.*$tcsh_nf_ml\n.*$tcsh_nf_ml\n.*$tcsh_nf_ml\n.*$tcsh_nf_ml" 5
152 }
153 }
154 fish {
155 testall_cmd_re "$shell" "module --version" {} "$fish_nf.*" [expr {$fish_version_is31 ? {1} : {127}}]
156 testall_cmd_re "$shell" "module foo" {} "$fish_nf.*" [expr {$fish_version_is31 ? {1} : {127}}]
157 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module list -t" {} ".*$fish_nf.*$fish_nf.*$fish_nf.*$fish_nf.*" [expr {$fish_version_is31 ? {4} : [expr {$fish_version_ge32 ? {255} : {252}}]}]
158 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module unload null\; module list -t" {} ".*$fish_nf.*$fish_nf.*$fish_nf.*$fish_nf.*$fish_nf.*" [expr {$fish_version_is31 ? {5} : [expr {$fish_version_ge32 ? {255} : {123}}]}]
159 if {$install_ml eq {y}} {
160 testall_cmd_re "$shell" "ml use $share_modpath\; ml purge\; ml null\; ml -null\; ml" {} ".*$fish_nf_ml.*$fish_nf_ml.*$fish_nf_ml.*$fish_nf_ml.*$fish_nf_ml.*" [expr {$fish_version_is31 ? {5} : [expr {$fish_version_ge32 ? {255} : {123}}]}]
161 }
162 }
163 default {
164 if {$shell eq "sh" && $sh_strict} {
165 testall_cmd_re "$shell" "module --version" {} "$sh_nf" 127
166 testall_cmd_re "$shell" "module foo" {} "$sh_nf" 127
167 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module list -t" {} ".*$sh_nf\n.*$sh_nf\n.*$sh_nf\n.*$sh_nf" 252
168 testall_cmd_re "$shell" "module use $share_modpath\; module purge\; module load null\; module unload null\; module list -t" {} ".*$sh_nf\n.*$sh_nf\n.*$sh_nf\n.*$sh_nf\n.*$sh_nf" 123
169 if {$install_ml eq {y}} {
170 testall_cmd_re "$shell" "ml use $share_modpath\; ml purge\; ml null\; ml -null\; ml" {} ".*$sh_nf_ml\n.*$sh_nf_ml\n.*$sh_nf_ml\n.*$sh_nf_ml\n.*$sh_nf_ml" 123
171 }
172 } else {
173 testall_cmd_re "$shell" "module --version" {} "Modules Release \\S+ (\\S+)" 0
174 testall_cmd "$shell" "module foo" "" "$bad_cmd\n$type_help" 1
175 testall_cmd "$shell" "module use $share_modpath\; module purge\; module load null\; module list -t" "" "$cur_loaded\nnull" 0
176 testall_cmd "$shell" "module use $share_modpath\; module purge\; module load null\; module unload null\; module list -t" "" "$no_loaded" 0
177 if {$install_ml eq {y}} {
178 testall_cmd "$shell" "ml use $share_modpath\; ml purge\; ml null\; ml -null\; ml" "" "$no_loaded" 0
179 }
180 }
181 }
182 }
183 }
184
185
186 #
187 # Clean up variables used in this test case
188 #
189
190 reset_test_env
191
192 # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: