]> git.lyx.org Git - lyx.git/blob - development/autotests/single-test.cmake
ctests: address some test failures.
[lyx.git] / development / autotests / single-test.cmake
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.
3 #
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
12 # PACKAGE         = lyx2.1
13 #
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 \
19 #       -DBINDIR=xxx \
20 #       -DLYX=xxx \
21 #       -DWORKDIR=xxx \
22 #       -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \
23 #       -DLOCALE_DIR=xxx \
24 #       -DPO_BUILD_DIR=xxx \
25 #       -DPACKAGE=xxx \
26 #       -DFRONTEND=Qt? \
27 #       -P ${AUTOTEST_ROOT}/single-test.cmake
28
29 set(KEYTEST "${AUTOTEST_ROOT}/keytest.py")
30
31 execute_process(COMMAND pidof ${LYX} OUTPUT_VARIABLE LYX_PID RESULT_VARIABLE pidstat OUTPUT_VARIABLE pidres)
32 message(STATUS "pidres = ${pidres}")
33 if (NOT pidstat)
34   # lyx already running, remove trailing '\n' from pid
35   string(REGEX REPLACE "\n" "" pidres ${pidres})
36   execute_process(COMMAND wmctrl -l -p OUTPUT_VARIABLE _wmco)
37   string(REGEX REPLACE "[\n]+" ";" _wmc ${_wmco})
38   foreach(_w ${_wmc})
39     string(REGEX MATCH "${pidres}" _wr ${_w})
40     if (${_wr} MATCHES ${pidres})
41       # this entry contains the pid, go search for X11-window-id
42       string(REGEX REPLACE " .*" "" _wr ${_w})
43       set(LYX_WINDOW_NAME ${_wr})
44       message(STATUS "Set LYX_WINDOW_NAME to ${_wr}")
45     endif()
46   endforeach()
47 else()
48   set(pidres "")
49   set(LYX_WINDOW_NAME "")
50 endif()
51
52 #check for plausible DISPLAY environment (needed bei keytests)
53 set(DISPLAY_VAR $ENV{DISPLAY})
54 if(NOT DISPLAY_VAR MATCHES "^[a-zA-Z\\.]*:[0-9]+\(\\.[0-9]+\)?$")
55   message(FATAL_ERROR "Invalid DISPLAY environment value (== '${DISPLAY_VAR}')")
56 endif()
57
58 set(LYX_EXE "${BINDIR}/${LYX}")
59 set(use_hacked $ENV{XVKBD_HACKED})
60 if(NOT use_hacked)
61   if(use_hacked STREQUAL "")
62     # ENV{XVKBD_HACKED} probably not set, so the default should be
63     # to use the hacked
64     set(use_hacked "1")
65   else()
66     set(use_hacked "0")
67   endif()
68 else()
69   set(use_hacked "1")
70 endif()
71
72 set(ENV{XVKBD_HACKED} ${use_hacked})
73 if(use_hacked)
74   set(XVKBD_EXE "${BINDIR}/xvkbd")
75 else()
76   set(XVKBD_EXE "/usr/bin/xvkbd")
77 endif()
78 set(ENV{QT_FRONTEND} ${FRONTEND})
79
80 if(EXISTS "${LYX_TESTS_USERDIR}/session")
81   execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f "${LYX_TESTS_USERDIR}/session")
82 endif()
83 # Environments needed by keytest.py
84 set(ENV{PACKAGE} ${PACKAGE})
85 set(ENV{LOCALE_DIR} ${LOCALE_DIR})
86 set(ENV{LYX_LOCALEDIR} "${LOCALE_DIR}")
87 set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}")
88 set(ENV{LYX_PID} ${pidres})
89 set(ENV{LYX_WINDOW_NAME} ${LYX_WINDOW_NAME})
90 set(ENV{LYX_EXE} ${LYX_EXE})
91 set(ENV{LYX} ${LYX})
92 set(ENV{XVKBD_EXE} ${XVKBD_EXE})
93 set(ENV{KEYTEST_INFILE} "${AUTOTEST_ROOT}/${KEYTEST_INFILE}")
94 set(ENV{KEYTEST_OUTFILE} "${WORKDIR}/${KEYTEST_OUTFILE}")
95 set(ENV{PO_BUILD_DIR} "${PO_BUILD_DIR}")
96 set(ENV{MAX_DROP} 0)
97 set(ENV{MAX_LOOPS} 1)
98 string(REGEX REPLACE "-in\\.(txt|sh)$" "" _jj ${KEYTEST_INFILE})
99 if(EXISTS "${WORKDIR}/../${_jj}.lyx.emergency")
100   execute_process(
101   COMMAND ${CMAKE_COMMAND} -E remove -f "${WORKDIR}/../${_jj}.lyx.emergency" )
102 endif()
103 file(GLOB _testfiles RELATIVE "${WORKDIR}" "test*.*" "#test*.*")
104 if(_testfiles)
105   # remove some leftover files from previous test
106   execute_process(
107   COMMAND ${CMAKE_COMMAND} -E remove -f ${_testfiles} )
108 endif()
109 if(EXISTS "${AUTOTEST_ROOT}/${_jj}.lyx")
110   configure_file("${AUTOTEST_ROOT}/${_jj}.lyx" "${WORKDIR}/../${_jj}.lyx" COPYONLY)
111 endif()
112 execute_process(
113   COMMAND python ${KEYTEST}
114   RESULT_VARIABLE KEYTEST_RES)
115 if(KEYTEST_RES)
116   message(FATAL_ERROR "KEYTEST failed: KEYTEST_RES=${KEYTEST_RES}")
117 endif()
118