]> git.lyx.org Git - features.git/blob - development/autotests/CMakeLists.txt
Cmake build key tests: Omit the tests and creation of xvkbd command,
[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 if(Q_WS_X11)
8   set(Missing)
9   set(XVFBDLIBS)
10   # Make sure, the needed programs are in PATH
11   find_program(PCREGREP_EXE "pcregrep")
12   if (NOT PCREGREP_EXE)
13     list(APPEND Missing "pcregrep")
14   endif()
15   find_program(WMCTRL_EXE "wmctrl")
16   if(NOT WMCTRL_EXE)
17     list(APPEND Missing "wmctrl")
18   endif()
19   # This is needed to build xvkbd
20   # Programs pcregrep wmctrl and xvkbd are used in subsequent scripts
21   # while testing
22
23   # Check for needed libraries for xvkbd
24   # do not add autotests, if any of them is lacking
25
26   find_package(X11)
27   if(NOT X11_FOUND)
28     list(APPEND Missing "X11")
29   endif()
30   find_package(PkgConfig)
31   if(PKG_CONFIG_FOUND)
32     pkg_check_modules(XAWLIB xaw7)
33     if (XAWLIB_LIBRARIES)
34       list(APPEND XVFBDLIBS ${XAWLIB_LIBRARIES})
35     else()
36       list(APPEND Missing Xaw7)
37     endif()
38     pkg_check_modules(XTEST xtst)
39     if (XTEST_LIBRARIES)
40       list(APPEND XVFBDLIBS ${XTEST_LIBRARIES})
41     else()
42       list(APPEND Missing xtst)
43     endif()
44   else()
45     find_library(XAW7LIB "Xaw7")
46     if(XAW7LIB)
47       list(APPEND XVFBDLIBS ${XAW7LIB})
48     else()
49       list(APPEND Missing Xaw7)
50     endif()
51     foreach(_lb Xt XTest X11)
52       if(X11_${_lb}_LIB)
53         list(APPEND XVFBDLIBS ${X11_${_lb}_LIB})
54       else()
55         list(APPEND Missing ${_lb})
56       endif()
57     endforeach()
58   endif()
59
60   if(Missing)
61     message(STATUS "Missing Libraries or programms to create xvkbd: ${Missing}")
62     message(STATUS "cmake build is therefore omiting autotests")
63   endif()
64
65   if(NOT Missing)
66     project(autotests)
67
68     add_subdirectory(xvkbd)
69
70     set(KEYTEST "${CMAKE_CURRENT_SOURCE_DIR}/keytest.py")
71     set(LYX_HOME "out-home")
72     set(LYX_USERDIR "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}/.lyx")
73     set(LOCALE_DIR "${CMAKE_CURRENT_BINARY_DIR}/locale") 
74     file(GLOB TESTST RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.txt")
75     file(GLOB TESTSS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.sh")
76     list(REMOVE_ITEM TESTST hello-world-in.txt first-time-in.txt)
77     list(SORT TESTST)
78     file(MAKE_DIRECTORY "${LYX_USERDIR}" "${LOCALE_DIR}")
79
80     foreach(_tf first-time-in.txt hello-world-in.txt ${TESTST})
81       string(REGEX REPLACE "-in\\.(txt|sh)" "" _t ${_tf})
82       add_test(NAME autotests/${_t}
83         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
84         COMMAND ${CMAKE_COMMAND}
85         -DAUTOTEST_ROOT=${TOP_SRC_DIR}/development/autotests
86         -DPO_BUILD_DIR=${TOP_BINARY_DIR}/po
87         -DKEYTEST_INFILE=${_tf}
88         -DBINDIR=$<TARGET_FILE_DIR:${_lyx}>
89         -DLYX=${_lyx}
90         -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
91         -DKEYTEST_OUTFILE=${_t}-out.txt
92         -DPACKAGE=${PACKAGE}
93         -DLOCALE_DIR=${LOCALE_DIR}
94         -P ${TOP_SRC_DIR}/development/autotests/single-test.cmake)
95     endforeach()
96   endif()
97 endif()
98
99 macro(getoutputformats filepath varname)
100   file(STRINGS "${filepath}" lines)
101   set(${varname} "pdf") # try at least this one
102   foreach(_l ${lines})
103     if(_l MATCHES "^\\\\default_output_format +\([^ ]+\)")
104       if(CMAKE_MATCH_1 STREQUAL "default")
105         set(found "xhtml" "pdf" "pdf2" "pdf5")
106       elseif(CMAKE_MATCH_1 STREQUAL "xhtml")
107         set(found "xhtml")
108       else()
109         set(found "xhtml" ${CMAKE_MATCH_1})
110       endif()
111       set(${varname} ${found})
112       break()
113     endif()
114   endforeach()
115 endmacro()
116
117 foreach(libsubfolder doc examples templates)
118   set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/lib/${libsubfolder}")
119   file(GLOB_RECURSE lyx_files RELATIVE "${LIBSUB_SRC_DIR}" "${LIBSUB_SRC_DIR}/*.lyx")
120   list(SORT lyx_files)
121   # Now create 2 lists. One for files in a language dir, one without
122   set(lang_lyx_files)
123   set(nolang_lyx_files)
124   foreach(f ${lyx_files})
125     string(REGEX MATCHALL "^[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${f})
126     if(_v)
127       list(APPEND lang_lyx_files ${f})
128     else()
129       list(APPEND nolang_lyx_files ${f})
130     endif()
131   endforeach()
132   foreach(f ${nolang_lyx_files} ${lang_lyx_files})
133     # Strip extension
134     string(REGEX REPLACE "\\.lyx$" "" f ${f})
135     add_test(NAME export/${libsubfolder}/${f}_lyx16
136       WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
137       COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
138           -Dlyx=$<TARGET_FILE:${_lyx}>
139           -Dformat=lyx16x
140           -Dextension=16.lyx
141           -Dfile=${f}
142           -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
143     getoutputformats("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
144     foreach(format ${formatlist})
145       add_test(NAME export/${libsubfolder}/${f}_${format}
146         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
147         COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
148             -Dlyx=$<TARGET_FILE:${_lyx}>
149             -Dformat=${format}
150             -Dextension=${format}
151             -Dfile=${f}
152             -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
153     endforeach()
154   endforeach()
155 endforeach()
156
157