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}")
73 set(_itr "^${_itrx}$")
74 if (${testname} MATCHES "${_itr}")
81 if (NOT "${sublabel}" STREQUAL "")
82 set(${rsublabel} ${sublabel})
85 set(${found} ${_found})
88 macro(maketestname testname reverted listreverted listignored listunreliable listlabels)
90 string(REGEX MATCH "\\/[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${${testname}})
92 string(REGEX REPLACE "\\/" "" _v ${_v})
93 set(listrevertedx ${listreverted}_${_v})
94 set(listignoredx ${listignored}_${_v})
95 set(listunreliablex ${listunreliable}_${_v})
97 set(listrevertedx ${listreverted})
98 set(listignoredx ${listignored})
99 set(listunreliablex ${listunreliable})
101 findexpr(mfound ${testname} ${listignoredx} sublabel)
103 # check if they are unreliable
105 findexpr(nsfound ${testname} ${listunreliablex} sublabel)
107 if (NOT "${sublabel}" STREQUAL "")
108 list(APPEND ${listlabels} ${sublabel})
109 string(TOUPPER "${sublabel}_" tmpprefix)
113 set(${testname} "UNRELIABLE.${tmpprefix}${${testname}}")
115 string(REGEX MATCH "_(systemF|texF|pdf3|pdf2|pdf|dvi|lyx16|xhtml)$" _v ${${testname}})
117 # check if test _may_ be in listreverted
119 findexpr(mfound ${testname} ${listrevertedx} sublabel)
127 set(${testname} "INVERTED_SEE-README.ctest_${${testname}}")
128 if (NOT sublabel STREQUAL "")
129 list(APPEND ${listlabels} ${sublabel})
138 macro(loadTestList filename resList)
139 # Create list of strings from a file without comments
140 file(STRINGS ${filename} tempList ENCODING "UTF-8")
143 foreach(_l ${tempList})
145 string(REGEX REPLACE "[ \t]*#.*$" "" _newl "${_l}")
147 string(REGEX REPLACE "(\\/|\\||\\(|\\))" " " _vxx ${_newl})
148 string(REGEX MATCHALL " ([a-z][a-z](_[A-Z][A-Z])?) " _vx ${_vxx})
149 if (_newl MATCHES "^Sublabel:")
150 set(sublabel ${_newl})
154 string(REGEX REPLACE " " "" _v ${_v})
155 #message(STATUS " ==> ${resList}_${_v}")
156 if (NOT ${sublabel} STREQUAL "${sublabel}_${_v}")
157 list(APPEND ${resList}_${_v} "${sublabel}")
158 set(${sublabel}_${_v} "${sublabel}")
160 list(APPEND ${resList}_${_v} "${_newl}")
162 if(_newl MATCHES "\\(\\|")
163 #message(STATUS " ==> ${resList}")
164 list(APPEND ${resList} "${_newl}")
167 #message(STATUS " ==> ${resList}")
168 list(APPEND ${resList} "${_newl}")
174 loadTestList(revertedTests revertedTests)
175 loadTestList(ignoredTests ignoredTests)
176 loadTestList(suspendedTests suspendedTests)
177 loadTestList(unreliableTests unreliableTests)
179 macro(handlesuspended TestName reverted testlabel)
180 set(mylabel ${${testlabel}})
181 set(myreverted ${reverted})
184 # check for unreliable
185 if ("${TestName}" MATCHES "^UNRELIABLE")
186 list(REMOVE_ITEM mylabel "export" "reverted" "templates" "mathmacros" "manuals")
187 list(APPEND mylabel "unreliable")
190 # check suspension only for reverted tests
191 findexpr(tfound TestName suspendedTests sublabel)
193 set(mylabel "suspended")
195 list(APPEND mylabel ${sublabel})
197 set(myreverted 0) # if test is to be suspended, remove the 'reverted' flag
200 setmarkedtestlabel(${TestName} ${myreverted} ${mylabel})
203 # preparing to add e.g. development/mathmacros to the foreach() loop
204 foreach(libsubfolderx lib/doc lib/examples lib/templates development/mathmacros autotests/export)
205 set(testlabel "export")
206 if (libsubfolderx MATCHES "lib/doc")
207 list(APPEND testlabel "manuals")
208 elseif (libsubfolderx MATCHES "lib/examples")
209 list(APPEND testlabel "examples")
210 elseif (libsubfolderx MATCHES "lib/templates")
211 list(APPEND testlabel "templates")
212 elseif (libsubfolderx MATCHES "development/mathmacros")
213 list(APPEND testlabel "mathmacros")
214 elseif (libsubfolderx MATCHES "autotests/.+")
215 list(APPEND testlabel "autotests")
217 set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/${libsubfolderx}")
218 string(REGEX REPLACE "^(lib|development|autotests)/" "" libsubfolder "${libsubfolderx}")
219 set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/${libsubfolderx}")
220 message(STATUS "Handling export dir ${LIBSUB_SRC_DIR}")
221 file(GLOB_RECURSE lyx_files RELATIVE "${LIBSUB_SRC_DIR}" "${LIBSUB_SRC_DIR}/*.lyx")
223 # Now create 2 lists. One for files in a language dir, one without
225 set(nolang_lyx_files)
226 foreach(f ${lyx_files})
227 string(REGEX MATCHALL "^[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${f})
229 list(APPEND lang_lyx_files ${f})
231 list(APPEND nolang_lyx_files ${f})
234 foreach(f ${nolang_lyx_files} ${lang_lyx_files})
236 string(REGEX REPLACE "\\.lyx$" "" f ${f})
237 set(TestName "export/${libsubfolder}/${f}_lyx16")
238 set(mytestlabel ${testlabel})
239 maketestname(TestName reverted revertedTests ignoredTests unreliableTests mytestlabel)
241 add_test(NAME ${TestName}
242 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
243 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
244 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
245 -Dlyx=$<TARGET_FILE:${_lyx}>
246 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
247 -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
251 -Dreverted=${reverted}
252 -DTOP_SRC_DIR=${TOP_SRC_DIR}
253 -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
254 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
255 handlesuspended(${TestName} ${reverted} mytestlabel) # checking for suspended lyx16 exports
257 if(LYX_PYTHON_EXECUTABLE)
258 set(lyx2lyxtestlabel "lyx2lyx")
259 # For use of lyx2lyx we need the python executable
260 set(mytestlabel ${lyx2lyxtestlabel})
261 set(TestName "lyx2lyx/${libsubfolder}/${f}")
262 maketestname(TestName reverted revertedTests ignoredTests unreliableTests mytestlabel)
264 add_test(NAME ${TestName}
265 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
266 COMMAND ${CMAKE_COMMAND}
267 "-DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}"
268 "-DLYX2LYX=${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx"
269 "-DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}"
270 "-DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx"
271 -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake")
272 handlesuspended(${TestName} ${reverted} mytestlabel)
275 set(loadtestlabel "load")
276 set(mytestlabel ${loadtestlabel})
277 set(TestName "check_load/${libsubfolder}/${f}")
278 maketestname(TestName reverted revertedTests ignoredTests unreliableTests mytestlabel)
280 add_test(NAME ${TestName}
281 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
282 COMMAND ${CMAKE_COMMAND} -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
283 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
284 -Dlyx=$<TARGET_FILE:${_lyx}>
285 -DPARAMS_DIR=${TOP_SRC_DIR}/development/autotests
286 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
287 -P "${TOP_SRC_DIR}/development/autotests/check_load.cmake")
288 handlesuspended(${TestName} ${reverted} mytestlabel)
289 set_tests_properties(${TestName} PROPERTIES RUN_SERIAL ON)
291 getoutputformats("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
292 foreach(format ${formatlist})
293 if(format MATCHES "dvi3|pdf4|pdf5")
294 set(fonttypes "texF" "systemF")
296 set(fonttypes "defaultF")
298 foreach(fonttype ${fonttypes})
299 if(fonttype MATCHES "defaultF")
300 set(TestName "export/${libsubfolder}/${f}_${format}")
302 set(TestName "export/${libsubfolder}/${f}_${format}_${fonttype}")
304 set(mytestlabel ${testlabel})
305 maketestname(TestName reverted revertedTests ignoredTests unreliableTests mytestlabel)
307 add_test(NAME ${TestName}
308 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
309 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
310 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
311 -Dlyx=$<TARGET_FILE:${_lyx}>
312 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
314 -Dfonttype=${fonttype}
315 -Dextension=${format}
317 -Dreverted=${reverted}
318 -DTOP_SRC_DIR=${TOP_SRC_DIR}
319 -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
320 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
321 handlesuspended(${TestName} ${reverted} mytestlabel) # check for suspended pdf/dvi exports