| 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: 2018/03/20 |
| 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 handling of argument strings on all shells |
| 18 |
# }C% |
| 19 |
# |
| 20 |
############################################################################## |
| 21 |
|
| 22 |
set modfile "$env(TESTSUITEDIR)/modulefiles.2/putsvar" |
| 23 |
|
| 24 |
set err_emptymod "$error_msgs: Invalid empty module name" |
| 25 |
set err_emptydir "$error_msgs: Invalid empty directory name" |
| 26 |
set err_locatemod "$error_msgs: Unable to locate a modulefile for '{foo bar}'" |
| 27 |
set err_locatemod2 "$error_msgs: Unable to locate a modulefile for '{foo\\\\\ bar}'" |
| 28 |
set err_locatemod3 "$error_msgs: Unable to locate a modulefile for '\$foo'" |
| 29 |
set err_locatemod4 "$error_msgs: Unable to locate a modulefile for '\\\$foo'" |
| 30 |
set err_locatemod5 "$error_msgs: Unable to locate a modulefile for '\\\\\\\$foo'" |
| 31 |
set err_locatemod6 "$error_msgs: Unable to locate a modulefile for '\"\"'" |
| 32 |
set err_locatemod7 "$error_msgs: Unable to locate a modulefile for ''''" |
| 33 |
set usage_msg "^Modules Release \\S+ (\\S+).*" |
| 34 |
|
| 35 |
set err_emptymod_re "(envmodule: )?$err_emptymod" |
| 36 |
set err_emptydir_re "(envmodule: )?$err_emptydir" |
| 37 |
set err_locatemod_re "(envmodule: )?$err_locatemod" |
| 38 |
set err_locatemod2_re "(envmodule: )?$err_locatemod2" |
| 39 |
set err_locatemod3_re "(envmodule: )?$err_locatemod3" |
| 40 |
set err_locatemod4_re "(envmodule: )?$err_locatemod4" |
| 41 |
set err_locatemod5_re "(envmodule: )?$err_locatemod5" |
| 42 |
set err_locatemod6_re "(envmodule: )?$err_locatemod6" |
| 43 |
set err_locatemod7_re "(envmodule: )?$err_locatemod7" |
| 44 |
|
| 45 |
# |
| 46 |
# The tests |
| 47 |
# |
| 48 |
|
| 49 |
if {$verbose} { |
| 50 |
send_user "\tChecking handling of argument strings\n" |
| 51 |
} |
| 52 |
|
| 53 |
set foo ":/path/to/dir1" |
| 54 |
set bar "/path/to/dir3" |
| 55 |
if {$verbose} { |
| 56 |
send_user "\tSetup FOO = '$foo'\n" |
| 57 |
send_user "\tSetup BAR = '$bar'\n" |
| 58 |
} |
| 59 |
set env(FOO) "$foo" |
| 60 |
set env(BAR) "$bar" |
| 61 |
|
| 62 |
for {set i 0} {$i < 2} {incr i} { |
| 63 |
|
| 64 |
# do the tests twice, second time with a quarantine setup |
| 65 |
# to check quarantine mechanism does not alter argument handling |
| 66 |
if {$i == 1} { |
| 67 |
# skip tests with quarantine enabled if space character found in install path |
| 68 |
if {[string first { } $install_libexecdir] != -1} { |
| 69 |
send_user "\tSkip quarantine mechanism test as installation path is not compliant with it\n" |
| 70 |
break |
| 71 |
} |
| 72 |
if {$verbose} { |
| 73 |
send_user "\tSetup MODULES_RUN_QUARANTINE = 'FOO'\n" |
| 74 |
} |
| 75 |
set env(MODULES_RUN_QUARANTINE) "FOO" |
| 76 |
} |
| 77 |
|
| 78 |
foreach shell $shell_list { |
| 79 |
testall_cmd "$shell" "module use \"\"" "" $err_emptydir 1 |
| 80 |
testall_cmd "$shell" "module load ''" "" $err_emptymod 1 |
| 81 |
testall_cmd "$shell" "module load \\\"\\\"" "" $err_locatemod6 1 |
| 82 |
testall_cmd "$shell" "module load \\'\\'" "" $err_locatemod7 1 |
| 83 |
testall_cmd "$shell" "module load \"foo bar\"" "" $err_locatemod 1 |
| 84 |
testall_cmd "$shell" "module load foo\\ bar" "" $err_locatemod 1 |
| 85 |
testall_cmd "$shell" "module load \\\$foo" "" $err_locatemod3 1 |
| 86 |
testall_cmd_re "$shell" "module" "" $usage_msg 0 |
| 87 |
testall_cmd_re "$shell" "module " "" $usage_msg 0 |
| 88 |
testall_cmd_re "$shell" "module \"\"" "" $usage_msg 0 |
| 89 |
testall_cmd_re "$shell" "module \"\" \"\"" "" $usage_msg 0 |
| 90 |
testall_cmd "$shell" "module append-path -d \" \" FOO /path/to/dir2;module source $modfile" "" "$foo /path/to/dir2" 0 |
| 91 |
testall_cmd "$shell" "module append-path -d ' ' FOO /path/to/dir2;module source $modfile" "" "$foo /path/to/dir2" 0 |
| 92 |
testall_cmd "$shell" "module append-path FOO \"\$BAR\";module source $modfile" "" "$foo:$bar" 0 |
| 93 |
testall_cmd "$shell" "module append-path FOO \\\$foo;module source $modfile" "" "$foo:\$foo" 0 |
| 94 |
testall_cmd "$shell" "module append-path --duplicates FOO \"\";module source $modfile" "" "$foo:" 0 |
| 95 |
testall_cmd "$shell" "module remove-path FOO \"\";module source $modfile" "" "/path/to/dir1" 0 |
| 96 |
} |
| 97 |
|
| 98 |
# ensure colored output is disabled for CMake tests |
| 99 |
setenv_var CLICOLOR 0 |
| 100 |
foreach shell $othlang_list { |
| 101 |
switch -- $shell { |
| 102 |
r { |
| 103 |
set postmsg "\nError: \nExecution halted" |
| 104 |
} |
| 105 |
cmake { |
| 106 |
set postmsg "\nCMake Error at testsuite/bin/install_test_cmake:71 \\\(message\\\):\n\n" |
| 107 |
} |
| 108 |
default { |
| 109 |
set postmsg {} |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
testall_cmd_re "$shell" "use," "" $err_emptydir_re$postmsg 1 |
| 114 |
testall_cmd_re "$shell" "load," "" $err_emptymod_re$postmsg 1 |
| 115 |
# langs swallow " differently |
| 116 |
switch -- $shell { |
| 117 |
{perl} - {ruby} - {r} { |
| 118 |
testall_cmd_re "$shell" "load,\"\"" "" $err_emptymod_re$postmsg 1 |
| 119 |
} |
| 120 |
default { |
| 121 |
testall_cmd_re "$shell" "load,\"\"" "" $err_locatemod6_re$postmsg 1 |
| 122 |
} |
| 123 |
} |
| 124 |
testall_cmd_re "$shell" "load,''" "" $err_locatemod7_re$postmsg 1 |
| 125 |
testall_cmd_re "$shell" "load,foo bar" "" $err_locatemod_re$postmsg 1 |
| 126 |
testall_cmd_re "$shell" "load,foo\\ bar" "" $err_locatemod2_re$postmsg 1 |
| 127 |
# langs swallow \$ differently |
| 128 |
switch -- $shell { |
| 129 |
{tcl} - {python} - {cmake} - {pwsh} { |
| 130 |
testall_cmd_re "$shell" "load,\\\$foo" "" $err_locatemod5_re$postmsg 1 |
| 131 |
} |
| 132 |
default { |
| 133 |
testall_cmd_re "$shell" "load,\\\$foo" "" $err_locatemod4_re$postmsg 1 |
| 134 |
} |
| 135 |
} |
| 136 |
testall_cmd_re "$shell" "NOARG" "" $usage_msg 0 |
| 137 |
if {$install_ml eq {y}} { |
| 138 |
testall_cmd_re "$shell" "ml:NOARG" "" "($no_loaded|$cur_loaded.*)" 0 1 |
| 139 |
} |
| 140 |
testall_cmd_re "$shell" "" "" $usage_msg 0 |
| 141 |
testall_cmd_re "$shell" "," "" $usage_msg 0 |
| 142 |
|
| 143 |
switch -- $shell { |
| 144 |
cmake { |
| 145 |
set premsg "(CMake Warning .*\n)?" |
| 146 |
} |
| 147 |
default { |
| 148 |
set premsg {} |
| 149 |
} |
| 150 |
} |
| 151 |
testall_cmd_re "$shell" "append-path,-d, ,FOO,/path/to/dir2:source,$modfile" "" "$premsg$foo /path/to/dir2" 0 |
| 152 |
# langs swallow \$ differently |
| 153 |
switch -- $shell { |
| 154 |
tcl - pwsh { |
| 155 |
testall_cmd_re "$shell" "append-path,FOO,\\\$foo:source,$modfile" "" "$foo:\\\\\\\$foo" 0 |
| 156 |
} |
| 157 |
python { |
| 158 |
testall_cmd_re "$shell" "append-path,FOO,\\\$foo:source,$modfile" "" "(<string>:3: SyntaxWarning: invalid escape sequence '\\\\\\$'\\n|<string>:3: SyntaxWarning: \"\\\\\\$\" is an invalid escape sequence.*\\n)?$foo:\\\\\\\$foo" 0 |
| 159 |
} |
| 160 |
default { |
| 161 |
testall_cmd_re "$shell" "append-path,FOO,\\\$foo:source,$modfile" "" "$foo:\\\$foo" 0 |
| 162 |
} |
| 163 |
} |
| 164 |
testall_cmd_re "$shell" "append-path,--duplicates,FOO,:source,$modfile" "" "$foo:" 0 |
| 165 |
testall_cmd_re "$shell" "remove-path,FOO,:source,$modfile" "" "/path/to/dir1" 0 |
| 166 |
} |
| 167 |
unsetenv_var CLICOLOR |
| 168 |
|
| 169 |
} |
| 170 |
|
| 171 |
# |
| 172 |
# Clean up variables used in this test case |
| 173 |
# |
| 174 |
|
| 175 |
reset_test_env |
| 176 |
|
| 177 |
# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: |