1 # This script invokes the keytest.py script with the simple set-up needed
2 # to re-run deterministic regression tests that one would like to have.
4 # AUTOTEST_ROOT = ${LYX_ROOT}/development/autotests
5 # KEYTEST_INFILE = xxx-in.txt
6 # KEYTEST_OUTFILE = xxx-out.txt
7 # BINDIR = ${BUILD_DIR}/bin
8 # WORKDIR = ${BUILD_DIR}/autotests/out-home
9 # LYX_USERDIR_VER = ${LYX_USERDIR_VER}
10 # LOCALE_DIR = ${BUILD_DIR}/autotests/locale
11 # PO_BUILD_DIR = ${BUILD_DIR}/po
14 # Script should be called like:
15 # cmake -DAUTOTEST_ROOT=xxxx \
16 # -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
17 # -DKEYTEST_INFILE=xxxx \
18 # -DKEYTEST_OUTFILE=xxx \
22 # -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \
24 # -DPO_BUILD_DIR=xxx \
27 # -P ${AUTOTEST_ROOT}/single-test.cmake
29 set(KEYTEST "${AUTOTEST_ROOT}/keytest.py")
32 # This thread works, but the sollution in keytest.py is faster
33 #-------------------------------------------------------------
34 # Try to wait some seconds until the previous lyx stopped
35 # but not more than 30 seconds
36 message(STATUS "Wait for maximal 30 seconds until the previous lyx finishes")
39 while (NOT lcount GREATER 30)
40 MATH(EXPR lcount "${lcount} + 1")
41 execute_process(COMMAND pidof ${LYX} OUTPUT_VARIABLE LYX_PID RESULT_VARIABLE pidstat OUTPUT_VARIABLE pidres)
45 execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1)
49 # We had to wait for some seconds
50 message(STATUS "There was still some lyx in way(${lcount})")
53 # lyx still running, remove trailing '\n' from pid
54 string(REGEX REPLACE "\n" "" pidres ${pidres})
55 message(FATAL_ERROR "Old lyx with pid ${pidres} still running")
59 #check for plausible DISPLAY environment (needed bei keytests)
60 set(DISPLAY_VAR $ENV{DISPLAY})
61 if(NOT DISPLAY_VAR MATCHES "^[a-zA-Z\\.]*:[0-9]+\(\\.[0-9]+\)?$")
62 message(FATAL_ERROR "Invalid DISPLAY environment value (== '${DISPLAY_VAR}')")
65 set(LYX_EXE "${BINDIR}/${LYX}")
67 set(ENV{QT_FRONTEND} ${FRONTEND})
69 if(EXISTS "${LYX_TESTS_USERDIR}/session")
70 execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f "${LYX_TESTS_USERDIR}/session")
72 # Environments needed by keytest.py
73 set(ENV{EXTRA_PATH} "${AUTOTEST_ROOT}")
74 set(ENV{PACKAGE} ${PACKAGE})
75 set(ENV{LOCALE_DIR} ${LOCALE_DIR})
76 set(ENV{LYX_LOCALEDIR} "${LOCALE_DIR}")
77 set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}")
78 set(ENV{LYX_PID} ${pidres})
79 set(ENV{LYX_WINDOW_NAME} ${LYX_WINDOW_NAME})
80 set(ENV{LYX_EXE} ${LYX_EXE})
82 set(ENV{XVKBD_EXE} ${XVKBD_EXE})
83 set(ENV{KEYTEST_INFILE} "${AUTOTEST_ROOT}/${KEYTEST_INFILE}")
84 set(ENV{KEYTEST_OUTFILE} "${WORKDIR}/${KEYTEST_OUTFILE}")
85 set(ENV{PO_BUILD_DIR} "${PO_BUILD_DIR}")
88 string(REGEX REPLACE "-in\\.(txt|sh)$" "" _jj ${KEYTEST_INFILE})
89 if(EXISTS "${WORKDIR}/../${_jj}.lyx.emergency")
91 COMMAND ${CMAKE_COMMAND} -E remove -f "${WORKDIR}/../${_jj}.lyx.emergency" )
93 file(GLOB _testfiles RELATIVE "${WORKDIR}" "test*.*" "#test*.*")
95 # remove some leftover files from previous test
97 COMMAND ${CMAKE_COMMAND} -E remove -f ${_testfiles} )
99 if(EXISTS "${AUTOTEST_ROOT}/${_jj}.lyx")
100 configure_file("${AUTOTEST_ROOT}/${_jj}.lyx" "${WORKDIR}/../${_jj}.lyx" COPYONLY)
104 COMMAND python ${KEYTEST}
105 RESULT_VARIABLE KEYTEST_RES)
107 message(FATAL_ERROR "KEYTEST failed: KEYTEST_RES=${KEYTEST_RES}")