Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions .github/workflows/scripts/test_init_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if [ ! -d assert.sh ]; then
fi
. assert.sh/assert.sh

TEST_SHELLS=("bash" "zsh" "fish" "ksh" "csh")
TEST_SHELLS=("bash" "zsh" "fish" "ksh" "csh" "sh")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@boegel All shells are covered via this script

SHELLS=$@

for shell in ${SHELLS[@]}; do
Expand All @@ -43,7 +43,11 @@ for shell in ${SHELLS[@]}; do

# TEST 1: Source Script and check Module Output
expected_pattern=".*EESSI has selected $EESSI_SOFTWARE_SUBDIR_OVERRIDE as the compatible CPU target for EESSI/$EESSI_VERSION.*"
assert_raises "$shell -c 'source init/lmod/$shell' 2>&1 | grep -E \"${expected_pattern}\""
if [ "$shell" = "csh" ]; then
assert_raises "$shell -c 'source init/lmod/$shell' 2>&1 | grep -E \"${expected_pattern}\""
else
assert_raises "$shell -c '. init/lmod/$shell' 2>&1 | grep -E \"${expected_pattern}\""
fi

# TEST 2: Check if module overviews first section is the loaded EESSI module
if [ "$shell" = "csh" ]; then
Expand All @@ -53,7 +57,7 @@ for shell in ${SHELLS[@]}; do
echo "source init/lmod/$shell" > ~/.cshrc
MODULE_SECTIONS=($($shell -c "module ov" 2>&1 | grep -e '---'))
else
MODULE_SECTIONS=($($shell -c "source init/lmod/$shell >/dev/null 2>&1; module ov 2>&1 | grep -e '---'"))
MODULE_SECTIONS=($($shell -c ". init/lmod/$shell >/dev/null 2>&1; module ov 2>&1 | grep -e '---'"))
fi
PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/$EESSI_SOFTWARE_SUBDIR_OVERRIDE/modules/all"
assert_raises 'echo "${MODULE_SECTIONS[1]}" | grep -E "$PATTERN"'
Expand All @@ -68,7 +72,7 @@ for shell in ${SHELLS[@]}; do
echo "source init/lmod/$shell" > ~/.cshrc
command="$shell -c 'module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version' | tail -n 1 | awk '{print \$4}'"
else
command="$shell -c 'source init/lmod/$shell >/dev/null 2>&1; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version' | tail -n 1 | awk '{print \$4}'"
command="$shell -c '. init/lmod/$shell >/dev/null 2>&1; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version' | tail -n 1 | awk '{print \$4}'"
fi
assert "$command" "$EXPECTED_EASYBUILD_VERSION"

Expand All @@ -77,7 +81,7 @@ for shell in ${SHELLS[@]}; do
echo "source init/lmod/$shell" > ~/.cshrc
EASYBUILD_PATH=$($shell -c "module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb")
else
EASYBUILD_PATH=$($shell -c "source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb")
EASYBUILD_PATH=$($shell -c ". init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb")
fi
# escape the dots in ${EASYBUILD_VERSION}
PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/$EESSI_SOFTWARE_SUBDIR_OVERRIDE/software/EasyBuild/${EXPECTED_EASYBUILD_VERSION//./\\.}/bin/eb"
Expand All @@ -97,8 +101,8 @@ for shell in ${SHELLS[@]}; do
TEST_LMOD_SYSTEM_DEFAULT_MODULES=$($shell -c 'set -x EESSI_DEFAULT_MODULES_APPEND append_module ; set -x EESSI_DEFAULT_MODULES_PREPEND prepend_module ; set -x EESSI_EXTRA_MODULEPATH .github/workflows/modules ; source init/lmod/'"$shell"' 2>/dev/null; echo $LMOD_SYSTEM_DEFAULT_MODULES')
TEST_MODULEPATH=$($shell -c 'set -x EESSI_DEFAULT_MODULES_APPEND append_module ; set -x EESSI_DEFAULT_MODULES_PREPEND prepend_module ; set -x EESSI_EXTRA_MODULEPATH .github/workflows/modules ; source init/lmod/'"$shell"' 2>/dev/null; echo $MODULEPATH')
else
TEST_LMOD_SYSTEM_DEFAULT_MODULES=$($shell -c 'export EESSI_DEFAULT_MODULES_APPEND=append_module ; export EESSI_DEFAULT_MODULES_PREPEND=prepend_module ; export EESSI_EXTRA_MODULEPATH=.github/workflows/modules ; source init/lmod/'"$shell"' ; echo $LMOD_SYSTEM_DEFAULT_MODULES')
TEST_MODULEPATH=$($shell -c 'export EESSI_DEFAULT_MODULES_APPEND=append_module ; export EESSI_DEFAULT_MODULES_PREPEND=prepend_module ; export EESSI_EXTRA_MODULEPATH=.github/workflows/modules ; source init/lmod/'"$shell"' 2>/dev/null; echo $MODULEPATH')
TEST_LMOD_SYSTEM_DEFAULT_MODULES=$($shell -c 'export EESSI_DEFAULT_MODULES_APPEND=append_module ; export EESSI_DEFAULT_MODULES_PREPEND=prepend_module ; export EESSI_EXTRA_MODULEPATH=.github/workflows/modules ; . init/lmod/'"$shell"' ; echo $LMOD_SYSTEM_DEFAULT_MODULES')
TEST_MODULEPATH=$($shell -c 'export EESSI_DEFAULT_MODULES_APPEND=append_module ; export EESSI_DEFAULT_MODULES_PREPEND=prepend_module ; export EESSI_EXTRA_MODULEPATH=.github/workflows/modules ; . init/lmod/'"$shell"' 2>/dev/null; echo $MODULEPATH')
fi
LMOD_SYSTEM_DEFAULT_MODULES_PATTERN='^prepend_module:.*:append_module$'
# echo "$TEST_LMOD_SYSTEM_DEFAULT_MODULES" AND "$LMOD_SYSTEM_DEFAULT_MODULES_PATTERN"
Expand Down Expand Up @@ -126,8 +130,8 @@ for shell in ${SHELLS[@]}; do
TEST_EESSI_WITH_PURGE=$($shell -c "source $LMOD_PKG/init/$shell 2>/dev/null ; source init/lmod/$shell 2>/dev/null")
TEST_EESSI_WITHOUT_PURGE=$($shell -c "set -x EESSI_NO_MODULE_PURGE_ON_INIT 1 ; source $LMOD_PKG/init/$shell 2>/dev/null ; source init/lmod/$shell 2>/dev/null")
else
TEST_EESSI_WITH_PURGE=$($shell -c "source $LMOD_PKG/init/$shell 2>/dev/null ; source init/lmod/$shell 2>/dev/null")
TEST_EESSI_WITHOUT_PURGE=$($shell -c "export EESSI_NO_MODULE_PURGE_ON_INIT=1 ; source $LMOD_PKG/init/$shell 2>/dev/null ; source init/lmod/$shell 2>/dev/null")
TEST_EESSI_WITH_PURGE=$($shell -c ". $LMOD_PKG/init/$shell 2>/dev/null ; . init/lmod/$shell 2>/dev/null")
TEST_EESSI_WITHOUT_PURGE=$($shell -c "export EESSI_NO_MODULE_PURGE_ON_INIT=1 ; . $LMOD_PKG/init/$shell 2>/dev/null ; . init/lmod/$shell 2>/dev/null")
fi
# In the first case we should have the test and in the second case we shouldn't
pattern="Modules purged before initialising EESSI"
Expand All @@ -139,10 +143,10 @@ for shell in ${SHELLS[@]}; do
fi

# Optional test 10, check if the prompt has been updated
if [ "$shell" = "bash" ] || [ "$shell" = "ksh" ] || [ "$shell" = "zsh" ]; then
if [ "$shell" = "bash" ] || [ "$shell" = "ksh" ] || [ "$shell" = "zsh" ] || [ "$shell" = "sh" ]; then
# Typically this is a non-interactive shell, so manually unset PS1 and reset to a non-exported variable when testing
TEST_EESSI_PS1_UPDATE=$($shell -c "unset PS1 ; PS1='$ ' ; source init/lmod/$shell 2>/dev/null ; echo \"\$PS1\"")
TEST_EESSI_NO_PS1_UPDATE=$($shell -c "unset PS1 ; source init/lmod/$shell 2>/dev/null ; echo \"\$PS1\"")
TEST_EESSI_PS1_UPDATE=$($shell -c "unset PS1 ; PS1='$ ' ; . init/lmod/$shell 2>/dev/null ; echo \"\$PS1\"")
TEST_EESSI_NO_PS1_UPDATE=$($shell -c "unset PS1 ; . init/lmod/$shell 2>/dev/null ; echo \"\$PS1\"")
pattern="{EESSI/${EESSI_VERSION}} "
assert_raises 'echo "$TEST_EESSI_PS1_UPDATE" | grep "$pattern"'
assert_raises 'echo "$TEST_EESSI_NO_PS1_UPDATE" | grep "$pattern"' 1
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/tests_init_module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
- name: Install missing shells
run: |
sudo apt update
# We're in Ubuntu so dash is already installed (and is symlinked to sh)
sudo apt install zsh ksh fish tcsh
echo "# INIT ZSH" > ~/.zshrc

Expand All @@ -65,7 +66,7 @@ jobs:
export EESSI_SOFTWARE_SUBDIR_OVERRIDE=${{matrix.EESSI_SOFTWARE_SUBDIR_OVERRIDE}}
export EESSI_VERSION=${{matrix.EESSI_VERSION}}
export EXPECTED_EASYBUILD_VERSION=${{matrix.EXPECTED_EASYBUILD_VERSION}}
.github/workflows/scripts/test_init_scripts.sh "bash" "zsh" "ksh" "fish" "csh"
.github/workflows/scripts/test_init_scripts.sh "bash" "zsh" "ksh" "fish" "csh" "sh"
- name: Run tests for available shells with system Lmod
run: |
# We also want to perform the same test when there is an Lmod version available on the system
Expand All @@ -76,4 +77,4 @@ jobs:
export EESSI_SOFTWARE_SUBDIR_OVERRIDE=${{matrix.EESSI_SOFTWARE_SUBDIR_OVERRIDE}}
export EESSI_VERSION=${{matrix.EESSI_VERSION}}
export EXPECTED_EASYBUILD_VERSION=${{matrix.EXPECTED_EASYBUILD_VERSION}}
.github/workflows/scripts/test_init_scripts.sh "bash" "zsh" "ksh" "fish" "csh"
.github/workflows/scripts/test_init_scripts.sh "bash" "zsh" "ksh" "fish" "csh" "sh"
117 changes: 0 additions & 117 deletions init/lmod/bash

This file was deleted.

1 change: 1 addition & 0 deletions init/lmod/bash
12 changes: 10 additions & 2 deletions init/lmod/csh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ if ( ! $?__EESSI_VERSION_USED_FOR_INIT ) then
else
set EESSI_VERSION_DEFAULT = "$__EESSI_VERSION_USED_FOR_INIT"
endif
if ( ! $?EESSI_VERSION ) then
set EESSI_VERSION = "$EESSI_VERSION_DEFAULT"
if ( ! $?__Init_EESSI_Default_Modules ) then
if ( $?EESSI_VERSION ) then
# keep existing value
else
set EESSI_VERSION "$EESSI_VERSION_DEFAULT"
endif
else
# If we have already initialised and this is being called again,
# then we must want the specific version
set EESSI_VERSION "__EESSI_VERSION_DEFAULT__"
endif
# On first run, record the EESSI version used for init as an environment variable.
# We use setenv to ensure it is available to child processes (equivalent to export).
Expand Down
12 changes: 10 additions & 2 deletions init/lmod/fish
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ if not set -q __EESSI_VERSION_USED_FOR_INIT
else
set EESSI_VERSION_DEFAULT "$__EESSI_VERSION_USED_FOR_INIT"
end
if not set -q EESSI_VERSION
set EESSI_VERSION "$EESSI_VERSION_DEFAULT"
if not set -q __Init_EESSI_Default_Modules
if set -q EESSI_VERSION
# keep existing value
else
set EESSI_VERSION $EESSI_VERSION_DEFAULT
end
else
# If we have already initialised and this is being called again,
# then we must want the specific version
set EESSI_VERSION "__EESSI_VERSION_DEFAULT__"
end

# Record version used for init; -x exports it to the environment
Expand Down
Loading
Loading