| 1 |
############################################################################## |
| 2 |
# Modules Revision 3.0 |
| 3 |
# Providing a flexible user environment |
| 4 |
# |
| 5 |
# File: modules.50-cmds/%M% |
| 6 |
# Revision: %I% |
| 7 |
# First Edition: 2023/08/30 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: restore, reload, mod-to-sh, switch |
| 14 |
# Modulefiles: error, foo, all |
| 15 |
# Sub-Command: |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Test abort_on_error configuration option with |
| 19 |
# various sub-commands |
| 20 |
# }C% |
| 21 |
# |
| 22 |
############################################################################## |
| 23 |
|
| 24 |
skip_if_quick_mode |
| 25 |
|
| 26 |
set mp $modpath.4 |
| 27 |
set mpre $modpathre.4 |
| 28 |
setenv_path_var MODULEPATH $mp |
| 29 |
|
| 30 |
set ans_continue [list] |
| 31 |
lappend ans_continue [list out all-pre-out] |
| 32 |
lappend ans_continue [list set TSPATH dir1] |
| 33 |
lappend ans_continue [list set LOADEDMODULES all/1.0:foo/1.0] |
| 34 |
lappend ans_continue [list set _LMFILES_ $mp/all/1.0:$mp/foo/1.0] |
| 35 |
lappend ans_continue [list set __MODULES_LMREFRESH all/1.0] |
| 36 |
lappend ans_continue [list set TS ok] |
| 37 |
lappend ans_continue [list alias alall value] |
| 38 |
lappend ans_continue [list funcall "() { value; }; export -f funcall;"] |
| 39 |
lappend ans_continue [list out {complete value compall;}] |
| 40 |
lappend ans_continue [list chdir /tmp] |
| 41 |
lappend ans_continue [list out all-out] |
| 42 |
lappend ans_continue [list ERR] |
| 43 |
|
| 44 |
set ans_switch [list] |
| 45 |
lappend ans_switch [list unset LOADEDMODULES] |
| 46 |
lappend ans_switch [list unset _LMFILES_] |
| 47 |
lappend ans_switch [list ERR] |
| 48 |
|
| 49 |
|
| 50 |
set custom_error_trace " invoked from within |
| 51 |
\"if \{\[info exists env(TESTSUITE_ABORT_ON_ERROR)\]\} \{ |
| 52 |
switch -- \$env(TESTSUITE_ABORT_ON_ERROR) \{ |
| 53 |
bad - load_last_bad - load_first_bad - load-...\"" |
| 54 |
|
| 55 |
set ts_load_error [msg_load err/1.0 [msg_moderr msg {error msg} $mp/err/1.0 2 {} {} {} $custom_error_trace]] |
| 56 |
|
| 57 |
setenv_var TESTSUITE_ABORT_ON_ERROR load_error |
| 58 |
|
| 59 |
|
| 60 |
# |
| 61 |
# continue |
| 62 |
# |
| 63 |
|
| 64 |
setenv_var MODULES_ABORT_ON_ERROR load:ml:reload:switch_unload |
| 65 |
|
| 66 |
|
| 67 |
# restore command (no impact of abort_on_error option) |
| 68 |
set ts_error_verbose [msg_load all/1.0]\n\n$ts_load_error\n\n[msg_load foo/1.0] |
| 69 |
testouterr_cmd bash {restore testsuite/home/coll-error-on-load} $ans_continue $ts_error_verbose |
| 70 |
|
| 71 |
|
| 72 |
# mod-to-sh command (abort_on_error has an impact) |
| 73 |
set ts_mod_to_sh_continue "all-pre-out |
| 74 |
TSPATH='dir1'; export TSPATH; |
| 75 |
TS='ok'; export TS; |
| 76 |
alias alall=value; |
| 77 |
funcall () { value; }; |
| 78 |
cd '/tmp'; |
| 79 |
all-out" |
| 80 |
testouterr_cmd bash {mod-to-sh sh all/1.0 err/1.0 foo/1.0} ERR $ts_mod_to_sh_continue |
| 81 |
|
| 82 |
|
| 83 |
# reload command (rollback, whatever the abort_on_error state) |
| 84 |
setenv_loaded_module [list all/1.0 err/1.0 foo/1.0] [list $mp/err/1.0 $mp/err/1.0 $mp/foo/1.0] |
| 85 |
testouterr_cmd bash {reload} ERR $ts_load_error |
| 86 |
|
| 87 |
|
| 88 |
# switch command (no impact of abort_on_error option) |
| 89 |
setenv_loaded_module [list foo/1.0] [list $mp/foo/1.0] |
| 90 |
set ts_error_switch $ts_load_error\n\n[msg_switch foo/1.0 err/1.0 [err_swon err/1.0]] |
| 91 |
testouterr_cmd bash {switch foo/1.0 err/1.0} $ans_switch $ts_error_switch |
| 92 |
|
| 93 |
unsetenv_loaded_module |
| 94 |
|
| 95 |
|
| 96 |
# |
| 97 |
# abort |
| 98 |
# |
| 99 |
|
| 100 |
setenv_var MODULES_ABORT_ON_ERROR load:ml:mod-to-sh:reload:switch_unload |
| 101 |
|
| 102 |
# restore command (no impact of abort_on_error option) |
| 103 |
testouterr_cmd bash {restore testsuite/home/coll-error-on-load} $ans_continue $ts_error_verbose |
| 104 |
|
| 105 |
|
| 106 |
# mod-to-sh command (abort_on_error has an impact) |
| 107 |
testouterr_cmd bash {mod-to-sh sh all/1.0 err/1.0 foo/1.0} ERR {} |
| 108 |
|
| 109 |
# --force leads to continue behavior |
| 110 |
testouterr_cmd bash {mod-to-sh --force sh all/1.0 err/1.0 foo/1.0} ERR $ts_mod_to_sh_continue |
| 111 |
|
| 112 |
|
| 113 |
# reload command (rollback, whatever the abort_on_error state) |
| 114 |
setenv_loaded_module [list all/1.0 err/1.0 foo/1.0] [list $mp/err/1.0 $mp/err/1.0 $mp/foo/1.0] |
| 115 |
testouterr_cmd bash {reload} ERR $ts_load_error |
| 116 |
|
| 117 |
|
| 118 |
# switch command (no impact of abort_on_error option) |
| 119 |
setenv_loaded_module [list foo/1.0] [list $mp/foo/1.0] |
| 120 |
set ts_error_switch $ts_load_error\n\n[msg_switch foo/1.0 err/1.0 [err_swon err/1.0]] |
| 121 |
testouterr_cmd bash {switch foo/1.0 err/1.0} $ans_switch $ts_error_switch |
| 122 |
|
| 123 |
unsetenv_loaded_module |
| 124 |
|
| 125 |
|
| 126 |
# |
| 127 |
# Cleanup |
| 128 |
# |
| 129 |
|
| 130 |
reset_test_env |