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)
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 #message(STATUS "${listreverted} ==> ${listrevertedx}")
84 set(listignoredx ${listignored}_${_v})
85 #message(STATUS "${listignored} ==> ${listignoredx}")
87 set(listrevertedx ${listreverted})
88 set(listignoredx ${listignored})
90 findexpr(mfound ${testname} ${listignoredx})
92 # check if test _may_ be in listreverted
93 string(REGEX MATCH "_(systemF|texF|pdf3|pdf2|pdf|dvi)$" _v ${${testname}})
95 findexpr(mfound ${testname} ${listrevertedx})
103 set(${testname} "INVERTED_SEE-README.ctest_${${testname}}")
110 macro(loadTestList filename resList)
111 # Create list of strings from a file without comments
112 file(STRINGS ${filename} tempList)
114 foreach(_l ${tempList})
115 string(REGEX REPLACE "[ \t]*#.*" "" _newl "${_l}")
117 #message(STATUS "Testing ${_newl}")
118 string(REGEX REPLACE "(\\/|\\||\\(|\\))" " " _vxx ${_newl})
119 string(REGEX MATCHALL " ([a-z][a-z](_[A-Z][A-Z])?) " _vx ${_vxx})
122 string(REGEX REPLACE " " "" _v ${_v})
123 #message(STATUS " ==> ${resList}_${_v}")
124 list(APPEND ${resList}_${_v} "${_newl}")
126 if(_newl MATCHES "\\(\\|")
127 #message(STATUS " ==> ${resList}")
128 list(APPEND ${resList} "${_newl}")
131 #message(STATUS " ==> ${resList}")
132 list(APPEND ${resList} "${_newl}")
138 loadTestList(revertedTests revertedTests)
139 loadTestList(ignoredTests ignoredTests)
141 foreach(libsubfolder doc examples templates)
142 set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/lib/${libsubfolder}")
143 file(GLOB_RECURSE lyx_files RELATIVE "${LIBSUB_SRC_DIR}" "${LIBSUB_SRC_DIR}/*.lyx")
145 # Now create 2 lists. One for files in a language dir, one without
147 set(nolang_lyx_files)
148 foreach(f ${lyx_files})
149 string(REGEX MATCHALL "^[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${f})
151 list(APPEND lang_lyx_files ${f})
153 list(APPEND nolang_lyx_files ${f})
156 foreach(f ${nolang_lyx_files} ${lang_lyx_files})
158 string(REGEX REPLACE "\\.lyx$" "" f ${f})
159 set(TestName "export/${libsubfolder}/${f}_lyx16")
160 maketestname(TestName reverted revertedTests ignoredTests)
162 add_test(NAME ${TestName}
163 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
164 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
165 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
166 -Dlyx=$<TARGET_FILE:${_lyx}>
167 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
168 -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
172 -Dreverted=${reverted}
173 -DTOP_SRC_DIR=${TOP_SRC_DIR}
174 -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
175 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
176 setmarkedtestlabel(${TestName} ${reverted} "export")
178 if(LYX_PYTHON_EXECUTABLE)
179 # For use of lyx2lyx we need the python executable
180 set(TestName "lyx2lyx/${libsubfolder}/${f}")
181 maketestname(TestName reverted revertedTests ignoredTests)
183 add_test(NAME ${TestName}
184 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
185 COMMAND ${CMAKE_COMMAND}
186 "-DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}"
187 "-DLYX2LYX=${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx"
188 "-DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}"
189 "-DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx"
190 -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake")
191 setmarkedtestlabel(${TestName} ${reverted} "lyx2lyx")
194 set(TestName "check_load/${libsubfolder}/${f}")
195 maketestname(TestName reverted revertedTests ignoredTests)
197 add_test(NAME ${TestName}
198 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
199 COMMAND ${CMAKE_COMMAND} -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
200 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
201 -Dlyx=$<TARGET_FILE:${_lyx}>
202 -DPARAMS_DIR=${TOP_SRC_DIR}/development/autotests
203 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
204 -P "${TOP_SRC_DIR}/development/autotests/check_load.cmake")
205 setmarkedtestlabel(${TestName} ${reverted} "load")
206 set_tests_properties(${TestName} PROPERTIES RUN_SERIAL ON)
208 getoutputformats("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
209 foreach(format ${formatlist})
210 if(format MATCHES "dvi3|pdf4|pdf5")
211 set(fonttypes "texF" "systemF")
213 set(fonttypes "defaultF")
215 foreach(fonttype ${fonttypes})
216 if(fonttype MATCHES "defaultF")
217 set(TestName "export/${libsubfolder}/${f}_${format}")
219 set(TestName "export/${libsubfolder}/${f}_${format}_${fonttype}")
221 maketestname(TestName reverted revertedTests ignoredTests)
223 add_test(NAME ${TestName}
224 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
225 COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
226 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
227 -Dlyx=$<TARGET_FILE:${_lyx}>
228 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
230 -Dfonttype=${fonttype}
231 -Dextension=${format}
233 -Dreverted=${reverted}
234 -DTOP_SRC_DIR=${TOP_SRC_DIR}
235 -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
236 -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
237 setmarkedtestlabel(${TestName} ${reverted} "export")