From ed5dfa9cd76a5775d1bafe5471cbeb488ce7c7e9 Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Sun, 21 Oct 2012 12:05:50 +0200 Subject: [PATCH] Cmake tests: Add tests the cmake-way. Now there is only _one_ target `test' --- CMakeLists.txt | 2 ++ src/support/tests/CMakeLists.txt | 17 ++++++++--------- src/tex2lyx/test/CMakeLists.txt | 13 ++++++++++++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 700ff04845..b5bb34667a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,8 @@ cmake_minimum_required(VERSION 2.6.4) set(LYX_PROJECT LyX) +enable_testing() + set(LYX_CMAKE_DIR "development/cmake") set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/${LYX_CMAKE_DIR}/modules") diff --git a/src/support/tests/CMakeLists.txt b/src/support/tests/CMakeLists.txt index d04c02f99e..7a25e2ad45 100644 --- a/src/support/tests/CMakeLists.txt +++ b/src/support/tests/CMakeLists.txt @@ -38,15 +38,14 @@ foreach(_src ${check_PROGRAMS}) string(REPLACE "check_" "" _srcx ${_src}) set(src_data_file "${TOP_SRC_DIR}/src/support/tests/regfiles/${_srcx}") set(created_data_file "${CMAKE_CURRENT_BINARY_DIR}/regfiles/${_src}_data") - add_custom_command( - OUTPUT "${created_data_file}" - COMMAND ${_src} > "${created_data_file}" - COMMAND ${CMAKE_COMMAND} -E compare_files "${src_data_file}" "${created_data_file}" - DEPENDS ${_src} "${src_data_file}" - COMMENT "${_src} > '${created_data_file}'" - ) - list(APPEND _depends "${created_data_file}") + add_test(NAME build_${_srcx} + COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${_src}) + add_test(NAME data_${_srcx} + COMMAND ${_src} > "${created_data_file}") + add_test(NAME compare_${_srcx} + COMMAND ${CMAKE_COMMAND} -E compare_files "${src_data_file}" "${created_data_file}") + set_tests_properties(data_${_srcx} PROPERTIES DEPENDS build_${_srcx} ) + set_tests_properties(compare_${_srcx} PROPERTIES DEPENDS data_${_srcx}) endforeach() -add_custom_target(checkregfiles DEPENDS support ${_depends}) diff --git a/src/tex2lyx/test/CMakeLists.txt b/src/tex2lyx/test/CMakeLists.txt index a68e5e60ea..e85222f070 100644 --- a/src/tex2lyx/test/CMakeLists.txt +++ b/src/tex2lyx/test/CMakeLists.txt @@ -30,5 +30,16 @@ ADD_CUSTOM_COMMAND( "${CMAKE_CURRENT_BINARY_DIR}" ) -ADD_CUSTOM_TARGET(test DEPENDS ${_tex2lyx} ${_lyx} ${_test_output}) +#ADD_CUSTOM_TARGET(test DEPENDS ${_tex2lyx} ${_lyx} ${_test_output}) + +add_test(NAME build_tex2lyx + COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${_tex2lyx}) +add_test(NAME roundtrip_tex2lyx + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + COMMAND ${LYX_PYTHON_EXECUTABLE} "${TOP_SRC_DIR}/src/tex2lyx/test/runtests.py" + "${TOP_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/${_tex2lyx}" + "${TOP_SRC_DIR}/lib/scripts" + "${CMAKE_CURRENT_BINARY_DIR}") + +set_tests_properties(roundtrip_tex2lyx PROPERTIES DEPENDS build_tex2lyx)