3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-01 03:33:50 +01:00
dft_tools/cmake/FindTriqsTest.cmake.in
2013-07-23 20:57:53 +02:00

106 lines
3.8 KiB
CMake

# runs python_with_DMFT script > output
# and compares output with script.output
# Example:
# triqs_add_triqs_test_script(ExampleTest)
# where ExampleTest.py is the script and ExampleTest.output is the expected output
#
macro(triqs_add_test_C_simple testname )
enable_testing()
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${testname}.output)
file( COPY ${CMAKE_CURRENT_SOURCE_DIR}/${testname}.output DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
add_test(${testname}
${CMAKE_COMMAND}
-Dname=${testname}${ARGN}
-Dcmd=${CMAKE_CURRENT_BINARY_DIR}/${testname}${ARGN}
-Dreference=${CMAKE_CURRENT_SOURCE_DIR}/${testname}.output
-P @CMAKE_INSTALL_PREFIX@/share/triqs/cmake/run_test.cmake
)
else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${testname}.output)
add_test(${testname}${ARGN} ${testname}${ARGN} )
endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${testname}.output)
endmacro(triqs_add_test_C_simple)
macro(triqs_add_test_C_hdf testname h5diff_options)
set(h5diff_objects ${ARGN}) # grab additionnal arguments !
enable_testing()
add_test(${testname}
${CMAKE_COMMAND}
-Dname=${testname}${ARGN}
-Dcmd=${CMAKE_CURRENT_BINARY_DIR}/${testname}${ARGN}
-DoutputName=${testname}.output.h5
-Dreference=${CMAKE_CURRENT_SOURCE_DIR}/${testname}.output.h5
-DH5_DIFF_EXECUTABLE=${TRIQS_HDF5_DIFF_EXECUTABLE}
-DH5_DIFF_OPTIONS=${h5diff_options}
-DH5_DIFF_OBJECTS=${h5diff_objects}
-P @CMAKE_INSTALL_PREFIX@/share/triqs/cmake/run_test.cmake
)
endmacro(triqs_add_test_C_hdf)
# WRITE THE run_pytriqs_for_test file
file (WRITE ${CMAKE_BINARY_DIR}/run_pytriqs_for_test.sh "#!/bin/bash\n export PYTHONPATH=${CMAKE_BINARY_DIR}/python:$PYTHONPATH\n ${TRIQS_PATH}/bin/pytriqs $@")
execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run_pytriqs_for_test.sh)
#SET(RUN_TEST @CMAKE_INSTALL_PREFIX@/bin/pytriqs)
SET(RUN_TEST ${CMAKE_BINARY_DIR}/run_pytriqs_for_test.sh )
#if (TRIQS_BUILD_STATIC)
# FILE(WRITE ${RUN_TEST} "PYTHONPATH=${CMAKE_BINARY_DIR}:$PYTHONPATH ${PYTHON_INTERPRETER} $1")
# #FILE(WRITE ${RUN_TEST} "PYTHONPATH=${CMAKE_BINARY_DIR}:$PYTHONPATH ${CMAKE_BINARY_DIR}/bin/pytriqs $1")
# execute_process( COMMAND chmod u+x ${RUN_TEST} )
#endif (TRIQS_BUILD_STATIC)
SET(ExecutableNameForTest ${RUN_TEST})
# runs pytriqs script > output
# and compares output with script.output
# Example:
# triqs_add_triqs_test_script(ExampleTest)
# where ExampleTest.py is the script and ExampleTest.output is the expected output
#
macro(triqs_add_test_txt testname )
enable_testing()
add_test(${testname}
${CMAKE_COMMAND}
-Dname=${testname}
-Dcmd=${ExecutableNameForTest}
-Dinput=${CMAKE_CURRENT_SOURCE_DIR}/${testname}.py
-Dreference=${CMAKE_CURRENT_SOURCE_DIR}/${testname}.output
-P @CMAKE_INSTALL_PREFIX@/share/triqs/cmake/run_test.cmake
)
endmacro(triqs_add_test_txt)
# - runs python_with_DMFT script
# - compares the file named testname_output.h5
# with the file testname.output.h5 of the source directory
# The comparison with made with h5diff_options
# all remainings arguments are the objects to which to restrict the comparison (default = no restriction)
# Example :
# triqs_add_triqs_test_hdf(ExampleTestH5 "-r" )
# where ExampleTestH5.py produces to be compared with ExampleTestH5_output.h5 with option "-r" and for all objects
#
macro(triqs_add_test_hdf testname h5diff_options)
set(h5diff_objects ${ARGN}) # grab additionnal arguments !
enable_testing()
add_test(${testname}
${CMAKE_COMMAND}
-Dname=${testname}
-Dcmd=${ExecutableNameForTest}
-Dinput=${CMAKE_CURRENT_SOURCE_DIR}/${testname}.py
-DoutputName=${testname}.output.h5
-Dreference=${CMAKE_CURRENT_SOURCE_DIR}/${testname}.output.h5
-DH5_DIFF_EXECUTABLE=${TRIQS_HDF5_DIFF_EXECUTABLE}
-DH5_DIFF_OPTIONS=${h5diff_options}
-DH5_DIFF_OBJECTS=${h5diff_objects}
-P @CMAKE_INSTALL_PREFIX@/share/triqs/cmake/run_test.cmake
)
endmacro(triqs_add_test_hdf)