From fc33092fd84613386f5246a7df23363488cc0bc3 Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Wed, 21 Aug 2013 13:34:26 +0200 Subject: [PATCH] Cmake build: modify some tests a) test export/templates/ectaart_pdf5 removed, because of incompatibility between ectart.cls and luatex.sty b) renamed some tests to reflect their purpose tex2lyx2lyx/roundtrip/ => tex2lyx/cmplyx/ # the tests are comparing files written by lyx (not by tex2lyx) autotests/ => keytest/ # we are testing reactions of lyx to some key strokes c) add tests for lyx2lyx. This is rather rudimental, in that it only checks for created output, error codes and error output. d) use correct environment variable to set up the userdir for testing --- development/autotests/CMakeLists.txt | 27 ++++++++++++---- development/autotests/export.cmake | 6 ++-- development/autotests/ignoredTests | 1 + development/autotests/lyx2lyxtest.cmake | 43 +++++++++++++++++++++++++ development/autotests/single-test.cmake | 25 ++++++++++++-- 5 files changed, 90 insertions(+), 12 deletions(-) create mode 100644 development/autotests/ignoredTests create mode 100755 development/autotests/lyx2lyxtest.cmake diff --git a/development/autotests/CMakeLists.txt b/development/autotests/CMakeLists.txt index ecb49b59fc..011e8e8672 100644 --- a/development/autotests/CMakeLists.txt +++ b/development/autotests/CMakeLists.txt @@ -60,11 +60,11 @@ if(Q_WS_X11) if(Missing) message(STATUS "Missing Libraries or programs to create xvkbd: ${Missing}") - message(STATUS "cmake build is therefore omitting autotests") + message(STATUS "cmake build is therefore omitting keytests") endif() if(NOT Missing) - project(autotests) + project(keytest) add_subdirectory(xvkbd) @@ -80,7 +80,7 @@ if(Q_WS_X11) foreach(_tf first-time-in.txt hello-world-in.txt ${TESTST}) string(REGEX REPLACE "-in\\.(txt|sh)" "" _t ${_tf}) - add_test(NAME autotests/${_t} + add_test(NAME keytest/${_t} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}" COMMAND ${CMAKE_COMMAND} -DAUTOTEST_ROOT=${TOP_SRC_DIR}/development/autotests @@ -89,6 +89,7 @@ if(Q_WS_X11) -DBINDIR=$ -DLYX=${_lyx} -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME} + -DLYX_USERDIR_VER=${LYX_USERDIR_VER} -DKEYTEST_OUTFILE=${_t}-out.txt -DPACKAGE=${PACKAGE} -DLOCALE_DIR=${LOCALE_DIR} @@ -142,6 +143,7 @@ foreach(libsubfolder doc examples templates) endif() endforeach() file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/revertedTests" revertedTests) + file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/ignoredTests" ignoredTests) foreach(f ${nolang_lyx_files} ${lang_lyx_files}) # Strip extension string(REGEX REPLACE "\\.lyx$" "" f ${f}) @@ -152,18 +154,28 @@ foreach(libsubfolder doc examples templates) COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR} -Dlyx=$ -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME} + -DLYX_USERDIR_VER=${LYX_USERDIR_VER} -Dformat=lyx16x -Dextension=16.lyx -Dfile=${f} -Dreverted=${reverted} -P "${TOP_SRC_DIR}/development/autotests/export.cmake") + set(TestName "lyx2lyx/${libsubfolder}/${f}") + getreverted(TestName reverted revertedTests) + add_test(NAME ${TestName} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}" + COMMAND ${CMAKE_COMMAND} -DLYX2LYX=${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx + -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx + -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake") getoutputformats("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist) foreach(format ${formatlist}) set(TestName "export/${libsubfolder}/${f}_${format}") - getreverted(TestName reverted revertedTests) - add_test(NAME ${TestName} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}" - COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR} + list(FIND ignoredTests ${TestName} _idx) + if (${_idx} LESS 0) + getreverted(TestName reverted revertedTests) + add_test(NAME ${TestName} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}" + COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR} -Dlyx=$ -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME} -Dformat=${format} @@ -171,6 +183,7 @@ foreach(libsubfolder doc examples templates) -Dfile=${f} -Dreverted=${reverted} -P "${TOP_SRC_DIR}/development/autotests/export.cmake") + endif() endforeach() endforeach() endforeach() diff --git a/development/autotests/export.cmake b/development/autotests/export.cmake index dc5c0bf428..6fb919c123 100755 --- a/development/autotests/export.cmake +++ b/development/autotests/export.cmake @@ -5,6 +5,7 @@ # # # LYX_ROOT = ${TOP_SRC_DIR}/lib/{doc,examples,templates} +# LYX_USERDIR_VER = Name of environment variable for the user directory # lyx = # format = lyx16x|xhtml # extension = 16.lyx|xhtml @@ -12,7 +13,8 @@ # # Script should be called like: # cmake -DLYX_ROOT=xxx \ -# -DWORKDIR=${BUILD_DIR}/autotests/out-home +# -DWORKDIR=${BUILD_DIR}/autotests/out-home \ +# -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \ # -Dlyx=xxx \ # -Dformat=xxx \ # -Dextension=xxx \ @@ -22,7 +24,7 @@ # message(STATUS "Executing ${lyx} -E ${format} ${file}.${extension} ${LYX_ROOT}/${file}.lyx") -set(ENV{LYX_USERDIR} "${WORKDIR}/.lyx") +set(ENV{${LYX_USERDIR_VER}} "${WORKDIR}/.lyx") execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${file}.${extension}) execute_process( COMMAND ${lyx} -E ${format} ${file}.${extension} "${LYX_ROOT}/${file}.lyx" diff --git a/development/autotests/ignoredTests b/development/autotests/ignoredTests new file mode 100644 index 0000000000..dbfb39a5b4 --- /dev/null +++ b/development/autotests/ignoredTests @@ -0,0 +1 @@ +export/templates/ectaart_pdf5 diff --git a/development/autotests/lyx2lyxtest.cmake b/development/autotests/lyx2lyxtest.cmake new file mode 100755 index 0000000000..e595fc365e --- /dev/null +++ b/development/autotests/lyx2lyxtest.cmake @@ -0,0 +1,43 @@ +# This file is part of LyX, the document processor. +# Licence details can be found in the file COPYING. +# +# Copyright (c) 2013 Kornel Benko kornel@lyx.org +# +# +# LYX2LYX = ${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx +# LYXFILE = xxx +# +# Script should be called like: +# cmake -DLYX2LYX=xxx \ +# -DWORKDIR=${BUILD_DIR}/autotests/out-home \ +# -DLYXFILE=xxx \ +# -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake" +# + +message(STATUS "Executing ${LYX2LYX} -e errors -o output ${LYXFILE}") +execute_process( + COMMAND ${LYX2LYX} -e errors -o output ${LYXFILE} + RESULT_VARIABLE _err) + +message(STATUS "Error output of lyx2lyx = ${_err}") +string(COMPARE NOTEQUAL ${_err} 0 _erg) + +# Check file "errors" being empty +file(STRINGS "errors" foundErrors) +if(foundErrors) + set(_erg 1) + foreach(_l ${foundErrors}) + message(STATUS "${_l}") + endforeach() +endif() + +# Check file "output" being not empty +file(STRINGS "output" createdLyx) +if(NOT createdLyx) + set(_erg 1) + message(STATUS "Created file empty") +endif() + +if(_erg) + message(FATAL_ERROR "lyx2lyx failed") +endif() diff --git a/development/autotests/single-test.cmake b/development/autotests/single-test.cmake index 3f452cc5c7..ecb8fbbcc9 100755 --- a/development/autotests/single-test.cmake +++ b/development/autotests/single-test.cmake @@ -6,6 +6,7 @@ # KEYTEST_OUTFILE = xxx-out.txt # BINDIR = ${BUILD_DIR}/bin # WORKDIR = ${BUILD_DIR}/autotests/out-home +# LYX_USERDIR_VER = ${LYX_USERDIR_VER} # LOCALE_DIR = ${BUILD_DIR}/autotests/locale # PO_BUILD_DIR = ${BUILD_DIR}/po # PACKAGE = lyx2.1 @@ -17,6 +18,7 @@ # -DBINDIR=xxx \ # -DLYX=xxx \ # -DWORKDIR=xxx \ +# -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \ # -DLOCALE_DIR=xxx \ # -DPO_BUILD_DIR=xxx \ # -DPACKAGE=xxx \ @@ -46,8 +48,25 @@ else() endif() set(LYX_EXE "${BINDIR}/${LYX}") -set(XVKBD_EXE "${BINDIR}/xvkbd") -set(ENV{XVKBD_HACKED} "1") +set(use_hacked $ENV{XVKBD_HACKED}) +if(NOT use_hacked) + if(use_hacked STREQUAL "") + # ENV{XVKBD_HACKED} probably not set, so the default should be + # to use the hacked + set(use_hacked "1") + else() + set(use_hacked "0") + endif() +else() + set(use_hacked "1") +endif() + +set(ENV{XVKBD_HACKED} ${use_hacked}) +if(use_hacked) + set(XVKBD_EXE "${BINDIR}/xvkbd") +else() + set(XVKBD_EXE "/usr/bin/xvkbd") +endif() if(EXISTS "${WORKDIR}/.lyx/session") execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f "${WORKDIR}/.lyx/session") @@ -56,7 +75,7 @@ endif() set(ENV{PACKAGE} ${PACKAGE}) set(ENV{LOCALE_DIR} ${LOCALE_DIR}) set(ENV{LYX_LOCALEDIR} "${WORKDIR}/../locale") -set(ENV{LYX_USERDIR} "${WORKDIR}/.lyx") +set(ENV{${LYX_USERDIR_VER}} "${WORKDIR}/.lyx") set(ENV{LYX_PID} ${pidres}) set(ENV{LYX_WINDOW_NAME} ${LYX_WINDOW_NAME}) set(ENV{LYX_EXE} ${LYX_EXE}) -- 2.39.5