Skip to content

Commit 9da3863

Browse files
committed
replacing tabs with spaces and final polishing/cleanup
1 parent 5b93cd8 commit 9da3863

File tree

1 file changed

+46
-45
lines changed

1 file changed

+46
-45
lines changed

.github/workflows/scripts/test_init_scripts.sh

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,81 @@
22
export LMOD_PAGER=cat
33

44
if [ -z ${EESSI_VERSION} ] || [ ! -d /cvmfs/software.eessi.io/versions/${EESSI_VERSION} ]; then
5-
echo "\$EESSI_VERSION has to be set to a valid EESSI version."
6-
exit 1
5+
echo "\$EESSI_VERSION has to be set to a valid EESSI version."
6+
exit 1
77
fi
88

99
if [ -z ${EXPECTED_EASYBUILD_VERSION} ]; then
10-
echo "\$EXPECTED_EASYBUILD_VERSION has to be set to an EasyBuild version that is expected to be available in EESSI version ${EESSI_VERSION}."
11-
exit 1
10+
echo "\$EXPECTED_EASYBUILD_VERSION has to be set to an EasyBuild version that is expected to be available in EESSI version ${EESSI_VERSION}."
11+
exit 1
1212
fi
1313

1414
# initialize assert framework
1515
if [ ! -d assert.sh ]; then
16-
echo "assert.sh not cloned."
17-
echo ""
18-
echo "run \`git clone https://github.com/lehmannro/assert.sh.git\`"
19-
exit 1
16+
echo "assert.sh not cloned."
17+
echo ""
18+
echo "run \`git clone https://github.com/lehmannro/assert.sh.git\`"
19+
exit 1
2020
fi
2121
. assert.sh/assert.sh
2222

2323
TEST_SHELLS=("bash" "zsh" "fish" "ksh" "csh")
2424
SHELLS=$@
2525

2626
for shell in ${SHELLS[@]}; do
27-
echo = | awk 'NF += (OFS = $_) + 100'
28-
echo RUNNING TESTS FOR SHELL: $shell
29-
echo = | awk 'NF += (OFS = $_) + 100'
27+
echo = | awk 'NF += (OFS = $_) + 100'
28+
echo RUNNING TESTS FOR SHELL: $shell
29+
echo = | awk 'NF += (OFS = $_) + 100'
3030
if [[ ! " ${TEST_SHELLS[*]} " =~ [[:space:]]${shell}[[:space:]] ]]; then
31-
### EXCEPTION FOR CSH ###
32-
echo -e "\033[33mWe don't now how to test the shell '$shell', PRs are Welcome.\033[0m"
31+
### EXCEPTION FOR CSH ###
32+
echo -e "\033[33mWe don't now how to test the shell '$shell', PRs are Welcome.\033[0m"
3333
else
34-
# TEST 1: Source Script and check Module Output
34+
# TEST 1: Source Script and check Module Output
3535
expected="Module for EESSI/$EESSI_VERSION loaded successfully"
36-
assert "$shell -c 'source init/lmod/$shell' 2>&1 " "${expected}"
37-
# TEST 2: Check if module overviews first section is the loaded EESSI module
36+
assert "$shell -c 'source init/lmod/$shell' 2>&1 " "${expected}"
37+
38+
# TEST 2: Check if module overviews first section is the loaded EESSI module
3839
if [ "$shell" = "csh" ]; then
39-
# module is defined as alias, but aliases are only retained in interactive shells
40-
# we work around this by running 'csh -l', however with '-l' we cannot add '-c'
41-
# we work around this by creating a temporary .cshrc file (which sources
42-
# the init script), and then use a here-string to specify the command to
43-
# be run; the output is then processed as for other shells
44-
echo "source init/lmod/$shell >& /dev/null" > ~/.cshrc
45-
MODULE_SECTIONS=($($shell -l <<< "module ov" 2>&1 | grep -e '---'))
40+
# module is defined as alias, but aliases are only retained in interactive
41+
# shells we work around this by creating a .cshrc file (which sources the
42+
# init script), and then simply run the remaining commands
43+
echo "source init/lmod/$shell" > ~/.cshrc
44+
MODULE_SECTIONS=($($shell -c "module ov" 2>&1 | grep -e '---'))
4645
else
47-
MODULE_SECTIONS=($($shell -c "source init/lmod/$shell 2>/dev/null; module ov 2>&1 | grep -e '---'"))
46+
MODULE_SECTIONS=($($shell -c "source init/lmod/$shell 2>/dev/null; module ov 2>&1 | grep -e '---'"))
4847
fi
49-
PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/modules/all"
50-
assert_raises 'echo "${MODULE_SECTIONS[1]}" | grep -E "$PATTERN"'
51-
# TEST 3: Check if module overviews second section is the EESSI init module
52-
assert "echo ${MODULE_SECTIONS[4]}" "/cvmfs/software.eessi.io/versions/$EESSI_VERSION/init/modules"
53-
# TEST 4: Load EasyBuild module and check version
54-
# eb --version outputs: "This is EasyBuild 5.1.1 (framework: 5.1.1, easyblocks: 5.1.1) on host ..."
48+
PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/modules/all"
49+
assert_raises 'echo "${MODULE_SECTIONS[1]}" | grep -E "$PATTERN"'
50+
51+
# TEST 3: Check if module overviews second section is the EESSI init module
52+
assert "echo ${MODULE_SECTIONS[4]}" "/cvmfs/software.eessi.io/versions/$EESSI_VERSION/init/modules"
53+
54+
# TEST 4: Load EasyBuild module and check version
55+
# eb --version outputs: "This is EasyBuild 5.1.1 (framework: 5.1.1, easyblocks: 5.1.1) on host ..."
5556
if [ "$shell" = "csh" ]; then
5657
echo "source init/lmod/$shell" > ~/.cshrc
5758
command="$shell -c 'module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version' | cut -d \" \" -f4"
5859
else
59-
command="$shell -c 'source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version | cut -d \" \" -f4'"
60+
command="$shell -c 'source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version | cut -d \" \" -f4'"
6061
fi
61-
assert "$command" "$EXPECTED_EASYBUILD_VERSION"
62-
# TEST 5: Load EasyBuild module and check path
62+
assert "$command" "$EXPECTED_EASYBUILD_VERSION"
63+
64+
# TEST 5: Load EasyBuild module and check path
6365
if [ "$shell" = "csh" ]; then
64-
echo "source init/lmod/$shell >& /dev/null" > ~/.cshrc
65-
EASYBUILD_PATH=$($shell -l <<< "module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb")
66+
echo "source init/lmod/$shell" > ~/.cshrc
67+
EASYBUILD_PATH=$($shell -c "module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb")
6668
else
67-
EASYBUILD_PATH=$($shell -c "source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb")
69+
EASYBUILD_PATH=$($shell -c "source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb")
6870
fi
69-
# escape the dots in ${EASYBUILD_VERSION}
70-
PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/software/EasyBuild/${EXPECTED_EASYBUILD_VERSION//./\\.}/bin/eb"
71-
echo "$EASYBUILD_PATH" | grep -E "$PATTERN"
72-
assert_raises 'echo "$EASYBUILD_PATH" | grep -E "$PATTERN"'
73-
74-
#End Test Suite
75-
assert_end "source_eessi_$shell"
76-
fi
77-
done
71+
# escape the dots in ${EASYBUILD_VERSION}
72+
PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/software/EasyBuild/${EXPECTED_EASYBUILD_VERSION//./\\.}/bin/eb"
73+
echo "$EASYBUILD_PATH" | grep -E "$PATTERN"
74+
assert_raises 'echo "$EASYBUILD_PATH" | grep -E "$PATTERN"'
7875

76+
# End Test Suite
77+
assert_end "source_eessi_$shell"
78+
fi
79+
done
7980

8081
# RESET PAGER
8182
export LMOD_PAGER=

0 commit comments

Comments
 (0)