2 # Copyright (c) 2014 Kornel Benko <kornel@lyx.org>
3 # Copyright (c) 2014 Scott Kostyshak <skotysh@lyx.org>
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # 3. The name of the author may not be used to endorse or promote products
15 # derived from this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 set(DVI_FORMATS "dvi" "dvi3")
33 set(PDF_FORMATS "pdf" "pdf2" "pdf3" "pdf4" "pdf5")
35 set(DVI_FORMATS "dvi")
36 set(PDF_FORMATS "pdf" "pdf2" "pdf3")
39 macro(getoutputformats filepath varname)
40 file(STRINGS "${filepath}" lines)
41 # What should we test, if default_output_format is not defined?
42 # For now we test everything ...
43 set(out_formats "xhtml" ${DVI_FORMATS} ${PDF_FORMATS})
45 if(_l MATCHES "^\\\\default_output_format +\([^ ]+\)")
46 set(_format ${CMAKE_MATCH_1})
47 if(_format STREQUAL "default")
48 set(out_formats "xhtml" ${DVI_FORMATS} ${PDF_FORMATS})
49 elseif(_format MATCHES "pdf$")
50 set(out_formats "xhtml" ${PDF_FORMATS})
51 elseif(_format MATCHES "dvi$")
52 set(out_formats "xhtml" ${DVI_FORMATS})
53 elseif(_format MATCHES "xhtml")
54 set(out_formats "xhtml")
56 # Respect all other output formats
58 set(out_formats "xhtml" ${_format})
63 set(${varname} ${out_formats})
66 macro(findexpr found testname listname rsublabel)
69 foreach(_itrx ${${listname}})
70 if ("${_itrx}" MATCHES "^Sublabel:[ \t]*\([a-z]+\)[ \t]*$")
71 set(sublabel "${CMAKE_MATCH_1}")
72 if (sublabel STREQUAL "RESET")
76 set(_itr "^${_itrx}$")
77 if (${testname} MATCHES "${_itr}")
84 if (NOT "${sublabel}" STREQUAL "")
85 set(${rsublabel} ${sublabel})
88 set(${found} ${_found})
91 macro(maketestname testname reverted listreverted listignored listunreliable listlabels)
93 string(REGEX MATCH "\\/[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${${testname}})
95 string(REGEX REPLACE "\\/" "" _v ${_v})
96 set(listrevertedx ${listreverted}_${_v})
97 set(listignoredx ${listignored}_${_v})
98 set(listunreliablex ${listunreliable}_${_v})
100 set(listrevertedx ${listreverted})
101 set(listignoredx ${listignored})
102 set(listunreliablex ${listunreliable})
104 findexpr(mfound ${testname} ${listignoredx} sublabel)
106 # check if they are unreliable
108 findexpr(nsfound ${testname} ${listunreliablex} sublabel)
110 if (NOT "${sublabel}" STREQUAL "")
111 list(APPEND ${listlabels} ${sublabel})
112 string(TOUPPER "${sublabel}_" tmpprefix)
116 set(${testname} "UNRELIABLE.${tmpprefix}${${testname}}")
118 string(REGEX MATCH "_(systemF|texF|pdf3|pdf2|pdf|dvi|lyx16|xhtml)$" _v ${${testname}})
120 # check if test _may_ be in listreverted
122 findexpr(mfound ${testname} ${listrevertedx} sublabel)
130 if (NOT sublabel STREQUAL "")
131 string(TOUPPER "${sublabel}_" tmpprefix)
133 set(tmpprefix "ctest_")
135 set(${testname} "INVERTED_SEE-README.${tmpprefix}${${testname}}")
136 if (NOT sublabel STREQUAL "")
137 list(APPEND ${listlabels} ${sublabel})
146 macro(loadTestList filename resList)
147 # Create list of strings from a file without comments
148 file(STRINGS ${filename} tempList ENCODING "UTF-8")
151 foreach(_l ${tempList})
153 string(REGEX REPLACE "[ \t]*#.*$" "" _newl "${_l}")
155 string(REGEX REPLACE "(\\/|\\||\\(|\\))" " " _vxx ${_newl})
156 string(REGEX MATCHALL " ([a-z][a-z](_[A-Z][A-Z])?) " _vx ${_vxx})
157 if (_newl MATCHES "^Sublabel:")
158 set(sublabel ${_newl})
162 string(REGEX REPLACE " " "" _v ${_v})
163 #message(STATUS " ==> ${resList}_${_v}")
164 if (NOT ${sublabel} STREQUAL "${sublabel}_${_v}")
165 list(APPEND ${resList}_${_v} "${sublabel}")
166 set(${sublabel}_${_v} "${sublabel}")
168 list(APPEND ${resList}_${_v} "${_newl}")
170 if(_newl MATCHES "\\(\\|")
171 #message(STATUS " ==> ${resList}")
172 list(APPEND ${resList} "${_newl}")
175 #message(STATUS " ==> ${resList}")
176 list(APPEND ${resList} "${_newl}")
182 loadTestList(revertedTests revertedTests)
183 loadTestList(ignoredTests ignoredTests)
184 loadTestList(suspendedTests suspendedTests)
185 loadTestList(unreliableTests unreliableTests)
187 macro(handlesuspended TestName reverted testlabel)
188 set(mylabel ${${testlabel}})
189 set(myreverted ${reverted})
192 # check for unreliable
193 if ("${TestName}" MATCHES "^UNRELIABLE")
194 list(REMOVE_ITEM mylabel "export" "reverted" "templates" "mathmacros" "manuals")
195 list(APPEND mylabel "unreliable")
198 # check suspension only for reverted tests
199 findexpr(tfound TestName suspendedTests sublabel)
201 set(mylabel "suspended")
203 list(APPEND mylabel ${sublabel})
205 set(myreverted 0) # if test is to be suspended, remove the 'reverted' flag
208 setmarkedtestlabel(${TestName} ${myreverted} ${mylabel})
211 # preparing to add e.g. development/mathmacros to the foreach() loop
212 foreach(libsubfolderx lib/doc lib/examples lib/templates development/mathmacros autotests/export)
213 set(testlabel "export")
214 if (libsubfolderx MATCHES "lib/doc")
215 list(APPEND testlabel "manuals")
216 elseif (libsubfolderx MATCHES "lib/examples")
217 list(APPEND testlabel "examples")
218 elseif (libsubfolderx MATCHES "lib/templates")
219 list(APPEND testlabel "templates")
220 elseif (libsubfolderx MATCHES "development/mathmacros")
221 list(APPEND testlabel "mathmacros")
222 elseif (libsubfolderx MATCHES "autotests/.+")
223 list(APPEND testlabel "autotests")
225 set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/${libsubfolderx}")
226 string(REGEX REPLACE "^(lib|development|autotests)/" "" libsubfolder "${libsubfolderx}")
227 set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/${libsubfolderx}")
228 message(STATUS "Handling export dir ${LIBSUB_SRC_DIR}")
229 file(GLOB_RECURSE lyx_files RELATIVE "${LIBSUB_SRC_DIR}" "${LIBSUB_SRC_DIR}/*.lyx")
231 # Now create 2 lists. One for files in a language dir, one without
233 set(nolang_lyx_files)
234 foreach(f ${lyx_files})
235 string(REGEX MATCHALL "^[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${f})
237 list(APPEND lang_lyx_files ${f})
239 list(APPEND nolang_lyx_files ${f})
242 foreach(f ${nolang_lyx_files} ${lang_lyx_files})
244 string(REGEX REPLACE "\\.lyx$" "" f ${f})
245 set(TestName "export/${libsubfolder}/${f}_lyx16")
246 set(mytestlabel ${testlabel})
247 maketestname(TestName reverted revertedTests ignoredTests unreliableTests mytestlabel)
249 add_test(NAME ${TestName}
250 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
251 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
252 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
253 -Dlyx=$<TARGET_FILE:${_lyx}>
254 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
255 -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
259 -Dreverted=${reverted}
260 -DTOP_SRC_DIR=${TOP_SRC_DIR}
261 -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
262 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
263 handlesuspended(${TestName} ${reverted} mytestlabel) # checking for suspended lyx16 exports
265 if(LYX_PYTHON_EXECUTABLE)
266 set(lyx2lyxtestlabel "lyx2lyx")
267 # For use of lyx2lyx we need the python executable
268 set(mytestlabel ${lyx2lyxtestlabel})
269 set(TestName "lyx2lyx/${libsubfolder}/${f}")
270 maketestname(TestName reverted revertedTests ignoredTests unreliableTests mytestlabel)
272 add_test(NAME ${TestName}
273 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
274 COMMAND ${CMAKE_COMMAND}
275 "-DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}"
276 "-DLYX2LYX=${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx"
277 "-DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}"
278 "-DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx"
279 -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake")
280 handlesuspended(${TestName} ${reverted} mytestlabel)
283 set(loadtestlabel "load")
284 set(mytestlabel ${loadtestlabel})
285 set(TestName "check_load/${libsubfolder}/${f}")
286 maketestname(TestName reverted revertedTests ignoredTests unreliableTests mytestlabel)
288 add_test(NAME ${TestName}
289 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
290 COMMAND ${CMAKE_COMMAND} -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
291 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
292 -Dlyx=$<TARGET_FILE:${_lyx}>
293 -DPARAMS_DIR=${TOP_SRC_DIR}/development/autotests
294 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
295 -P "${TOP_SRC_DIR}/development/autotests/check_load.cmake")
296 handlesuspended(${TestName} ${reverted} mytestlabel)
297 set_tests_properties(${TestName} PROPERTIES RUN_SERIAL ON)
299 getoutputformats("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
300 foreach(format ${formatlist})
301 if(format MATCHES "dvi3|pdf4|pdf5")
302 set(fonttypes "texF" "systemF")
304 set(fonttypes "defaultF")
306 foreach(fonttype ${fonttypes})
307 if(fonttype MATCHES "defaultF")
308 set(TestName "export/${libsubfolder}/${f}_${format}")
310 set(TestName "export/${libsubfolder}/${f}_${format}_${fonttype}")
312 set(mytestlabel ${testlabel})
313 maketestname(TestName reverted revertedTests ignoredTests unreliableTests mytestlabel)
315 add_test(NAME ${TestName}
316 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
317 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
318 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
319 -Dlyx=$<TARGET_FILE:${_lyx}>
320 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
322 -Dfonttype=${fonttype}
323 -Dextension=${format}
325 -Dreverted=${reverted}
326 -DTOP_SRC_DIR=${TOP_SRC_DIR}
327 -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
328 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
329 handlesuspended(${TestName} ${reverted} mytestlabel) # check for suspended pdf/dvi exports