############################################################################## # Modules Revision 3.0 # Providing a flexible user environment # # File: modules.00-init/%M% # Revision: %I% # First Edition: 2018/03/20 # Last Mod.: %U%, %G% # # Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr # # Description: Testuite testsequence # Command: # Sub-Command: # # Comment: %C{ # Check handling of argument strings on all shells # }C% # ############################################################################## set modfile "$env(TESTSUITEDIR)/modulefiles.2/putsvar" set err_emptymod "$error_msgs: Invalid empty module name" set err_emptydir "$error_msgs: Invalid empty directory name" set err_locatemod "$error_msgs: Unable to locate a modulefile for '{foo bar}'" set err_locatemod2 "$error_msgs: Unable to locate a modulefile for '{foo\\\\\ bar}'" set err_locatemod3 "$error_msgs: Unable to locate a modulefile for '\$foo'" set err_locatemod4 "$error_msgs: Unable to locate a modulefile for '\\\$foo'" set err_locatemod5 "$error_msgs: Unable to locate a modulefile for '\\\\\\\$foo'" set err_locatemod6 "$error_msgs: Unable to locate a modulefile for '\"\"'" set err_locatemod7 "$error_msgs: Unable to locate a modulefile for ''''" set usage_msg "^Modules Release \\S+ (\\S+).*" set err_emptymod_re "(envmodule: )?$err_emptymod" set err_emptydir_re "(envmodule: )?$err_emptydir" set err_locatemod_re "(envmodule: )?$err_locatemod" set err_locatemod2_re "(envmodule: )?$err_locatemod2" set err_locatemod3_re "(envmodule: )?$err_locatemod3" set err_locatemod4_re "(envmodule: )?$err_locatemod4" set err_locatemod5_re "(envmodule: )?$err_locatemod5" set err_locatemod6_re "(envmodule: )?$err_locatemod6" set err_locatemod7_re "(envmodule: )?$err_locatemod7" # # The tests # if {$verbose} { send_user "\tChecking handling of argument strings\n" } set foo ":/path/to/dir1" set bar "/path/to/dir3" if {$verbose} { send_user "\tSetup FOO = '$foo'\n" send_user "\tSetup BAR = '$bar'\n" } set env(FOO) "$foo" set env(BAR) "$bar" for {set i 0} {$i < 2} {incr i} { # do the tests twice, second time with a quarantine setup # to check quarantine mechanism does not alter argument handling if {$i == 1} { # skip tests with quarantine enabled if space character found in install path if {[string first { } $install_libexecdir] != -1} { send_user "\tSkip quarantine mechanism test as installation path is not compliant with it\n" break } if {$verbose} { send_user "\tSetup MODULES_RUN_QUARANTINE = 'FOO'\n" } set env(MODULES_RUN_QUARANTINE) "FOO" } foreach shell $shell_list { testall_cmd "$shell" "module use \"\"" "" $err_emptydir 1 testall_cmd "$shell" "module load ''" "" $err_emptymod 1 testall_cmd "$shell" "module load \\\"\\\"" "" $err_locatemod6 1 testall_cmd "$shell" "module load \\'\\'" "" $err_locatemod7 1 testall_cmd "$shell" "module load \"foo bar\"" "" $err_locatemod 1 testall_cmd "$shell" "module load foo\\ bar" "" $err_locatemod 1 testall_cmd "$shell" "module load \\\$foo" "" $err_locatemod3 1 testall_cmd_re "$shell" "module" "" $usage_msg 0 testall_cmd_re "$shell" "module " "" $usage_msg 0 testall_cmd_re "$shell" "module \"\"" "" $usage_msg 0 testall_cmd_re "$shell" "module \"\" \"\"" "" $usage_msg 0 testall_cmd "$shell" "module append-path -d \" \" FOO /path/to/dir2;module source $modfile" "" "$foo /path/to/dir2" 0 testall_cmd "$shell" "module append-path -d ' ' FOO /path/to/dir2;module source $modfile" "" "$foo /path/to/dir2" 0 testall_cmd "$shell" "module append-path FOO \"\$BAR\";module source $modfile" "" "$foo:$bar" 0 testall_cmd "$shell" "module append-path FOO \\\$foo;module source $modfile" "" "$foo:\$foo" 0 testall_cmd "$shell" "module append-path --duplicates FOO \"\";module source $modfile" "" "$foo:" 0 testall_cmd "$shell" "module remove-path FOO \"\";module source $modfile" "" "/path/to/dir1" 0 } # ensure colored output is disabled for CMake tests setenv_var CLICOLOR 0 foreach shell $othlang_list { switch -- $shell { r { set postmsg "\nError: \nExecution halted" } cmake { set postmsg "\nCMake Error at testsuite/bin/install_test_cmake:71 \\\(message\\\):\n\n" } default { set postmsg {} } } testall_cmd_re "$shell" "use," "" $err_emptydir_re$postmsg 1 testall_cmd_re "$shell" "load," "" $err_emptymod_re$postmsg 1 # langs swallow " differently switch -- $shell { {perl} - {ruby} - {r} { testall_cmd_re "$shell" "load,\"\"" "" $err_emptymod_re$postmsg 1 } default { testall_cmd_re "$shell" "load,\"\"" "" $err_locatemod6_re$postmsg 1 } } testall_cmd_re "$shell" "load,''" "" $err_locatemod7_re$postmsg 1 testall_cmd_re "$shell" "load,foo bar" "" $err_locatemod_re$postmsg 1 testall_cmd_re "$shell" "load,foo\\ bar" "" $err_locatemod2_re$postmsg 1 # langs swallow \$ differently switch -- $shell { {tcl} - {python} - {cmake} - {pwsh} { testall_cmd_re "$shell" "load,\\\$foo" "" $err_locatemod5_re$postmsg 1 } default { testall_cmd_re "$shell" "load,\\\$foo" "" $err_locatemod4_re$postmsg 1 } } testall_cmd_re "$shell" "NOARG" "" $usage_msg 0 if {$install_ml eq {y}} { testall_cmd_re "$shell" "ml:NOARG" "" "($no_loaded|$cur_loaded.*)" 0 1 } testall_cmd_re "$shell" "" "" $usage_msg 0 testall_cmd_re "$shell" "," "" $usage_msg 0 switch -- $shell { cmake { set premsg "(CMake Warning .*\n)?" } default { set premsg {} } } testall_cmd_re "$shell" "append-path,-d, ,FOO,/path/to/dir2:source,$modfile" "" "$premsg$foo /path/to/dir2" 0 # langs swallow \$ differently switch -- $shell { tcl - pwsh { testall_cmd_re "$shell" "append-path,FOO,\\\$foo:source,$modfile" "" "$foo:\\\\\\\$foo" 0 } python { testall_cmd_re "$shell" "append-path,FOO,\\\$foo:source,$modfile" "" "(:3: SyntaxWarning: invalid escape sequence '\\\\\\$'\\n|:3: SyntaxWarning: \"\\\\\\$\" is an invalid escape sequence.*\\n)?$foo:\\\\\\\$foo" 0 } default { testall_cmd_re "$shell" "append-path,FOO,\\\$foo:source,$modfile" "" "$foo:\\\$foo" 0 } } testall_cmd_re "$shell" "append-path,--duplicates,FOO,:source,$modfile" "" "$foo:" 0 testall_cmd_re "$shell" "remove-path,FOO,:source,$modfile" "" "/path/to/dir1" 0 } unsetenv_var CLICOLOR } # # Clean up variables used in this test case # reset_test_env # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: