############################################################################## # Modules Revision 3.0 # Providing a flexible user environment # # File: modules.50-cmds/%M% # Revision: %I% # First Edition: 2017/01/27 # Last Mod.: %U%, %G% # # Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr # # Description: Testuite testsequence # Command: load, display, whatis, search, source, restore # Command: unload, switch, purge, reload, help, test, reset # Command: stash # Modulefiles: info/commandexp # Sub-Command: # # Comment: %C{ # Tests the 'module-info command' module subcommand with # own suggestion. # This command does not change behaviour depending on # the user shell. Tests are made for the bourne shell # here. # }C% # ############################################################################## skip_if_quick_mode # # Variables. This test forces a module load command. It will result in the # environment variables "_LMFILES_", "LOADEDMODULES" and "testsuite" to # be set up # set module "info/commandexp" set modulefile "$modpath/$module" set modulefilere "$modpathre/$module" set header_help "Module Specific Help for $modulefilere:" set header_test "Module Specific Test for $modulefilere:" set header "$modlin $modpathre $modlin" # # The tests # lappend ans [list set _LMFILES_ $modulefile] lappend ans [list set LOADEDMODULES $module] lappend ansun [list unset _LMFILES_] lappend ansun [list unset LOADEDMODULES] # test loading testouterr_cmd "sh" "load $module" $ans "load" # test try-loading testouterr_cmd sh "try-load $module" $ans try-load # test load-any testouterr_cmd sh "load-any $module" $ans load-any # test mod-to-sh # specific test as this subcmd output shell code on report message channel set tserr [shell_set sh INFOCMD mod-to-sh] testouterr_cmd sh "mod-to-sh sh $module" [list [list OK nop]] $tserr # test reset setenv_var __MODULES_LMINIT "module use --append $modpath:module load $module" testouterr_cmd sh reset $ans reset\n[msg_load $module] unsetenv_var __MODULES_LMINIT # test stash setenv_var __MODULES_LMINIT "module use --append $modpath:module load $module" testouterr_cmd sh stash $ans stash\n[msg_load $module] unsetenv_var __MODULES_LMINIT # test stashpop setenv_loaded_module [list $module] [list $modulefile] testouterr_cmd sh stashpop $ansun stashpop\n[msg_unload $module] unsetenv_loaded_module file delete $env(HOME)/.module # test displaying testouterr_cmd_re "sh" "display $module" "OK" "$modlin\n$modulefilere:\n\ndisplay\n$modlin" # test whatis testouterr_cmd_re "sh" "whatis $module" "OK" "$header\n\\s+$module: whatis" # test searching # error found in interpreted module, so an error code is rendered testouterr_cmd_re "sh" "search search" "ERR" "$header\n(\\s+\\S+: search\\n)*\\s+$module: search" # test sourcing testouterr_cmd "sh" "source $modulefile" "OK" "source" # set HOME to location containing collections set homewithcoll "$env(HOME)/home" if {$verbose} { send_user "\tSetup HOME = $homewithcoll\n" } set env(HOME) "$homewithcoll" # test restoring testouterr_cmd "sh" "restore infocmdexp" $ans restore\n[msg_load $module] # restore default testsuite home if {$verbose} { send_user "\tRestore HOME = $ORIG_HOME\n" } set env(HOME) $ORIG_HOME # Set up the environment for test that require the module to be loaded setenv_loaded_module $module $modulefile # test unloading testouterr_cmd "sh" "unload $module" $ansun "unload" # test switching testouterr_cmd "sh" "switch $module $module" $ans "switch\nswitch" # test refreshing setenv_var __MODULES_LMREFRESH $module testouterr_cmd sh refresh OK refresh unsetenv_var __MODULES_LMREFRESH # test purging testouterr_cmd "sh" "purge" $ansun "purge" # test reloading testouterr_cmd "sh" "reload" $ans "reload\nreload" testouterr_cmd "sh" "update" $ans "reload\nreload" # Clean up the just changed environment unsetenv_loaded_module # test help testouterr_cmd_re "sh" "help $module" "OK" "$modlin\n$header_help\n\nhelp\nhelp\n$modlin" # test test testouterr_cmd_re "sh" "test $module" "OK" "$modlin\n$header_test\n\ntest\ntest\nTest result: PASS\n$modlin" setenv_var MODULEPATH $modpath.4 # test spider setenv_var TESTSUITE_INFO_COMMANDEXP spider set tserr "spider\n$modpath.4:\ninfo/commandexp" testouterr_cmd sh "spider -t $module" OK $tserr # # Cleanup # reset_test_env