|
| 1 | +#!/bin/bash |
| 2 | +EESSI_VERSION="2023.06" |
| 3 | +export LMOD_PAGER=cat |
| 4 | + |
| 5 | +# initialize assert framework |
| 6 | +if [ ! -d assert.sh ]; then |
| 7 | + echo "assert.sh not cloned." |
| 8 | + echo "" |
| 9 | + echo "run \`git clone https://github.com/lehmannro/assert.sh.git\`" |
| 10 | + exit 1 |
| 11 | +fi |
| 12 | +. assert.sh/assert.sh |
| 13 | + |
| 14 | +TEST_SHELLS=("bash" "zsh" "fish" "ksh") |
| 15 | +SHELLS=$@ |
| 16 | + |
| 17 | +for shell in ${SHELLS[@]}; do |
| 18 | + echo = | awk 'NF += (OFS = $_) + 100' |
| 19 | + echo RUNNING TESTS FOR SHELL: $shell |
| 20 | + echo = | awk 'NF += (OFS = $_) + 100' |
| 21 | + if [[ ! " ${TEST_SHELLS[*]} " =~ [[:space:]]${shell}[[:space:]] ]]; then |
| 22 | + ### EXCEPTION FOR CSH ### |
| 23 | + echo -e "\033[33mWe don't now how to test the shell '$shell', PRs are Welcome.\033[0m" |
| 24 | + else |
| 25 | + # TEST 1: Source Script and check Module Output |
| 26 | + assert "$shell -c 'source init/lmod/$shell' 2>&1 " "EESSI/$EESSI_VERSION loaded successfully" |
| 27 | + # TEST 2: Check if module overviews first section is the loaded EESSI module |
| 28 | + MODULE_SECTIONS=($($shell -c "source init/lmod/$shell 2>/dev/null; module ov 2>&1 | grep -e '---'")) |
| 29 | + PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/modules/all" |
| 30 | + assert_raises 'echo "${MODULE_SECTIONS[1]}" | grep -E "$PATTERN"' |
| 31 | + # TEST 3: Check if module overviews second section is the EESSI init module |
| 32 | + assert "echo ${MODULE_SECTIONS[4]}" "/cvmfs/software.eessi.io/versions/$EESSI_VERSION/init/modules" |
| 33 | + # Test 4: Load Python module and check version |
| 34 | + command="$shell -c 'source init/lmod/$shell 2>/dev/null; module load Python/3.10.8-GCCcore-12.2.0; python --version'" |
| 35 | + expected="Python 3.10.8" |
| 36 | + assert "$command" "$expected" |
| 37 | + # Test 5: Load Python module and check path |
| 38 | + PYTHON_PATH=$($shell -c "source init/lmod/$shell 2>/dev/null; module load Python/3.10.8-GCCcore-12.2.0; which python") |
| 39 | + PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/software/Python/3\.10\.8-GCCcore-12\.2\.0/bin/python" |
| 40 | + echo "$PYTHON_PATH" | grep -E "$PATTERN" |
| 41 | + assert_raises 'echo "$PYTHON_PATH" | grep -E "$PATTERN"' |
| 42 | + |
| 43 | + #End Test Suite |
| 44 | + assert_end "source_eessi_$shell" |
| 45 | + fi |
| 46 | +done |
| 47 | + |
| 48 | + |
| 49 | +# RESET PAGER |
| 50 | +export LMOD_PAGER= |
0 commit comments