mirror of
https://github.com/triqs/dft_tools
synced 2024-12-21 11:53:41 +01:00
Add option to measure python test coverage
This commit is contained in:
parent
8f1011e389
commit
6ed84c078f
@ -52,6 +52,21 @@ add_subdirectory(shells)
|
||||
# tests
|
||||
#------------------------
|
||||
|
||||
option(TEST_COVERAGE "Analyze the coverage of tests" OFF)
|
||||
|
||||
# perform tests with coverage info
|
||||
if (${TEST_COVERAGE})
|
||||
# we try to locate the coverage program
|
||||
find_program(PYTHON_COVERAGE python-coverage)
|
||||
find_program(PYTHON_COVERAGE coverage)
|
||||
if(NOT PYTHON_COVERAGE)
|
||||
message(FATAL_ERROR "Program coverage (or python-coverage) not found.\nEither set PYTHON_COVERAGE explicitly or disable TEST_COVERAGE!\nYou need to install the python package coverage, e.g. with\n pip install coverage\nor with\n apt install python-coverage")
|
||||
endif()
|
||||
|
||||
message(STATUS "Setting up test coverage")
|
||||
add_custom_target(coverage ${PYTHON_COVERAGE} combine --append .coverage plovasp/.coverage || true COMMAND ${PYTHON_COVERAGE} html COMMAND echo "Open ${CMAKE_BINARY_DIR}/test/htmlcov/index.html in browser!" WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test)
|
||||
endif()
|
||||
|
||||
enable_testing()
|
||||
|
||||
option(Build_Tests "Build the tests of the library " ON)
|
||||
|
@ -124,3 +124,7 @@ Functionality of ``dft_tools`` can be tweaked using extra compile-time options p
|
||||
+---------------------------------------------------------------+-----------------------------------------------+
|
||||
| Build the documentation locally | -DBuild_Documentation=ON |
|
||||
+---------------------------------------------------------------+-----------------------------------------------+
|
||||
| Check test coverage when testing | -DTEST_COVERAGE=ON |
|
||||
| (run ``make coverage`` to show the results; requires the | |
|
||||
| python ``coverage`` package) | |
|
||||
+---------------------------------------------------------------+-----------------------------------------------+
|
||||
|
@ -7,8 +7,14 @@ FILE(COPY SrVO3.pmat SrVO3.struct SrVO3.outputs SrVO3.oubwin SrVO3.ctqmcout SrVO
|
||||
# List all tests
|
||||
set(all_tests wien2k_convert hk_convert w90_convert sumkdft_basic srvo3_Gloc srvo3_transp sigma_from_file blockstructure analyse_block_structure_from_gf analyse_block_structure_from_gf2)
|
||||
|
||||
set(python_executable python)
|
||||
|
||||
if(${TEST_COVERAGE})
|
||||
set(python_executable ${PYTHON_COVERAGE} run --append --source "${CMAKE_BINARY_DIR}/python" )
|
||||
endif()
|
||||
|
||||
foreach(t ${all_tests})
|
||||
add_test(NAME ${t} COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/${t}.py)
|
||||
add_test(NAME ${t} COMMAND ${python_executable} ${CMAKE_CURRENT_SOURCE_DIR}/${t}.py)
|
||||
endforeach()
|
||||
|
||||
# Set the PythonPath : put the build dir first (in case there is an installed version).
|
||||
@ -17,4 +23,3 @@ set_property(TEST ${all_tests} PROPERTY ENVIRONMENT PYTHONPATH=${CMAKE_BINARY_DI
|
||||
|
||||
# VASP converter tests
|
||||
add_subdirectory(plovasp)
|
||||
|
||||
|
@ -12,7 +12,7 @@ FILE(COPY ${all_tests} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
FILE(COPY run_suite.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
foreach(t ${all_tests})
|
||||
add_test(NAME ${t} COMMAND python run_suite.py ${t})
|
||||
add_test(NAME ${t} COMMAND ${python_executable} run_suite.py ${t})
|
||||
endforeach()
|
||||
|
||||
set_property(TEST ${all_tests} PROPERTY ENVIRONMENT PYTHONPATH=${CMAKE_BINARY_DIR}/python:$ENV{PYTHONPATH} )
|
||||
|
Loading…
Reference in New Issue
Block a user