Cmake build tests: Unify use of userdir

While some test runns lyx-exe, we need userdir be
different from default. All relevant tests should use the same directory.
This commit is contained in:
Kornel Benko 2013-08-25 11:41:10 +02:00
parent 0b6edb0b2f
commit 788e2b1ac8
7 changed files with 55 additions and 11 deletions

View File

@ -23,7 +23,7 @@ set(CMAKE_MODULE_PATH "${TOP_MODULE_PATH}")
set(CMAKE_PROJECT_NAME ${LYX_PROJECT}) set(CMAKE_PROJECT_NAME ${LYX_PROJECT})
message(STATUS) message(STATUS)
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(STATUS "Building in-source") message(STATUS "Building in-source")
set(TOP_BINARY_DIR "${CMAKE_BINARY_DIR}/build") set(TOP_BINARY_DIR "${CMAKE_BINARY_DIR}/build")
else() else()
@ -31,6 +31,9 @@ else()
set(TOP_BINARY_DIR "${CMAKE_BINARY_DIR}") set(TOP_BINARY_DIR "${CMAKE_BINARY_DIR}")
endif() endif()
# This directory should be used if some test uses lyx-executable
set(LYX_TESTS_USERDIR "${TOP_BINARY_DIR}/Testing/.lyx")
file(MAKE_DIRECTORY "${LYX_TESTS_USERDIR}")
if(COMMAND cmake_policy) if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 OLD) cmake_policy(SET CMP0003 OLD)

View File

@ -5,9 +5,8 @@
# #
set(LYX_HOME "out-home") set(LYX_HOME "out-home")
set(LYX_USERDIR "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}/.lyx")
set(LOCALE_DIR "${CMAKE_CURRENT_BINARY_DIR}/locale") set(LOCALE_DIR "${CMAKE_CURRENT_BINARY_DIR}/locale")
file(MAKE_DIRECTORY "${LYX_USERDIR}" "${LOCALE_DIR}") file(MAKE_DIRECTORY "${LOCALE_DIR}")
if(Q_WS_X11) if(Q_WS_X11)
set(Missing) set(Missing)
@ -78,13 +77,13 @@ if(Q_WS_X11)
file(GLOB TESTSS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.sh") file(GLOB TESTSS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.sh")
list(REMOVE_ITEM TESTST hello-world-in.txt first-time-in.txt) list(REMOVE_ITEM TESTST hello-world-in.txt first-time-in.txt)
list(SORT TESTST) list(SORT TESTST)
file(MAKE_DIRECTORY "${LYX_USERDIR}" "${LOCALE_DIR}")
foreach(_tf first-time-in.txt hello-world-in.txt ${TESTST}) foreach(_tf first-time-in.txt hello-world-in.txt ${TESTST})
string(REGEX REPLACE "-in\\.(txt|sh)" "" _t ${_tf}) string(REGEX REPLACE "-in\\.(txt|sh)" "" _t ${_tf})
add_test(NAME keytest/${_t} add_test(NAME keytest/${_t}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
COMMAND ${CMAKE_COMMAND} COMMAND ${CMAKE_COMMAND}
-DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
-DAUTOTEST_ROOT=${TOP_SRC_DIR}/development/autotests -DAUTOTEST_ROOT=${TOP_SRC_DIR}/development/autotests
-DPO_BUILD_DIR=${TOP_BINARY_DIR}/po -DPO_BUILD_DIR=${TOP_BINARY_DIR}/po
-DKEYTEST_INFILE=${_tf} -DKEYTEST_INFILE=${_tf}
@ -173,6 +172,7 @@ foreach(libsubfolder doc examples templates)
add_test(NAME ${TestName} add_test(NAME ${TestName}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR} COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
-DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
-Dlyx=$<TARGET_FILE:${_lyx}> -Dlyx=$<TARGET_FILE:${_lyx}>
-DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME} -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
-DLYX_USERDIR_VER=${LYX_USERDIR_VER} -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
@ -188,6 +188,7 @@ foreach(libsubfolder doc examples templates)
add_test(NAME ${TestName} add_test(NAME ${TestName}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
COMMAND ${CMAKE_COMMAND} -DLYX2LYX=${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx COMMAND ${CMAKE_COMMAND} -DLYX2LYX=${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx
-DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
-DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
-P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake") -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake")
endif() endif()
@ -197,6 +198,7 @@ foreach(libsubfolder doc examples templates)
add_test(NAME ${TestName} add_test(NAME ${TestName}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
COMMAND ${CMAKE_COMMAND} -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx COMMAND ${CMAKE_COMMAND} -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
-DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
-Dlyx=$<TARGET_FILE:${_lyx}> -Dlyx=$<TARGET_FILE:${_lyx}>
-DPARAMS_DIR=${TOP_SRC_DIR}/development/autotests -DPARAMS_DIR=${TOP_SRC_DIR}/development/autotests
-DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME} -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
@ -212,6 +214,7 @@ foreach(libsubfolder doc examples templates)
add_test(NAME ${TestName} add_test(NAME ${TestName}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR} COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
-DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
-Dlyx=$<TARGET_FILE:${_lyx}> -Dlyx=$<TARGET_FILE:${_lyx}>
-DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME} -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
-Dformat=${format} -Dformat=${format}

View File

@ -10,6 +10,7 @@
# #
# Script should be called like: # Script should be called like:
# cmake -DWORKDIR=${BUILD_DIR}/autotests/out-home \ # cmake -DWORKDIR=${BUILD_DIR}/autotests/out-home \
# -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} \
# -DLYXFILE=xxx \ # -DLYXFILE=xxx \
# -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \ # -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \
# -DPARAMS_DIR="${TOP_SRC_DIR}/development/autotests" \ # -DPARAMS_DIR="${TOP_SRC_DIR}/development/autotests" \
@ -17,11 +18,11 @@
# #
message(STATUS "Executing ${lyx} -batch ${LYXFILE}") message(STATUS "Executing ${lyx} -batch ${LYXFILE}")
set(ENV{${LYX_USERDIR_VER}} "${WORKDIR}/.lyx") set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}")
set(ENV{LANG} "en") # to get all error-messages in english set(ENV{LANG} "en") # to get all error-messages in english
execute_process( execute_process(
COMMAND ${lyx} -batch -userdir ${WORKDIR}/.lyx ${LYXFILE} COMMAND ${lyx} -batch -userdir "${LYX_TESTS_USERDIR}" ${LYXFILE}
RESULT_VARIABLE _err RESULT_VARIABLE _err
ERROR_VARIABLE lyxerr) ERROR_VARIABLE lyxerr)

View File

@ -13,6 +13,7 @@
# #
# Script should be called like: # Script should be called like:
# cmake -DLYX_ROOT=xxx \ # cmake -DLYX_ROOT=xxx \
# -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} \
# -DWORKDIR=${BUILD_DIR}/autotests/out-home \ # -DWORKDIR=${BUILD_DIR}/autotests/out-home \
# -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \ # -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \
# -Dlyx=xxx \ # -Dlyx=xxx \
@ -24,10 +25,10 @@
# #
message(STATUS "Executing ${lyx} -userdir \"${WORKDIR}/.lyx\" -E ${format} ${file}.${extension} \"${LYX_ROOT}/${file}.lyx\"") message(STATUS "Executing ${lyx} -userdir \"${WORKDIR}/.lyx\" -E ${format} ${file}.${extension} \"${LYX_ROOT}/${file}.lyx\"")
set(ENV{${LYX_USERDIR_VER}} "${WORKDIR}/.lyx") set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${file}.${extension}) execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${file}.${extension})
execute_process( execute_process(
COMMAND ${lyx} -userdir "${WORKDIR}/.lyx" -E ${format} ${file}.${extension} "${LYX_ROOT}/${file}.lyx" COMMAND ${lyx} -userdir "${LYX_TESTS_USERDIR}" -E ${format} ${file}.${extension} "${LYX_ROOT}/${file}.lyx"
RESULT_VARIABLE _err) RESULT_VARIABLE _err)
if(reverted) if(reverted)
string(COMPARE EQUAL ${_err} 0 _erg) string(COMPARE EQUAL ${_err} 0 _erg)

View File

@ -9,6 +9,7 @@
# #
# Script should be called like: # Script should be called like:
# cmake -DLYX2LYX=xxx \ # cmake -DLYX2LYX=xxx \
# -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} \
# -DWORKDIR=${BUILD_DIR}/autotests/out-home \ # -DWORKDIR=${BUILD_DIR}/autotests/out-home \
# -DLYXFILE=xxx \ # -DLYXFILE=xxx \
# -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake" # -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake"

View File

@ -13,6 +13,7 @@
# #
# Script should be called like: # Script should be called like:
# cmake -DAUTOTEST_ROOT=xxxx \ # cmake -DAUTOTEST_ROOT=xxxx \
# -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
# -DKEYTEST_INFILE=xxxx \ # -DKEYTEST_INFILE=xxxx \
# -DKEYTEST_OUTFILE=xxx \ # -DKEYTEST_OUTFILE=xxx \
# -DBINDIR=xxx \ # -DBINDIR=xxx \
@ -68,14 +69,14 @@ else()
set(XVKBD_EXE "/usr/bin/xvkbd") set(XVKBD_EXE "/usr/bin/xvkbd")
endif() endif()
if(EXISTS "${WORKDIR}/.lyx/session") if(EXISTS "${LYX_TESTS_USERDIR}/session")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f "${WORKDIR}/.lyx/session") execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f "${LYX_TESTS_USERDIR}/session")
endif() endif()
# Environments needed by keytest.py # Environments needed by keytest.py
set(ENV{PACKAGE} ${PACKAGE}) set(ENV{PACKAGE} ${PACKAGE})
set(ENV{LOCALE_DIR} ${LOCALE_DIR}) set(ENV{LOCALE_DIR} ${LOCALE_DIR})
set(ENV{LYX_LOCALEDIR} "${WORKDIR}/../locale") set(ENV{LYX_LOCALEDIR} "${WORKDIR}/../locale")
set(ENV{${LYX_USERDIR_VER}} "${WORKDIR}/.lyx") set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}")
set(ENV{LYX_PID} ${pidres}) set(ENV{LYX_PID} ${pidres})
set(ENV{LYX_WINDOW_NAME} ${LYX_WINDOW_NAME}) set(ENV{LYX_WINDOW_NAME} ${LYX_WINDOW_NAME})
set(ENV{LYX_EXE} ${LYX_EXE}) set(ENV{LYX_EXE} ${LYX_EXE})

View File

@ -0,0 +1,34 @@
# 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
#
#
# -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} \
# -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \
# -DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE} \
# -DPY_SCRIPT=${TOP_SRC_DIR}/src/tex2lyx/test/runtests.py \
# -DFIRST_PARAM=
# -DTEX2LYX_EXE=$<TARGET_FILE:${_tex2lyx}> \
# -DSCRIPT_DIR=${TOP_SRC_DIR}/lib/scripts \
# -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR} \
# -DTESTFILE=${fl} \
# -P ${TOP_SRC_DIR}/src/tex2lyx/test/runtests.cmake
set(ENV{${LYX_USERDIR_VER}} ${LYX_TESTS_USERDIR})
message(STATUS "SCRIPT_DIR = ${SCRIPT_DIR}")
execute_process(COMMAND ${LYX_PYTHON_EXECUTABLE} ${PY_SCRIPT} ${FIRST_PARAM}
${TEX2LYX_EXE} ${SCRIPT_DIR} ${WORKDIR} ${TESTFILE}
RESULT_VARIABLE _err
OUTPUT_VARIABLE _out)
message(STATUS ${_out})
message(STATUS "Error output of ${PY_SCRIPT} = ${_err}")
string(COMPARE NOTEQUAL ${_err} 0 _erg)
if(_erg)
message(FATAL_ERROR "${PY_SCRIPT} failed")
endif()