Skip to content

Commit 144a036

Browse files
committed
ts: fix 70/310 tests when module is defined in env
1 parent 26ef861 commit 144a036

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

testsuite/modules.70-maint/310-sh-to-mod.exp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -731,17 +731,30 @@ setenv_var TESTSUITE_SHTOMOD_MODULE 1
731731
setenv_var MODULES_SET_SHELL_STARTUP 0
732732
setenv_var MODULES_CMD [file normalize $env(TESTSUITEDIR)/../modulecmd.tcl]
733733
setenv_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+
734743
set tserr "#%Module\n$tscwd\n$tsvarpre\n$tsvar\n"
735744
if {$install_versioning eq {y}} {
736745
append tserr "setenv\t\tMODULE_VERSION $install_version
737746
setenv\t\tMODULE_VERSION_STACK $install_version\n"
738747
}
739748
append tserr "setenv\t\tMODULES_COLLECTION_TARGET bar
740749
setenv\t\ttestsuite yes"
750+
set tserrbash "$tserr$extratserr"
741751
foreach 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
755768
setenv\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"
758771
testouterr_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
766779
setenv\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"
769782
testouterr_shtomod bash {} OK $tserr
770783

771784

0 commit comments

Comments
 (0)