| 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/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 module command propagation in sub shell of other kind |
| 18 |
# }C% |
| 19 |
# |
| 20 |
############################################################################## |
| 21 |
|
| 22 |
|
| 23 |
set bad_cmd "$error_msgs: Invalid command 'foo'" |
| 24 |
|
| 25 |
set bash_nf "(.*: )?module: command not found" |
| 26 |
if {$os_name eq "sunos"} { |
| 27 |
set cmd_nf "module: not found \\\[No such file or directory\\\]" |
| 28 |
} elseif {$os_name eq "freebsd"} { |
| 29 |
set cmd_nf "eval: module: not found" |
| 30 |
} elseif {$sh_kind eq "dash"} { |
| 31 |
set cmd_nf "(.*: )?module: not found" |
| 32 |
} else { |
| 33 |
set cmd_nf "$bash_nf" |
| 34 |
} |
| 35 |
# depending on ksh version, error message could change |
| 36 |
set ksh_nf "(.*: )?module: (inaccessible or )?not found( \\\[No such file or directory\\\])?" |
| 37 |
set zsh_nf "(\\\(eval\\\):1: )?command not found: module" |
| 38 |
set tcsh_nf "module: Command not found." |
| 39 |
if {$os_name eq "sunos"} { |
| 40 |
set csh_nf "module: Command not found" |
| 41 |
} else { |
| 42 |
set csh_nf $tcsh_nf |
| 43 |
} |
| 44 |
set fish_nf "fish: Unknown command:? '?module" |
| 45 |
|
| 46 |
# |
| 47 |
# The tests |
| 48 |
# |
| 49 |
|
| 50 |
if {$verbose} { |
| 51 |
send_user "\tChecking module command propagation in other kind of sub shell\n" |
| 52 |
} |
| 53 |
|
| 54 |
set idx 0 |
| 55 |
foreach subshell $shell_list { |
| 56 |
# exclude subshell from shell to test, as this combination has already |
| 57 |
# been checked in 020-module tests |
| 58 |
set shell_totest [lreplace $shell_list $idx $idx] |
| 59 |
incr idx |
| 60 |
|
| 61 |
set shell_level "sub" |
| 62 |
foreach shell $shell_totest { |
| 63 |
# No module command propagation available in most cases |
| 64 |
switch -- $subshell { |
| 65 |
sh { |
| 66 |
# propagate only when top shell defines module with export -f |
| 67 |
switch -- $shell { |
| 68 |
sh - bash - basheu { |
| 69 |
# if sh is dash, exported function will be ignored |
| 70 |
if {$subshell eq "sh" && $sh_strict} { |
| 71 |
testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127 |
| 72 |
} else { |
| 73 |
testall_cmd_re "$shell" "module --version" "" "Modules Release \\S+ (\\S+)" 0 |
| 74 |
} |
| 75 |
} |
| 76 |
ksh { |
| 77 |
# sh is a ksh on Solaris |
| 78 |
if {$os_name eq "sunos"} { |
| 79 |
testall_cmd_re "$shell" "module --version" "" "^Modules Release \\S+ (\\S+)" 0 |
| 80 |
} else { |
| 81 |
testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127 |
| 82 |
} |
| 83 |
} |
| 84 |
default { |
| 85 |
testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127 |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
# propagate in any cases as BASH_ENV is set everywhere when set_shell_startup is enabled |
| 90 |
bash { |
| 91 |
if {[is_set_shell_startup_enabled] || $shell eq {basheu} || ($shell eq {sh} && $sh_kind eq {bash})} { |
| 92 |
testall_cmd_re "$shell" "module --version" "" "^Modules Release \\S+ (\\S+)" 0 |
| 93 |
} else { |
| 94 |
testall_cmd_re "$shell" "module --version" "" "$bash_nf" 127 |
| 95 |
} |
| 96 |
} |
| 97 |
ksh { |
| 98 |
testall_cmd_re "$shell" "module --version" "" "$ksh_nf" 127 |
| 99 |
} |
| 100 |
zsh { |
| 101 |
testall_cmd_re "$shell" "module --version" "" "$zsh_nf" 127 |
| 102 |
} |
| 103 |
csh { |
| 104 |
testall_cmd_re "$shell" "module --version" "" "$csh_nf" 1 |
| 105 |
} |
| 106 |
tcsh { |
| 107 |
testall_cmd_re "$shell" "module --version" "" "$tcsh_nf" 1 |
| 108 |
} |
| 109 |
fish { |
| 110 |
testall_cmd_re "$shell" "module --version" "" "$fish_nf.*" [expr {$fish_version_is31 ? {1} : {127}}] |
| 111 |
} |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
set shell_level "subsub" |
| 116 |
foreach shell $shell_totest { |
| 117 |
# No module command propagation available in most cases |
| 118 |
switch -- $subshell { |
| 119 |
sh { |
| 120 |
# propagate only when top shell defines module with export -f |
| 121 |
switch -- $shell { |
| 122 |
sh - bash - basheu { |
| 123 |
# if sh is dash, exported function will be ignored |
| 124 |
if {$subshell eq "sh" && $sh_strict} { |
| 125 |
testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127 |
| 126 |
} else { |
| 127 |
testall_cmd_re "$shell" "module --version" "" "^Modules Release \\S+ (\\S+)" 0 |
| 128 |
} |
| 129 |
} |
| 130 |
ksh { |
| 131 |
# sh is a ksh on Solaris |
| 132 |
if {$os_name eq "sunos"} { |
| 133 |
testall_cmd_re "$shell" "module --version" "" "^Modules Release \\S+ (\\S+)" 0 |
| 134 |
} else { |
| 135 |
testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127 |
| 136 |
} |
| 137 |
} |
| 138 |
default { |
| 139 |
testall_cmd_re "$shell" "module --version" "" "$cmd_nf" 127 |
| 140 |
} |
| 141 |
} |
| 142 |
} |
| 143 |
# propagate in any cases as BASH_ENV is set everywhere when set_shell_startup is enabled |
| 144 |
bash { |
| 145 |
if {[is_set_shell_startup_enabled] || $shell eq {basheu} || ($shell eq {sh} && $sh_kind eq {bash})} { |
| 146 |
testall_cmd_re "$shell" "module --version" "" "^Modules Release \\S+ (\\S+)" 0 |
| 147 |
} else { |
| 148 |
testall_cmd_re "$shell" "module --version" "" "$bash_nf" 127 |
| 149 |
} |
| 150 |
} |
| 151 |
ksh { |
| 152 |
testall_cmd_re "$shell" "module --version" "" "$ksh_nf" 127 |
| 153 |
} |
| 154 |
zsh { |
| 155 |
testall_cmd_re "$shell" "module --version" "" "$zsh_nf" 127 |
| 156 |
} |
| 157 |
csh { |
| 158 |
testall_cmd_re "$shell" "module --version" "" "$csh_nf" 1 |
| 159 |
} |
| 160 |
tcsh { |
| 161 |
testall_cmd_re "$shell" "module --version" "" "$tcsh_nf" 1 |
| 162 |
} |
| 163 |
fish { |
| 164 |
testall_cmd_re "$shell" "module --version" "" "$fish_nf.*" [expr {$fish_version_is31 ? {1} : {127}}] |
| 165 |
} |
| 166 |
} |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
if {[lsearch -exact $shell_list ksh] != -1} { |
| 171 |
if {$verbose} { |
| 172 |
send_user "\tChecking module command propagation in ksh sub-shell with MODULES_SHELLS_WITH_KSH_FPATH\n" |
| 173 |
} |
| 174 |
set ::env(MODULES_SHELLS_WITH_KSH_FPATH) {sh:bash:csh:tcsh} |
| 175 |
set subshell ksh |
| 176 |
set shell_level sub |
| 177 |
foreach shell $shell_list { |
| 178 |
if {[lsearch -exact [split $::env(MODULES_SHELLS_WITH_KSH_FPATH) :] $shell] != -1} { |
| 179 |
testall_cmd_re $shell {module --version} "" "^Modules Release \\S+ (\\S+)" 0 |
| 180 |
} |
| 181 |
} |
| 182 |
unset ::env(MODULES_SHELLS_WITH_KSH_FPATH) |
| 183 |
} |
| 184 |
|
| 185 |
# |
| 186 |
# Clean up variables used in this test case |
| 187 |
# |
| 188 |
|
| 189 |
reset_test_env |
| 190 |
|
| 191 |
# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: |