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)
68 foreach(_itrx ${${listname}})
69 set(_itr "^${_itrx}$")
70 if(${testname} MATCHES ${_itr})
75 set(${found} ${_found})
78 macro(maketestname testname reverted listreverted listignored listnonstandard)
79 string(REGEX MATCH "\\/[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${${testname}})
81 string(REGEX REPLACE "\\/" "" _v ${_v})
82 set(listrevertedx ${listreverted}_${_v})
83 set(listignoredx ${listignored}_${_v})
84 set(listnonstandardx ${listnonstandard}_${_v})
86 set(listrevertedx ${listreverted})
87 set(listignoredx ${listignored})
88 set(listnonstandardx ${listnonstandard})
90 findexpr(mfound ${testname} ${listignoredx})
92 # check if they are non-standard
93 findexpr(nsfound ${testname} ${listnonstandardx})
95 set(${testname} "NON_STANDARD.${${testname}}")
97 string(REGEX MATCH "_(systemF|texF|pdf3|pdf2|pdf|dvi|lyx16|xhtml)$" _v ${${testname}})
98 # check if test _may_ be in listreverted
100 findexpr(mfound ${testname} ${listrevertedx})
108 set(${testname} "INVERTED_SEE-README.ctest_${${testname}}")
116 macro(loadTestList filename resList)
117 # Create list of strings from a file without comments
118 file(STRINGS ${filename} tempList)
120 foreach(_l ${tempList})
121 string(REGEX REPLACE "[ \t]*#.*" "" _newl "${_l}")
123 #message(STATUS "Testing ${_newl}")
124 string(REGEX REPLACE "(\\/|\\||\\(|\\))" " " _vxx ${_newl})
125 string(REGEX MATCHALL " ([a-z][a-z](_[A-Z][A-Z])?) " _vx ${_vxx})
128 string(REGEX REPLACE " " "" _v ${_v})
129 #message(STATUS " ==> ${resList}_${_v}")
130 list(APPEND ${resList}_${_v} "${_newl}")
132 if(_newl MATCHES "\\(\\|")
133 #message(STATUS " ==> ${resList}")
134 list(APPEND ${resList} "${_newl}")
137 #message(STATUS " ==> ${resList}")
138 list(APPEND ${resList} "${_newl}")
144 loadTestList(revertedTests revertedTests)
145 loadTestList(ignoredTests ignoredTests)
146 loadTestList(suspendedTests suspendedTests)
147 loadTestList(nonstandardTests nonstandardTests)
149 macro(handlesuspended TestName reverted testlabel)
150 set(mylabel ${${testlabel}})
151 set(myreverted ${reverted})
153 # check for nonstandard
154 if ("${TestName}" MATCHES "^NON_STANDARD")
155 set(mylabel "nonstandard")
158 # check suspension only for reverted tests
159 findexpr(tfound TestName suspendedTests)
161 set(mylabel "suspended")
162 set(myreverted 0) # if test is to be suspended, remove the 'reverted' flag
165 setmarkedtestlabel(${TestName} ${myreverted} ${mylabel})
168 # preparing to add e.g. development/mathmacros to the foreach() loop
169 foreach(libsubfolderx lib/doc lib/examples lib/templates development/mathmacros)
170 set(testlabel "export")
171 if (libsubfolderx MATCHES "lib/doc")
172 list(APPEND testlabel "manuals")
173 elseif (libsubfolderx MATCHES "lib/examples")
174 list(APPEND testlabel "examples")
175 elseif (libsubfolderx MATCHES "lib/templates")
176 list(APPEND testlabel "templates")
177 elseif (libsubfolderx MATCHES "development/mathmacros")
178 list(APPEND testlabel "mathmacros")
179 elseif (libsubfolderx MATCHES "autotests/.+")
180 list(APPEND testlabel "autotests")
182 set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/${libsubfolderx}")
183 string(REGEX REPLACE "^(lib|development|autotests)/" "" libsubfolder "${libsubfolderx}")
184 set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/${libsubfolderx}")
185 message(STATUS "Handling export dir ${LIBSUB_SRC_DIR}")
186 file(GLOB_RECURSE lyx_files RELATIVE "${LIBSUB_SRC_DIR}" "${LIBSUB_SRC_DIR}/*.lyx")
188 # Now create 2 lists. One for files in a language dir, one without
190 set(nolang_lyx_files)
191 foreach(f ${lyx_files})
192 string(REGEX MATCHALL "^[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${f})
194 list(APPEND lang_lyx_files ${f})
196 list(APPEND nolang_lyx_files ${f})
199 foreach(f ${nolang_lyx_files} ${lang_lyx_files})
201 string(REGEX REPLACE "\\.lyx$" "" f ${f})
202 set(TestName "export/${libsubfolder}/${f}_lyx16")
203 maketestname(TestName reverted revertedTests ignoredTests nonstandardTests)
205 add_test(NAME ${TestName}
206 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
207 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
208 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
209 -Dlyx=$<TARGET_FILE:${_lyx}>
210 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
211 -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
215 -Dreverted=${reverted}
216 -DTOP_SRC_DIR=${TOP_SRC_DIR}
217 -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
218 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
219 handlesuspended(${TestName} ${reverted} testlabel) # checking for suspended lyx16 exports
221 if(LYX_PYTHON_EXECUTABLE)
222 set(lyx2lyxtestlabel "lyx2lyx")
223 # For use of lyx2lyx we need the python executable
224 set(TestName "lyx2lyx/${libsubfolder}/${f}")
225 maketestname(TestName reverted revertedTests ignoredTests nonstandardTests)
227 add_test(NAME ${TestName}
228 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
229 COMMAND ${CMAKE_COMMAND}
230 "-DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}"
231 "-DLYX2LYX=${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx"
232 "-DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}"
233 "-DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx"
234 -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake")
235 handlesuspended(${TestName} ${reverted} lyx2lyxtestlabel)
238 set(TestName "check_load/${libsubfolder}/${f}")
239 maketestname(TestName reverted revertedTests ignoredTests nonstandardTests)
241 set(loadtestlabel "load")
242 add_test(NAME ${TestName}
243 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
244 COMMAND ${CMAKE_COMMAND} -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
245 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
246 -Dlyx=$<TARGET_FILE:${_lyx}>
247 -DPARAMS_DIR=${TOP_SRC_DIR}/development/autotests
248 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
249 -P "${TOP_SRC_DIR}/development/autotests/check_load.cmake")
250 handlesuspended(${TestName} ${reverted} loadtestlabel)
251 set_tests_properties(${TestName} PROPERTIES RUN_SERIAL ON)
253 getoutputformats("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
254 foreach(format ${formatlist})
255 if(format MATCHES "dvi3|pdf4|pdf5")
256 set(fonttypes "texF" "systemF")
258 set(fonttypes "defaultF")
260 foreach(fonttype ${fonttypes})
261 if(fonttype MATCHES "defaultF")
262 set(TestName "export/${libsubfolder}/${f}_${format}")
264 set(TestName "export/${libsubfolder}/${f}_${format}_${fonttype}")
266 maketestname(TestName reverted revertedTests ignoredTests nonstandardTests)
268 add_test(NAME ${TestName}
269 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
270 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
271 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
272 -Dlyx=$<TARGET_FILE:${_lyx}>
273 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
275 -Dfonttype=${fonttype}
276 -Dextension=${format}
278 -Dreverted=${reverted}
279 -DTOP_SRC_DIR=${TOP_SRC_DIR}
280 -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
281 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
282 handlesuspended(${TestName} ${reverted} testlabel) # check for suspended pdf/dvi exports