| 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: 2018/10/14 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: nanobowers <[email protected]> |
| 11 |
# |
| 12 |
# Description: Testsuite testsequence |
| 13 |
# Command: unload |
| 14 |
# Modulefiles: function/1.0 |
| 15 |
# Sub-Command: |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Tests the reverse 'set-function' module subcommand |
| 19 |
# for all allowed shell types. |
| 20 |
# }C% |
| 21 |
# |
| 22 |
############################################################################## |
| 23 |
|
| 24 |
# |
| 25 |
# Variables. This test forces a module unload command. It will result in the |
| 26 |
# environment variables "_LMFILES_", "LOADEDMODULES" and "testsuite" to |
| 27 |
# be set up |
| 28 |
# |
| 29 |
|
| 30 |
set module "function/1.0" |
| 31 |
set modulefile "$modpath/$module" |
| 32 |
|
| 33 |
# |
| 34 |
# Set up the environment for reversal ... |
| 35 |
# |
| 36 |
|
| 37 |
setenv_loaded_module $module $modulefile |
| 38 |
setenv_var __MODULES_LMREFRESH $module |
| 39 |
|
| 40 |
# |
| 41 |
# Expected results for the different shells ... |
| 42 |
# |
| 43 |
set ans_fish [list] |
| 44 |
lappend ans_fish [list unset _LMFILES_] |
| 45 |
lappend ans_fish [list unset LOADEDMODULES] |
| 46 |
lappend ans_fish [list unset __MODULES_LMREFRESH] |
| 47 |
lappend ans_fish [list "functions -e testsuite2;"] |
| 48 |
lappend ans_fish [list "functions -e testsuite3;"] |
| 49 |
lappend ans_fish [list "functions -e testsuite4;"] |
| 50 |
lappend ans_fish [list "functions -e testsuite;"] |
| 51 |
lappend ans_fish [list "functions -e testsuite5;"] |
| 52 |
|
| 53 |
set ans_sh [list] |
| 54 |
lappend ans_sh [list unset _LMFILES_] |
| 55 |
lappend ans_sh [list unset LOADEDMODULES] |
| 56 |
lappend ans_sh [list unset __MODULES_LMREFRESH] |
| 57 |
lappend ans_sh [list "unset -f testsuite2 2>/dev/null || true;"] |
| 58 |
lappend ans_sh [list "unset -f testsuite3 2>/dev/null || true;"] |
| 59 |
lappend ans_sh [list "unset -f testsuite4 2>/dev/null || true;"] |
| 60 |
lappend ans_sh [list "unset -f testsuite 2>/dev/null || true;"] |
| 61 |
lappend ans_sh [list "unset -f testsuite5 2>/dev/null || true;"] |
| 62 |
|
| 63 |
set ans_pwsh [list] |
| 64 |
lappend ans_pwsh [list unset _LMFILES_] |
| 65 |
lappend ans_pwsh [list unset LOADEDMODULES] |
| 66 |
lappend ans_pwsh [list unset __MODULES_LMREFRESH] |
| 67 |
lappend ans_pwsh [list "Remove-Item -Path function:testsuite2 -ErrorAction SilentlyContinue"] |
| 68 |
lappend ans_pwsh [list "Remove-Item -Path function:testsuite3 -ErrorAction SilentlyContinue"] |
| 69 |
lappend ans_pwsh [list "Remove-Item -Path function:testsuite4 -ErrorAction SilentlyContinue"] |
| 70 |
lappend ans_pwsh [list "Remove-Item -Path function:testsuite -ErrorAction SilentlyContinue"] |
| 71 |
lappend ans_pwsh [list "Remove-Item -Path function:testsuite5 -ErrorAction SilentlyContinue"] |
| 72 |
|
| 73 |
set ans_empty [list] |
| 74 |
lappend ans_empty [list unset _LMFILES_] |
| 75 |
lappend ans_empty [list unset LOADEDMODULES] |
| 76 |
lappend ans_empty [list unset __MODULES_LMREFRESH] |
| 77 |
|
| 78 |
# |
| 79 |
# The tests |
| 80 |
# |
| 81 |
foreach sh $supported_shells { |
| 82 |
# Can only sh/bash actually unset functions? |
| 83 |
if { [lsearch {sh bash zsh ksh} $sh] >= 0 } { |
| 84 |
test_cmd "$sh" "unload $module" $ans_sh |
| 85 |
} elseif { $sh == "fish" } { |
| 86 |
test_cmd "$sh" "unload $module" $ans_fish |
| 87 |
} elseif { $sh == "pwsh" } { |
| 88 |
test_cmd "$sh" "unload $module" $ans_pwsh |
| 89 |
} else { |
| 90 |
test_cmd "$sh" "unload $module" $ans_empty |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
# |
| 95 |
# Cleanup |
| 96 |
# |
| 97 |
|
| 98 |
reset_test_env |