@@ -731,17 +731,30 @@ setenv_var TESTSUITE_SHTOMOD_MODULE 1
731731setenv_var MODULES_SET_SHELL_STARTUP 0
732732setenv_var MODULES_CMD [file normalize $env(TESTSUITEDIR)/../modulecmd.tcl]
733733setenv_var TCLSH $TCLSH
734+
735+ # if module was defined in environment prior test, the result of the source-sh evaluation
736+ # will be the unset of the module functions
737+ if {$is_modules_defined} {
738+ set extratserr "\nunset-function\t_module_raw\nunset-function\tml\nunset-function\tmodule"
739+ } else {
740+ set extratserr {}
741+ }
742+
734743set tserr "#%Module\n$tscwd\n$tsvarpre\n$tsvar\n"
735744if {$install_versioning eq {y}} {
736745 append tserr "setenv\t\tMODULE_VERSION $install_version
737746setenv\t\tMODULE_VERSION_STACK $install_version\n"
738747}
739748append tserr "setenv\t\tMODULES_COLLECTION_TARGET bar
740749setenv\t\ttestsuite yes"
750+ set tserrbash "$tserr$extratserr"
741751foreach sh $shtomod_avail_shells {
752+ # unset module definition on bash when module is predefined
753+ if {$sh eq {bash} || ($sh eq {sh} && $sh_kind eq {bash})} {
754+ testouterr_shtomod $sh {} OK $tserrbash
742755 # skip this test for old fish version as a __fish_restore_status
743756 # function is defined in this case
744- if {$sh ne {fish} || $fish_version_ge31} {
757+ } elseif {$sh ne {fish} || $fish_version_ge31} {
745758 testouterr_shtomod $sh {} OK $tserr
746759 }
747760}
@@ -754,7 +767,7 @@ if {$install_versioning eq {y}} {
754767 append tserr "setenv\t\tMODULE_VERSION $install_version
755768setenv\t\tMODULE_VERSION_STACK $install_version\n"
756769}
757- append tserr "setenv\t\tMODULES_COLLECTION_TARGET bar"
770+ append tserr "setenv\t\tMODULES_COLLECTION_TARGET bar$extratserr "
758771testouterr_shtomod bash {} OK $tserr
759772
760773# module is loaded prior sh-to-mod
@@ -765,7 +778,7 @@ if {$install_versioning eq {y}} {
765778 append tserr "setenv\t\tMODULE_VERSION $install_version
766779setenv\t\tMODULE_VERSION_STACK $install_version\n"
767780}
768- append tserr "setenv\t\tMODULES_COLLECTION_TARGET bar"
781+ append tserr "setenv\t\tMODULES_COLLECTION_TARGET bar$extratserr "
769782testouterr_shtomod bash {} OK $tserr
770783
771784
0 commit comments