@@ -360,31 +360,68 @@ jobs:
360360 - name : Build project
361361 run : |
362362 cmake --build build --parallel
363- - name : Run tests (MPI)
364- run : python3 scripts/run_tests.py --running-type="processes"
363+ - name : Run tests (MPI) with coverage
364+ run : |
365+ mkdir -p mpi_coverage
366+ cat > mpi_coverage_wrapper.sh << 'EOF'
367+ #!/bin/bash
368+ # Get MPI rank from environment variables
369+ rank_id="${PMI_RANK:-${OMPI_COMM_WORLD_RANK:-${SLURM_PROCID:-$$}}}"
370+ export GCOV_PREFIX="$(pwd)/mpi_coverage/rank_${rank_id}"
371+ mkdir -p "$GCOV_PREFIX"
372+ exec "$@"
373+ EOF
374+ chmod +x mpi_coverage_wrapper.sh
375+
376+ # Run MPI tests with coverage wrapper
377+ mpirun -np 2 ./mpi_coverage_wrapper.sh python3 scripts/run_tests.py --running-type="processes" --counts 2
365378 env :
366379 PPC_NUM_PROC : 2
367380 PPC_NUM_THREADS : 2
381+ GCOV_PREFIX_STRIP : 0
368382 - name : Run tests (threads)
369383 run : python3 scripts/run_tests.py --running-type="threads" --counts 1 2 3 4
370384 env :
371385 PPC_NUM_PROC : 1
372- - name : Generate gcovr Coverage Data
386+ - name : Collect and merge coverage data from all MPI ranks
373387 run : |
374- mkdir cov-report
388+ mkdir -p cov-report
375389 cd build
376- gcovr -r ../ \
377- --exclude '.*3rdparty/.*' \
378- --exclude '/usr/.*' \
379- --exclude '.*tasks/.*/tests/.*' \
380- --exclude '.*modules/.*/tests/.*' \
381- --exclude '.*tasks/common/runners/.*' \
382- --exclude '.*modules/core/runners/.*' \
383- --exclude '.*modules/core/util/include/perf_test_util.hpp' \
384- --exclude '.*modules/core/util/include/func_test_util.hpp' \
385- --exclude '.*modules/core/util/src/func_test_util.cpp' \
386- --xml --output ../coverage.xml \
387- --html=../cov-report/index.html --html-details
390+
391+ # Find all .gcda files from all ranks
392+ echo "Finding coverage files..."
393+ find . -name "*.gcda" -type f | head -10
394+ find ../mpi_coverage -name "*.gcda" -type f 2>/dev/null | head -10 || true
395+
396+ # Create comprehensive gcovr command that includes all rank data
397+ gcovr_cmd="gcovr -r ../"
398+ gcovr_cmd="$gcovr_cmd --exclude '.*3rdparty/.*'"
399+ gcovr_cmd="$gcovr_cmd --exclude '/usr/.*'"
400+ gcovr_cmd="$gcovr_cmd --exclude '.*tasks/.*/tests/.*'"
401+ gcovr_cmd="$gcovr_cmd --exclude '.*modules/.*/tests/.*'"
402+ gcovr_cmd="$gcovr_cmd --exclude '.*tasks/common/runners/.*'"
403+ gcovr_cmd="$gcovr_cmd --exclude '.*modules/core/runners/.*'"
404+ gcovr_cmd="$gcovr_cmd --exclude '.*modules/core/util/include/perf_test_util.hpp'"
405+ gcovr_cmd="$gcovr_cmd --exclude '.*modules/core/util/include/func_test_util.hpp'"
406+ gcovr_cmd="$gcovr_cmd --exclude '.*modules/core/util/src/func_test_util.cpp'"
407+
408+ # Add object directories for all ranks
409+ for rank_dir in ../mpi_coverage/rank_*; do
410+ if [ -d "$rank_dir" ]; then
411+ echo "Adding coverage data from $rank_dir"
412+ gcovr_cmd="$gcovr_cmd --object-directory $rank_dir"
413+ fi
414+ done
415+
416+ # Also include main build directory
417+ gcovr_cmd="$gcovr_cmd --object-directory ."
418+
419+ # Generate output
420+ gcovr_cmd="$gcovr_cmd --xml --output ../coverage.xml"
421+ gcovr_cmd="$gcovr_cmd --html=../cov-report/index.html --html-details"
422+
423+ echo "Running: $gcovr_cmd"
424+ eval $gcovr_cmd
388425 - name : Upload coverage reports to Codecov
389426 uses : codecov/codecov-action@v5.4.3
390427 with :
0 commit comments