##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.50-cmds/%M%
#   Revision:		%I%
#   First Edition:	2005/11/21
#   Last Mod.:		%U%, %G%
#
#   Authors:		Jens Hamisch, Jens.Hamisch@Strawberry.COM
#			R.K.Owen, rk@owen.sj.ca.us
#
#   Description:	Testuite testsequence
#   Command:		refresh
#   Modulefiles:	alias/2.0,setenv/1.0
#   Sub-Command:
#
#   Comment:	%C{
#			Tests the 'refresh' module subcommand for all allowed
#			shell types.
#		}C%
#
##############################################################################

#
#  Variables.
#

set module1 "alias/2.0"
set modulefile1 "$env(MODULEPATH)/$module1"
set module2 "setenv/1.0"
set modulefile2 "$env(MODULEPATH)/$module2"
set alias "ps -auxww | grep modulecmd"

#
#  For the different shells ...
#

set tfnam_pat "/\[a-zA-Z_0-9_/\\.\\-\]+modulesource_\[a-zA-Z_0-9\\.\\-\]+"
set fil_cmd_sh "testsuite() { $alias\n}"
set fil_cmd_ksh "alias testsuite='$alias'"
set fil_cmd_csh "alias testsuite '$alias'"

set ts_sh "\\. ($tfnam_pat);/bin/rm -f $tfnam_pat;"

set ts_csh "source ($tfnam_pat);/bin/rm -f $tfnam_pat;"

set evl_cmd_ksh "$fil_cmd_ksh;"
set evl_cmd_csh "$fil_cmd_csh;"
#
#  The tests
#

if { [ version_test "HAS_BOURNE_ALIAS=1" ] } {
	test_alias "sh" "refresh" "$ts_sh" "$fil_cmd_ksh" "$evl_cmd_ksh"
} elseif { [ version_test "HAS_BOURNE_FUNCS=1" ] } {
	test_alias_sh_fn "refresh" "$ts_sh" "$fil_cmd_sh"
} else {
	send_user "skipping sh refresh test\n"
}
test_alias "ksh" "refresh" "$ts_sh" "$fil_cmd_ksh" "$evl_cmd_ksh"
test_alias "zsh" "refresh" "$ts_sh" "$fil_cmd_ksh" "$evl_cmd_ksh"
test_alias "csh" "refresh" "$ts_csh" "$fil_cmd_csh" "$evl_cmd_csh"
test_alias "tcsh" "refresh" "$ts_csh" "$fil_cmd_csh" "$evl_cmd_csh"
# only available for csh/sh derivatives ... no longer warn for others

#
#  Cleanup
#

unset evl_cmd_ksh
unset evl_cmd_csh

unset ts_sh
unset ts_csh

unset modulefile2
unset module2
unset modulefile1
unset module1

unset fil_cmd_sh
unset fil_cmd_csh
unset tfnam_pat

#
#  Clean up the environment, too
#

unset env(_LMFILES_)
unset env(LOADEDMODULES)
