Skip to content
Merged
Show file tree
Hide file tree
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
64 changes: 58 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,76 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install Requirements for Coverage Testing
with:
submodules: recursive

- name: Install Perl Dependencies and Coverage Tools
run: |
apt update && apt install -y lcov gpg curl jq ca-certificates
- name: Building
apt update && apt install -y curl jq ca-certificates python3-pip
apt install -y lcov perl-modules
apt install -y libcapture-tiny-perl libdatetime-perl libjson-perl libperlio-gzip-perl
lcov --version

- name: Building with Coverage
run: |
cmake -B build -DENABLE_COVERAGE=ON -DBUILD_TESTING=ON -DENABLE_MLALGO=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_GOOGLEBENCH=ON -DENABLE_RAPIDJSON=ON
rm -rf build/
rm -f CMakeCache.txt

mkdir -p build
chmod -R 755 build/

cmake -B build \
-DENABLE_COVERAGE=ON \
-DBUILD_TESTING=ON \
-DENABLE_MLALGO=ON \
-DENABLE_LIBXC=ON \
-DENABLE_LIBRI=ON \
-DENABLE_GOOGLEBENCH=ON \
-DENABLE_RAPIDJSON=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="--coverage -fprofile-arcs -ftest-coverage" \
-DCMAKE_EXE_LINKER_FLAGS="--coverage"
cmake --build build -j`nproc`
cmake --install build

- name: Testing
env:
OMP_NUM_THREADS: 1
run: |
cmake --build build --target test ARGS="-V --timeout 21600" || exit 0
chmod -R 755 build/
cmake --build build --target test ARGS="-V --timeout 21600" || echo "Some tests failed but continuing for coverage"

- name: Generate Coverage Data
run: |
cd build

lcov --directory . --capture --output-file coverage.info

lcov --remove coverage.info '/usr/*' '*/test/*' '*/external/*' '*/build/*' --output-file coverage.filtered.info

genhtml coverage.filtered.info --output-directory coverage-report

cd ..

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v5
if: ${{ ! cancelled() }}
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
skip_validation: true
files: ./build/coverage.xml,./build/coverage.info
directory: ./build/
flags: unittests
name: codecov-umbrella
verbose: true

- name: Upload Coverage Report Artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: |
build/coverage-report/
build/coverage.info
build/coverage.xml
retention-days: 30
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,14 @@ if(ENABLE_COVERAGE)
include(FetchContent)
FetchContent_Declare(
cmakecodecov
URL https://github.com/baixiaokuang/CMake-codecov/archive/refs/heads/master.zip
GIT_REPOSITORY https://github.com/RWTH-HPC/CMake-codecov.git
GIT_TAG master
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_Populate(cmakecodecov)
list(APPEND CMAKE_MODULE_PATH ${cmakecodecov_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH "${cmakecodecov_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
find_package(codecov REQUIRED)
endif()
endif()
Expand Down
2 changes: 1 addition & 1 deletion source/source_cell/test_pw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AddTest(
../read_stru.cpp ../read_atom_species.cpp
../read_pp_vwr.cpp ../read_pp_blps.cpp ../../source_io/output.cpp
../../source_estate/read_pseudo.cpp ../../source_estate/cal_nelec_nband.cpp
../../source_estate/read_orb.cpp ../../source_cell/print_cell.cpp
../../source_estate/read_orb.cpp ../print_cell.cpp
../../source_estate/cal_wfc.cpp ../sep.cpp ../sep_cell.cpp
)

Expand Down
22 changes: 11 additions & 11 deletions source/source_lcao/module_deepks/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ add_executable(
../../../source_estate/cal_nelec_nband.cpp
../../../source_estate/module_dm/density_matrix.cpp
../../../source_estate/module_dm/density_matrix_io.cpp
../../../source_lcao/module_hcontainer/base_matrix.cpp
../../../source_lcao/module_hcontainer/hcontainer.cpp
../../../source_lcao/module_hcontainer/atom_pair.cpp
../../../source_lcao/module_hcontainer/func_transfer.cpp
../../../source_lcao/module_hcontainer/func_folding.cpp
../../../source_lcao/module_hcontainer/transfer.cpp
../../../source_lcao/module_hcontainer/output_hcontainer.cpp
../../../source_lcao/module_operator_lcao/deepks_lcao.cpp
../../../source_lcao/module_operator_lcao/operator_lcao.cpp
../../module_hcontainer/base_matrix.cpp
../../module_hcontainer/hcontainer.cpp
../../module_hcontainer/atom_pair.cpp
../../module_hcontainer/func_transfer.cpp
../../module_hcontainer/func_folding.cpp
../../module_hcontainer/transfer.cpp
../../module_hcontainer/output_hcontainer.cpp
../../module_operator_lcao/deepks_lcao.cpp
../../module_operator_lcao/operator_lcao.cpp
../../../source_hamilt/operator.cpp
../../../source_lcao/module_rt/td_info.cpp
../../../source_lcao/module_rt/td_folding.cpp
../../module_rt/td_info.cpp
../../module_rt/td_folding.cpp
../../../source_estate/module_pot/H_TDDFT_pw.cpp
)

Expand Down
8 changes: 4 additions & 4 deletions source/source_lcao/module_operator_lcao/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ AddTest(
../../../source_basis/module_ao/parallel_orbitals.cpp
../../../source_basis/module_ao/ORB_atomic_lm.cpp
tmp_mocks.cpp ../../../source_hamilt/operator.cpp
../../../source_lcao/module_rt/td_info.cpp
../../../source_lcao/module_rt/td_folding.cpp
../../module_rt/td_info.cpp
../../module_rt/td_folding.cpp
../../../source_estate/module_pot/H_TDDFT_pw.cpp
)

Expand All @@ -22,8 +22,8 @@ AddTest(
../../../source_basis/module_ao/parallel_orbitals.cpp
../../../source_basis/module_ao/ORB_atomic_lm.cpp
tmp_mocks.cpp ../../../source_hamilt/operator.cpp
../../../source_lcao/module_rt/td_info.cpp
../../../source_lcao/module_rt/td_folding.cpp
../../module_rt/td_info.cpp
../../module_rt/td_folding.cpp
../../../source_estate/module_pot/H_TDDFT_pw.cpp
)

Expand Down
17 changes: 10 additions & 7 deletions tests/integrate/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
find_program(BASH bash)
find_package(Python3 REQUIRED)

add_executable(sum_cube ${ABACUS_TEST_DIR}/integrate/tools/sum_cube.cpp)
install(TARGETS sum_cube DESTINATION ${ABACUS_TEST_DIR}/integrate/tools/)
message(STATUS "Target sum_cube has been defined in ${CMAKE_CURRENT_SOURCE_DIR}") # 添加此行

if(ENABLE_COVERAGE)
add_coverage(sum_cube)
endif()

if(ENABLE_ASAN)
add_test(
NAME integrated_test_with_asan
Expand All @@ -13,10 +22,4 @@ else()
COMMAND ${BASH} Autotest.sh -a ${ABACUS_BIN_PATH} -n 4
WORKING_DIRECTORY ${ABACUS_TEST_DIR}/integrate
)
add_executable(sum_cube.exe ${ABACUS_TEST_DIR}/integrate/tools/sum_cube.cpp)
install(TARGETS sum_cube.exe DESTINATION ${ABACUS_TEST_DIR}/integrate/tools/)

if(ENABLE_COVERAGE)
add_coverage(sum_cube.exe)
endif()
endif()
endif()
2 changes: 1 addition & 1 deletion tests/integrate/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ for directory in `ls | grep $module`; do
#--------------------------------------------
# delete exec files in tools directory (if it exists)
#--------------------------------------------
sumfile1="$directory/sum_cube.exe"
sumfile1="$directory/sum_cube"
test -e "$sumfile1" && rm -rf $sumfile1

#--------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tests/integrate/tools/catch_properties.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# mohan add 2025-05-03
# this compare script is used in different integrate tests
COMPARE_SCRIPT="../../integrate/tools/CompareFile.py"
SUM_CUBE_EXE="../../integrate/tools/sum_cube.exe"
SUM_CUBE_EXE="../../integrate/tools/sum_cube"


sum_file(){
Expand Down
Loading