From bbe183b087fd20c28ca565164a41426b03824256 Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Wed, 7 Aug 2013 15:00:03 +0200 Subject: [PATCH] Cmake testing: Added test_biblio --- src/frontends/CMakeLists.txt | 1 + src/frontends/tests/CMakeLists.txt | 20 ++++++++++++++++++++ src/frontends/tests/test_biblio.cmake | 17 +++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 src/frontends/tests/CMakeLists.txt create mode 100644 src/frontends/tests/test_biblio.cmake diff --git a/src/frontends/CMakeLists.txt b/src/frontends/CMakeLists.txt index c8e8065fcc..78c310d31d 100644 --- a/src/frontends/CMakeLists.txt +++ b/src/frontends/CMakeLists.txt @@ -26,3 +26,4 @@ target_link_libraries(frontends ${Lyx_Boost_Libraries}) project_source_group("${GROUP_CODE}" frontends_sources frontends_headers) +add_subdirectory(tests) diff --git a/src/frontends/tests/CMakeLists.txt b/src/frontends/tests/CMakeLists.txt new file mode 100644 index 0000000000..9641faf11a --- /dev/null +++ b/src/frontends/tests/CMakeLists.txt @@ -0,0 +1,20 @@ +# This file is part of LyX, the document processor. +# Licence details can be found in the file COPYING. +# +# Copyright (c) 2013 Kornel Benko, + +project(test) + +set(TESTS "test_biblio") + +add_executable(biblio biblio.cpp boost.cpp) +target_link_libraries(biblio ${Lyx_Boost_Libraries}) +add_dependencies(lyx_run_tests biblio) + +foreach(tst ${TESTS}) + add_test(NAME "frontends/${tst}" + COMMAND ${CMAKE_COMMAND} + -Dbiblio=$ + -Dsaved_data=${TOP_SRC_DIR}/src/frontends/tests/regfiles/biblio + -P ${TOP_SRC_DIR}/src/frontends/tests/${tst}.cmake) +endforeach() diff --git a/src/frontends/tests/test_biblio.cmake b/src/frontends/tests/test_biblio.cmake new file mode 100644 index 0000000000..e086a4e69b --- /dev/null +++ b/src/frontends/tests/test_biblio.cmake @@ -0,0 +1,17 @@ +# check of output of biblio-command with the saved data in regfiles/biblio +# +# Input variable +# biblio = full path of the biblio executable +# saved_data = full path of the file with expected output of biblio +# +if(NOT EXISTS "${biblio}") + message(STATUS "searching for biblio as ${biblio}") + message(FATAL_ERROR "Compile biblio first") +else() + execute_process(COMMAND "${biblio}" OUTPUT_VARIABLE biblio_out RESULT_VARIABLE biblio_res) + + file(READ "${saved_data}" biblio_check) + if(NOT biblio_out STREQUAL biblio_check) + message(FATAL_ERROR "biblio_out = ${biblio_out}\nbiblio_in = ${biblio_in}") + endif() +endif() -- 2.39.2