@@ -49,7 +49,17 @@ for shell in ${SHELLS[@]}; do
4949 assert_raises " $shell -c '. init/lmod/$shell ' 2>&1 | grep -E \" ${expected_pattern} \" "
5050 fi
5151
52- # TEST 2: Check if module overviews first section is the loaded EESSI module
52+ # TEST 2: Source Script again in an subshell and check Module Output
53+ expected_pattern=" .*EESSI has selected $EESSI_SOFTWARE_SUBDIR_OVERRIDE as the compatible CPU target for EESSI/$EESSI_VERSION .*"
54+ if [ " $shell " = " csh" ]; then
55+ # Cannot figure out how to chain shells with silenced output to test this in csh but it does work
56+ # assert_raises "$shell -c 'setenv LMOD_QUIET 1 ; source init/lmod/$shell ; ($shell -c \"unsetenv LMOD_QUIET ; source init/lmod/$shell\")' 2>&1 | grep -E \"${expected_pattern}\""
57+ echo " Skipping chained shell check for csh as can't figure out how to silence output in first call"
58+ else
59+ assert_raises " $shell -c '. init/lmod/$shell > /dev/null 2>&1; $shell -c \" . init/lmod/$shell \" ' 2>&1 | grep -E \" ${expected_pattern} \" "
60+ fi
61+
62+ # TEST 3: Check if module overviews first section is the loaded EESSI module
5363 if [ " $shell " = " csh" ]; then
5464 # module is defined as alias, but aliases are only retained in interactive
5565 # shells we work around this by creating a .cshrc file (which sources the
@@ -63,10 +73,10 @@ for shell in ${SHELLS[@]}; do
6373 assert_raises ' echo "${MODULE_SECTIONS[1]}" | grep -E "$PATTERN"'
6474 # echo "${MODULE_SECTIONS[1]}" "$PATTERN"
6575
66- # TEST 3 : Check if module overviews second section is the EESSI init module
76+ # TEST 4 : Check if module overviews second section is the EESSI init module
6777 assert " echo ${MODULE_SECTIONS[4]} " " /cvmfs/software.eessi.io/init/modules"
6878
69- # TEST 4 : Load EasyBuild module and check version
79+ # TEST 5 : Load EasyBuild module and check version
7080 # eb --version outputs: "This is EasyBuild 5.1.1 (framework: 5.1.1, easyblocks: 5.1.1) on host ..."
7181 if [ " $shell " = " csh" ]; then
7282 echo " source init/lmod/$shell " > ~ /.cshrc
@@ -76,7 +86,7 @@ for shell in ${SHELLS[@]}; do
7686 fi
7787 assert " $command " " $EXPECTED_EASYBUILD_VERSION "
7888
79- # TEST 5 : Load EasyBuild module and check path
89+ # TEST 6 : Load EasyBuild module and check path
8090 if [ " $shell " = " csh" ]; then
8191 echo " source init/lmod/$shell " > ~ /.cshrc
8292 EASYBUILD_PATH=$( $shell -c " module load EasyBuild/${EXPECTED_EASYBUILD_VERSION} ; which eb" )
@@ -89,7 +99,7 @@ for shell in ${SHELLS[@]}; do
8999 assert_raises ' echo "$EASYBUILD_PATH" | grep -E "$PATTERN"'
90100 # echo "$EASYBUILD_PATH" "$PATTERN"
91101
92- # TEST 6 and 7 : Check the various options (EESSI_DEFAULT_MODULES_APPEND, EESSI_DEFAULT_MODULES_APPEND, EESSI_EXTRA_MODULEPATH) all work
102+ # TEST 7 and 8 : Check the various options (EESSI_DEFAULT_MODULES_APPEND, EESSI_DEFAULT_MODULES_APPEND, EESSI_EXTRA_MODULEPATH) all work
93103 if [ " $shell " = " csh" ]; then
94104 echo " setenv EESSI_DEFAULT_MODULES_APPEND append_module" > ~ /.cshrc
95105 echo " setenv EESSI_DEFAULT_MODULES_PREPEND prepend_module" >> ~ /.cshrc
@@ -115,7 +125,7 @@ for shell in ${SHELLS[@]}; do
115125 # echo "$TEST_MODULEPATH" AND "$MODULEPATH_PATTERN"
116126 assert_raises ' echo "$TEST_MODULEPATH" | grep -E "$MODULEPATH_PATTERN"'
117127
118- # TEST 8 and 9 : Add a conditional test depending on whether we have the Lmod command is available locally or not (Ubuntu-based location for CI)
128+ # TEST 9 and 10 : Add a conditional test depending on whether we have the Lmod command is available locally or not (Ubuntu-based location for CI)
119129 if [ -d " $LMOD_PKG /init" ]; then
120130 echo " Running check for locally available Lmod with purge"
121131 if [ " $shell " = " csh" ]; then
@@ -142,14 +152,32 @@ for shell in ${SHELLS[@]}; do
142152 assert_raises ' echo "$TEST_EESSI_WITHOUT_PURGE" | grep "$pattern"' 1
143153 fi
144154
145- # Optional test 10 , check if the prompt has been updated
155+ # Optional test 11 , check if the prompt has been updated
146156 if [ " $shell " = " bash" ] || [ " $shell " = " ksh" ] || [ " $shell " = " zsh" ] || [ " $shell " = " sh" ]; then
157+ # Let's configure things to use the EESSI module within the PR
158+ sed ' s|export MODULEPATH=.*|export MODULEPATH=init/modules|' init/lmod/sh > init/lmod/sh.test
159+ ln -srf init/lmod/sh.test init/lmod/bash.test
160+ ln -srf init/lmod/sh.test init/lmod/ksh.test
161+ ln -srf init/lmod/sh.test init/lmod/zsh.test
147162 # Typically this is a non-interactive shell, so manually unset PS1 and reset to a non-exported variable when testing
148- TEST_EESSI_PS1_UPDATE=$( $shell -c " unset PS1 ; PS1='$ ' ; . init/lmod/$shell 2>/dev/null ; echo \"\$ PS1\" " )
149- TEST_EESSI_NO_PS1_UPDATE=$( $shell -c " unset PS1 ; . init/lmod/$shell 2>/dev/null ; echo \"\$ PS1\" " )
163+ TEST_EESSI_PS1_UPDATE=$( $shell -c " unset PS1 ; PS1='$ ' ; . init/lmod/$shell .test 2>/dev/null ; echo \"\$ PS1\" " )
164+ TEST_EESSI_NO_PS1_UPDATE=$( $shell -c " unset PS1 ; . init/lmod/$shell .test 2>/dev/null ; echo \"\$ PS1\" " )
150165 pattern=" {EESSI/${EESSI_VERSION} } "
151166 assert_raises ' echo "$TEST_EESSI_PS1_UPDATE" | grep "$pattern"'
152167 assert_raises ' echo "$TEST_EESSI_NO_PS1_UPDATE" | grep "$pattern"' 1
168+ # Also check when we explicitly ask for it not to be updated
169+ TEST_EESSI_EXPLICIT_NO_PS1_UPDATE=$( $shell -c " unset PS1 ; PS1='test> ' ; export EESSI_MODULE_UPDATE_PS1=0 ; . init/lmod/$shell .test 2>/dev/null ; echo \"\$ PS1\" " )
170+ TEST_EESSI_EXPLICIT_NO_PS1_UPDATE_CALLED_TWICE=$( $shell -c " unset PS1 ; PS1='$ ' ; export EESSI_MODULE_UPDATE_PS1=0 ; . init/lmod/$shell .test 2>/dev/null ; . init/lmod/$shell .test 2>/dev/null ; echo \"\$ PS1\" " )
171+ assert_raises ' echo "$TEST_EESSI_EXPLICIT_NO_PS1_UPDATE" | grep "$pattern"' 1
172+ assert_raises ' echo "$TEST_EESSI_EXPLICIT_NO_PS1_UPDATE_CALLED_TWICE" | grep "$pattern"' 1
173+ # Also check complex prompts, and unloading/purging the EESSI module
174+ prompt=" \$ (echo '\['✘) $ "
175+ promptstr=" \[✘ $ "
176+ updated_promptstr=" {EESSI/${EESSI_VERSION} } \[✘ $ "
177+ TEST_EESSI_PS1_UPDATE=$( $shell -c " unset PS1 ; PS1=\" $prompt \" ; . init/lmod/$shell .test >/dev/null ; echo \"\$ PS1\" " )
178+ TEST_EESSI_PS1_REVERT=$( $shell -c " unset PS1 ; PS1=\" $prompt \" ; . init/lmod/$shell .test >/dev/null ; module purge; echo \"\$ PS1\" " )
179+ assert ' echo "$TEST_EESSI_PS1_UPDATE"' " $updated_promptstr "
180+ assert ' echo "$TEST_EESSI_PS1_REVERT"' " $promptstr "
153181 fi
154182
155183 # End Test Suite
0 commit comments