]> git.lyx.org Git - features.git/blob - development/autotests/CMakeLists.txt
Cmake tests: Disable keytests if missing needed input files
[features.git] / development / autotests / CMakeLists.txt
1 # This file is part of LyX, the document processor.
2 # Licence details can be found in the file COPYING.
3 #
4 # Copyright (c) 2012 Kornel Benko kornel@lyx.org
5 #
6
7 set(LYX_HOME "out-home")
8 set(LOCALE_DIR "${CMAKE_CURRENT_BINARY_DIR}/locale")
9 file(MAKE_DIRECTORY "${LOCALE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}")
10
11 if(QT_USES_X11)
12   set(Missing)
13   set(XVFBDLIBS)
14   # Make sure, the needed programs are in PATH
15   find_program(PCREGREP_EXE "pcregrep")
16   if (NOT PCREGREP_EXE)
17     list(APPEND Missing "pcregrep")
18   endif()
19   find_program(WMCTRL_EXE "wmctrl")
20   if(NOT WMCTRL_EXE)
21     list(APPEND Missing "wmctrl")
22   endif()
23   # This is needed to build xvkbd
24   # Programs pcregrep wmctrl and xvkbd are used in subsequent scripts
25   # while testing
26
27   # Check for needed libraries for xvkbd
28   # do not add autotests, if any of them is lacking
29
30   find_package(X11)
31   if(NOT X11_FOUND)
32     list(APPEND Missing "X11")
33   endif()
34   find_package(PkgConfig)
35   if(PKG_CONFIG_FOUND)
36     foreach(_lb "xaw7" "xmu" "xtst")
37       pkg_check_modules(${_lb}LIB ${_lb})
38       if(${_lb}LIB_LIBRARIES)
39         list(APPEND XVFBDLIBS ${${_lb}LIB_LIBRARIES})
40       else()
41         list(APPEND Missing ${_lb})
42       endif()
43     endforeach()
44   else()
45     foreach(_lb "Xaw7" "Xmu")
46       find_library(${_lb}LIB ${_lb})
47       if(${_lb}LIB)
48         list(APPEND XVFBDLIBS ${${_lb}LIB})
49       else()
50         list(APPEND Missing ${_lb})
51       endif()
52     endforeach()
53     foreach(_lb Xt XTest X11)
54       if(X11_${_lb}_LIB)
55         list(APPEND XVFBDLIBS ${X11_${_lb}_LIB})
56       else()
57         list(APPEND Missing ${_lb})
58       endif()
59     endforeach()
60   endif()
61   if (XVFBDLIBS)
62     list(REMOVE_DUPLICATES XVFBDLIBS)
63   endif()
64
65   if(Missing)
66     message(STATUS "Missing Libraries or programs to create xvkbd: ${Missing}")
67     message(STATUS "cmake build is therefore omitting keytests")
68   endif()
69
70   if(Missing)
71     set(_runtest FALSE)
72   else()
73     project(keytest)
74
75     add_subdirectory(xvkbd)
76
77     set(_runtest TRUE)
78     set(KEYTEST "${CMAKE_CURRENT_SOURCE_DIR}/keytest.py")
79     file(GLOB TESTST RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.txt")
80     file(GLOB TESTSS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.sh")
81     set(_firsttxt hello-world-in.txt first-time-in.txt)
82     foreach(_f ${_firsttxt})
83       list(FIND TESTST ${_f} _ff)
84       if(NOT _ff GREATER -1)
85         set(_runtest FALSE)
86       endif()
87     endforeach()
88     list(REMOVE_ITEM TESTST ${_firsttxt})
89     list(SORT TESTST)
90   endif()
91   if(_runtest)
92     foreach(_tf ${_firsttxt} ${TESTST})
93       string(REGEX REPLACE "-in\\.(txt|sh)" "" _t ${_tf})
94       add_test(NAME keytest/${_t}
95         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
96         COMMAND ${CMAKE_COMMAND}
97         -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
98         -DAUTOTEST_ROOT=${TOP_SRC_DIR}/development/autotests
99         -DPO_BUILD_DIR=${TOP_BINARY_DIR}/po
100         -DKEYTEST_INFILE=${_tf}
101         -DBINDIR=$<TARGET_FILE_DIR:${_lyx}>
102         -DLYX=${_lyx}
103         -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
104         -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
105         -DKEYTEST_OUTFILE=${_t}-out.txt
106         -DPACKAGE=${PACKAGE}
107         -DLOCALE_DIR=${LOCALE_DIR}
108         -P ${TOP_SRC_DIR}/development/autotests/single-test.cmake)
109       settestlabel(keytest/${_t} "key")
110       set_tests_properties(keytest/${_t} PROPERTIES RUN_SERIAL ON)
111     endforeach()
112   endif()
113 endif()
114
115 if (LYX_ENABLE_EXPORT_TESTS)
116   include(${TOP_SRC_DIR}/development/autotests/ExportTests.cmake)
117 endif()