1 # This file is part of LyX, the document processor.
2 # Licence details can be found in the file COPYING.
4 # Copyright (c) 2012 Kornel Benko kornel@lyx.org
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}")
14 # Make sure, the needed programs are in PATH
15 find_program(PCREGREP_EXE "pcregrep")
17 list(APPEND Missing "pcregrep")
19 find_program(WMCTRL_EXE "wmctrl")
21 list(APPEND Missing "wmctrl")
23 # This is needed to build xvkbd
24 # Programs pcregrep wmctrl and xvkbd are used in subsequent scripts
27 # Check for needed libraries for xvkbd
28 # do not add autotests, if any of them is lacking
32 list(APPEND Missing "X11")
34 find_package(PkgConfig)
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})
41 list(APPEND Missing ${_lb})
45 foreach(_lb "Xaw7" "Xmu")
46 find_library(${_lb}LIB ${_lb})
48 list(APPEND XVFBDLIBS ${${_lb}LIB})
50 list(APPEND Missing ${_lb})
53 foreach(_lb Xt XTest X11)
55 list(APPEND XVFBDLIBS ${X11_${_lb}_LIB})
57 list(APPEND Missing ${_lb})
62 list(REMOVE_DUPLICATES XVFBDLIBS)
66 message(STATUS "Missing Libraries or programs to create xvkbd: ${Missing}")
67 message(STATUS "cmake build is therefore omitting keytests")
73 add_subdirectory(xvkbd)
75 set(KEYTEST "${CMAKE_CURRENT_SOURCE_DIR}/keytest.py")
76 file(GLOB TESTST RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.txt")
77 file(GLOB TESTSS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.sh")
78 list(REMOVE_ITEM TESTST hello-world-in.txt first-time-in.txt)
81 foreach(_tf first-time-in.txt hello-world-in.txt ${TESTST})
82 string(REGEX REPLACE "-in\\.(txt|sh)" "" _t ${_tf})
83 add_test(NAME keytest/${_t}
84 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
85 COMMAND ${CMAKE_COMMAND}
86 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
87 -DAUTOTEST_ROOT=${TOP_SRC_DIR}/development/autotests
88 -DPO_BUILD_DIR=${TOP_BINARY_DIR}/po
89 -DKEYTEST_INFILE=${_tf}
90 -DBINDIR=$<TARGET_FILE_DIR:${_lyx}>
92 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
93 -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
94 -DKEYTEST_OUTFILE=${_t}-out.txt
96 -DLOCALE_DIR=${LOCALE_DIR}
97 -P ${TOP_SRC_DIR}/development/autotests/single-test.cmake)
98 settestlabel(keytest/${_t} "key")
99 set_tests_properties(keytest/${_t} PROPERTIES RUN_SERIAL ON)
104 macro(getoutputformats filepath varname)
105 file(STRINGS "${filepath}" lines)
106 set(out_formats "xhtml" "pdf" "pdf2" "pdf5")
107 set(${varname} ${out_formats})
109 if(_l MATCHES "^\\\\default_output_format +\([^ ]+\)")
110 if(CMAKE_MATCH_1 STREQUAL "default")
111 set(found ${out_formats})
112 elseif(CMAKE_MATCH_1 STREQUAL "xhtml")
115 set(found "xhtml" ${CMAKE_MATCH_1})
117 set(${varname} ${found})
123 macro(maketestname testname reverted listreverted listignored)
124 list(FIND ${listignored} ${${testname}} _idx)
126 list(FIND ${listreverted} ${${testname}} _idx)
131 set(${testname} "INVERTED_SEE-README.ctest_${${testname}}")
138 macro(loadTestList filename resList)
139 # Create list of strings from a file without comments
140 file(STRINGS ${filename} tempList)
142 foreach(_l ${tempList})
143 string(REGEX REPLACE "[ \t]*#.*" "" _newl "${_l}")
145 list(APPEND ${resList} "${_newl}")
150 loadTestList(revertedTests revertedTests)
151 loadTestList(ignoredTests ignoredTests)
153 foreach(libsubfolder doc examples templates)
154 set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/lib/${libsubfolder}")
155 file(GLOB_RECURSE lyx_files RELATIVE "${LIBSUB_SRC_DIR}" "${LIBSUB_SRC_DIR}/*.lyx")
157 # Now create 2 lists. One for files in a language dir, one without
159 set(nolang_lyx_files)
160 foreach(f ${lyx_files})
161 string(REGEX MATCHALL "^[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${f})
163 list(APPEND lang_lyx_files ${f})
165 list(APPEND nolang_lyx_files ${f})
168 foreach(f ${nolang_lyx_files} ${lang_lyx_files})
170 string(REGEX REPLACE "\\.lyx$" "" f ${f})
171 set(TestName "export/${libsubfolder}/${f}_lyx16")
172 maketestname(TestName reverted revertedTests ignoredTests)
174 add_test(NAME ${TestName}
175 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
176 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
177 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
178 -Dlyx=$<TARGET_FILE:${_lyx}>
179 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
180 -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
184 -Dreverted=${reverted}
185 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
186 setmarkedtestlabel(${TestName} ${reverted} "export")
188 set(TestName "lyx2lyx/${libsubfolder}/${f}")
189 maketestname(TestName reverted revertedTests ignoredTests)
191 add_test(NAME ${TestName}
192 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
193 COMMAND ${CMAKE_COMMAND} -DLYX2LYX=${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx
194 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
195 -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
196 -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake")
197 setmarkedtestlabel(${TestName} ${reverted} "export")
199 set(TestName "check_load/${libsubfolder}/${f}")
200 maketestname(TestName reverted revertedTests ignoredTests)
202 add_test(NAME ${TestName}
203 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
204 COMMAND ${CMAKE_COMMAND} -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
205 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
206 -Dlyx=$<TARGET_FILE:${_lyx}>
207 -DPARAMS_DIR=${TOP_SRC_DIR}/development/autotests
208 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
209 -P "${TOP_SRC_DIR}/development/autotests/check_load.cmake")
210 setmarkedtestlabel(${TestName} ${reverted} "load")
212 getoutputformats("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
213 foreach(format ${formatlist})
214 set(TestName "export/${libsubfolder}/${f}_${format}")
215 maketestname(TestName reverted revertedTests ignoredTests)
217 add_test(NAME ${TestName}
218 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
219 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
220 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
221 -Dlyx=$<TARGET_FILE:${_lyx}>
222 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
224 -Dextension=${format}
226 -Dreverted=${reverted}
227 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
228 setmarkedtestlabel(${TestName} ${reverted} "export")