File: 050-crossshell.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 (191 lines) | stat: -rw-r--r-- 6,712 bytes parent folder | download
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:       modules.00-init/%M%
#   Revision:       %I%
#   First Edition:  2017/05/08
#   Last Mod.:      %U%, %G%
#
#   Authors:        Xavier Delaruelle, xavier.delaruelle@cea.fr
#
#   Description:    Testuite testsequence
#   Command:
#   Sub-Command:
#
#   Comment:    %C{
#           Check module command propagation in sub shell of other kind
#       }C%
#
##############################################################################


set bad_cmd "$error_msgs: Invalid command 'foo'"

set bash_nf "(.*: )?module: command not found"
if {$os_name eq "sunos"} {
   set cmd_nf "module: not found \\\[No such file or directory\\\]"
} elseif {$os_name eq "freebsd"} {
   set cmd_nf "eval: module: not found"
} elseif {$sh_kind eq "dash"} {
   set cmd_nf "(.*: )?module: not found"
} else {
   set cmd_nf "$bash_nf"
}
# depending on ksh version, error message could change
set ksh_nf "(.*: )?module: (inaccessible or )?not found( \\\[No such file or directory\\\])?"
set zsh_nf "(\\\(eval\\\):1: )?command not found: module"
set tcsh_nf "module: Command not found."
if {$os_name eq "sunos"} {
   set csh_nf "module: Command not found"
} else {
   set csh_nf $tcsh_nf
}
set fish_nf "fish: Unknown command:? '?module"

#
# The tests
#

if {$verbose} {
   send_user "\tChecking module command propagation in other kind of sub shell\n"
}

set idx 0
foreach subshell $shell_list {
   # exclude subshell from shell to test, as this combination has already
   # been checked in 020-module tests
   set shell_totest [lreplace $shell_list $idx $idx]
   incr idx

   set shell_level "sub"
   foreach shell $shell_totest {
      # No module command propagation available in most cases
      switch -- $subshell {
         sh {
            # propagate only when top shell defines module with export -f
            switch -- $shell {
               sh - bash - basheu {
                  # if sh is dash, exported function will be ignored
                  if {$subshell eq "sh" && $sh_strict} {
                     testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127
                  } else {
                     testall_cmd_re "$shell" "module --version" "" "Modules Release \\S+ (\\S+)" 0
                  }
               }
               ksh {
                  # sh is a ksh on Solaris
                  if {$os_name eq "sunos"} {
                     testall_cmd_re "$shell" "module --version" "" "^Modules Release \\S+ (\\S+)" 0
                  } else {
                     testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127
                  }
               }
               default {
                  testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127
               }
            }
         }
         # propagate in any cases as BASH_ENV is set everywhere when set_shell_startup is enabled
         bash {
            if {[is_set_shell_startup_enabled] || $shell eq {basheu} || ($shell eq {sh} && $sh_kind eq {bash})} {
               testall_cmd_re "$shell" "module --version" "" "^Modules Release \\S+ (\\S+)" 0
            } else {
               testall_cmd_re "$shell" "module --version" "" "$bash_nf" 127
            }
         }
         ksh {
            testall_cmd_re "$shell" "module --version" "" "$ksh_nf" 127
         }
         zsh {
            testall_cmd_re "$shell" "module --version" "" "$zsh_nf" 127
         }
         csh {
            testall_cmd_re "$shell" "module --version" "" "$csh_nf" 1
         }
         tcsh {
            testall_cmd_re "$shell" "module --version" "" "$tcsh_nf" 1
         }
         fish {
            testall_cmd_re "$shell" "module --version" "" "$fish_nf.*" [expr {$fish_version_is31 ? {1} : {127}}]
         }
      }
   }

   set shell_level "subsub"
   foreach shell $shell_totest {
      # No module command propagation available in most cases
      switch -- $subshell {
         sh {
            # propagate only when top shell defines module with export -f
            switch -- $shell {
               sh - bash - basheu {
                  # if sh is dash, exported function will be ignored
                  if {$subshell eq "sh" && $sh_strict} {
                     testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127
                  } else {
                     testall_cmd_re "$shell" "module --version" "" "^Modules Release \\S+ (\\S+)" 0
                  }
               }
               ksh {
                  # sh is a ksh on Solaris
                  if {$os_name eq "sunos"} {
                     testall_cmd_re "$shell" "module --version" "" "^Modules Release \\S+ (\\S+)" 0
                  } else {
                     testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127
                  }
               }
               default {
                  testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127
               }
            }
         }
         # propagate in any cases as BASH_ENV is set everywhere when set_shell_startup is enabled
         bash {
            if {[is_set_shell_startup_enabled] || $shell eq {basheu} || ($shell eq {sh} && $sh_kind eq {bash})} {
               testall_cmd_re "$shell" "module --version" "" "^Modules Release \\S+ (\\S+)" 0
            } else {
               testall_cmd_re "$shell" "module --version" "" "$bash_nf" 127
            }
         }
         ksh {
            testall_cmd_re "$shell" "module --version" "" "$ksh_nf" 127
         }
         zsh {
            testall_cmd_re "$shell" "module --version" "" "$zsh_nf" 127
         }
         csh {
            testall_cmd_re "$shell" "module --version" "" "$csh_nf" 1
         }
         tcsh {
            testall_cmd_re "$shell" "module --version" "" "$tcsh_nf" 1
         }
         fish {
            testall_cmd_re "$shell" "module --version" "" "$fish_nf.*" [expr {$fish_version_is31 ? {1} : {127}}]
         }
      }
   }
}

if {[lsearch -exact $shell_list ksh] != -1} {
   if {$verbose} {
      send_user "\tChecking module command propagation in ksh sub-shell with MODULES_SHELLS_WITH_KSH_FPATH\n"
   }
   set ::env(MODULES_SHELLS_WITH_KSH_FPATH) {sh:bash:csh:tcsh}
   set subshell ksh
   set shell_level sub
   foreach shell $shell_list {
      if {[lsearch -exact [split $::env(MODULES_SHELLS_WITH_KSH_FPATH) :] $shell] != -1} {
         testall_cmd_re $shell {module --version} "" "^Modules Release \\S+ (\\S+)" 0
      }
   }
   unset ::env(MODULES_SHELLS_WITH_KSH_FPATH)
}

#
#  Clean up variables used in this test case
#

reset_test_env

# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: