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