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})
message(STATUS)
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(STATUS "Building in-source")
set(TOP_BINARY_DIR "${CMAKE_BINARY_DIR}/build")
else()
@ -31,6 +31,9 @@ else()
set(TOP_BINARY_DIR "${CMAKE_BINARY_DIR}")
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)
cmake_policy(SET CMP0003 OLD)

View File

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

View File

@ -10,6 +10,7 @@
#
# Script should be called like:
# cmake -DWORKDIR=${BUILD_DIR}/autotests/out-home \
# -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} \
# -DLYXFILE=xxx \
# -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \
# -DPARAMS_DIR="${TOP_SRC_DIR}/development/autotests" \
@ -17,11 +18,11 @@
#
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
execute_process(
COMMAND ${lyx} -batch -userdir ${WORKDIR}/.lyx ${LYXFILE}
COMMAND ${lyx} -batch -userdir "${LYX_TESTS_USERDIR}" ${LYXFILE}
RESULT_VARIABLE _err
ERROR_VARIABLE lyxerr)

View File

@ -13,6 +13,7 @@
#
# Script should be called like:
# cmake -DLYX_ROOT=xxx \
# -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} \
# -DWORKDIR=${BUILD_DIR}/autotests/out-home \
# -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \
# -Dlyx=xxx \
@ -24,10 +25,10 @@
#
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 ${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)
if(reverted)
string(COMPARE EQUAL ${_err} 0 _erg)

View File

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

View File

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