Skip to content

ENH: Add Functionality of running only one test file if specified #70

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 31, 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
32 changes: 27 additions & 5 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,39 @@ else
CC=clang
fi

# compile C and Fortran sources
$CC -I$CONDA_PREFIX/include -c ../src/mpi_wrapper.c
# If user specified a particular test (e.g. ./run_tests.sh bcast.f90),
# then only build & run that file. Otherwise, build & run all *.f90 files.

if [ $# -gt 0 ]; then
TEST_FILES=("$@")
echo -e "${YELLOW}Received argument(s). Will only compile/run: ${TEST_FILES[*]}${NC}"
else
# No arguments, so gather all .f90 test files in the current directory
TEST_FILES=( *.f90 )
echo -e "${YELLOW}No specific test file given. Will compile/run all .f90 tests...${NC}"
fi

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

start_time=$(date +%s)
for file in *.f90; do

# Now compile & run each requested test
for file in "${TEST_FILES[@]}"; do
if [[ ! -f "$file" ]]; then
echo -e "${RED}Test file '$file' not found! Skipping...${NC}"
continue
fi

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
$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"

# Test with 1, 2, and 4 ranks
for np in 1 2 4; do
# set MPIEXEC_ARGS based on MPI type and number of ranks
# `--oversubscribe` isn't needed with Open MPI when running
Expand All @@ -63,6 +84,7 @@ done

end_time=$(date +%s)
elapsed_time=$((end_time - start_time))

echo ""
echo -e "${YELLOW}... Running standalone tests took ${elapsed_time} seconds ...${NC}"
echo ""