############################################################################## # 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 # # 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