Skip to content

test: improve run_tests.sh script to be less verbose #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2025
Merged
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
26 changes: 19 additions & 7 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
set -ex
#!/bin/bash
set -e

# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

MPIEXEC=${CONDA_PREFIX}/bin/mpiexec

Expand All @@ -8,20 +15,25 @@ else
CC=clang
fi

# Compile C and Fortran sources
$CC -I$CONDA_PREFIX/include -c ../src/mpi_wrapper.c
$FC -c ../src/mpi_c_bindings.f90
$FC -c ../src/mpi.f90

for file in *.f90; do
filename=$(basename "$file" .f90)
echo -e "${YELLOW}Compiling $filename...${NC}"
$FC -c $file
$FC mpi_wrapper.o mpi_c_bindings.o mpi.o $filename.o -o $filename -L$CONDA_PREFIX/lib -lmpi -Wl,-rpath,$CONDA_PREFIX/lib

echo "Running $filename with 1 MPI rank..."
${MPIEXEC} -np 1 $filename
echo "Done!"
for np in 1 2; do
echo -e "${YELLOW}Running $filename with $np MPI ranks...${NC}"
if ${MPIEXEC} -np $np ./$filename; then
echo -e "${GREEN}Test $filename with $np MPI ranks PASSED!${NC}"
else
echo -e "${RED}Test $filename with $np MPI ranks FAILED!${NC}"
exit 1
fi
done

echo "Running $filename with 2 MPI rank..."
${MPIEXEC} -np 2 $filename
echo "Done!"
done