]> git.lyx.org Git - lyx.git/blob - development/autotests/ExportTests.cmake
DocBook: do a little something for Sweave & co.
[lyx.git] / development / autotests / ExportTests.cmake
1 #
2 #  Copyright (c) 2014 Kornel Benko <kornel@lyx.org>
3 #  Copyright (c) 2014 Scott Kostyshak <skotysh@lyx.org>
4 #
5 #  Redistribution and use in source and binary forms, with or without
6 #  modification, are permitted provided that the following conditions
7 #  are met:
8 #
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.
16 #
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.
27 #
28
29 find_package(Perl)
30 find_program(XMLLINT_EXECUTABLE xmllint)
31 find_program(JAVA_EXECUTABLE java)
32 set(jingjava)
33 if (JAVA_EXECUTABLE)
34   if (EXISTS "${TOP_SRC_DIR}/development/tools/jing.jar")
35     set(jingjava ${JAVA_EXECUTABLE})
36   endif()
37 endif()
38
39 if(PERL_FOUND)
40   set(DVI_FORMATS "dvi" "dvi3")
41   set(PDF_FORMATS "pdf" "pdf2" "pdf3" "pdf4" "pdf5")
42 else()
43   set(DVI_FORMATS "dvi")
44   set(PDF_FORMATS "pdf" "pdf2" "pdf3")
45 endif()
46
47 set(potential_languages "ca" "cs" "da" "de" "el" "es" "eu" "fa" "fr" "gl" "he" "hu" "id" "it" "ja" "ko" "nb" "nl" "pl" "pt" "ro" "ru" "sk" "sl" "sr" "sv" "uk" "zh_CN")
48
49 # Used to select labels from .*Tests files
50 set(label_chars "[a-zA-Z:_]+")
51
52 macro(initLangVars varname)
53   foreach(_l ${potential_languages})
54     set(${varname}_${_l})
55   endforeach()
56 endmacro()
57
58 macro(getoutputformats filepath varname format_set)
59   file(STRINGS "${filepath}" lines)
60   # What should we test, if default_output_format is not defined?
61   # For now we test everything ...
62   set(out_formats "xhtml" "docbook5" ${DVI_FORMATS} ${PDF_FORMATS})
63   foreach(_l IN LISTS lines)
64     if(_l MATCHES "^\\\\default_output_format +\([^ ]+\)")
65       set(_format ${CMAKE_MATCH_1})
66       if(_format STREQUAL "default")
67         set(out_formats "xhtml" "docbook5" ${DVI_FORMATS} ${PDF_FORMATS})
68       else()
69         set(${format_set} ${_format})
70         if(_format STREQUAL "pdf2" AND "${filepath}" MATCHES "/doc/")
71           set(out_formats "xhtml" "docbook5" ${DVI_FORMATS} ${PDF_FORMATS})
72         elseif(_format MATCHES "pdf$")
73           set(out_formats "xhtml" "docbook5" ${PDF_FORMATS})
74         elseif(_format MATCHES "dvi$")
75           set(out_formats "xhtml" "docbook5" ${DVI_FORMATS})
76         elseif(_format MATCHES "docbook5")
77           set(out_formats "docbook5")
78         elseif(_format MATCHES "xhtml")
79           set(out_formats "xhtml")
80         else()
81           # Respect all other output formats
82           # like "eps3"
83           set(out_formats "xhtml" ${_format})
84         endif()
85       endif()
86       break()
87     endif()
88   endforeach()
89   set(${varname} ${out_formats})
90 endmacro()
91
92 macro(findexpr found testname listname rsublabel)
93   set(_found 0)
94   set(tmpsublabel "")
95   foreach(_itrx ${${listname}})
96     if ("${_itrx}" MATCHES "^Sublabel:")
97       set(tmpsublabel "")
98       string(REGEX REPLACE "^Sublabel:[ \t]*" "" _itrlabels ${_itrx})
99       string(REGEX MATCHALL ${label_chars} _labels ${_itrlabels})
100       foreach(subl ${_labels})
101         if (subl STREQUAL "RESET")
102           set(tmpsublabel "")
103         else()
104           list(APPEND tmpsublabel ${subl})
105         endif()
106       endforeach()
107       # remove doubles in sublabel
108       list(REMOVE_DUPLICATES tmpsublabel)
109     else()
110       if (_itrx MATCHES "^!\(.*\)$")
111         set(_itr "^${CMAKE_MATCH_1}$")
112         set(_foundval 0)
113       else()
114         set(_itr "^${_itrx}$")
115         set(_foundval 1)
116       endif()
117       if (${testname} MATCHES "${_itr}")
118         set(_found ${_foundval})
119         break()
120       endif()
121     endif()
122   endforeach()
123   if (${_found})
124     if (NOT "${tmpsublabel}" STREQUAL "")
125       list(APPEND ${rsublabel} ${tmpsublabel})
126     endif()
127   endif()
128   set(${found} ${_found})
129 endmacro()
130
131 function(join rvalues glue routput)
132   set(locallist ${${rvalues}})
133   set(removelist "export" "lyx2lyx" "load")
134   foreach(_l ${locallist})
135     if (depth_${_l} LESS 0)
136       list(APPEND removelist ${_l})
137     endif()
138   endforeach()
139   list(REMOVE_ITEM locallist ${removelist})
140   string(REGEX REPLACE "([^\\]|^);" "\\1${glue}" out "${locallist}")
141   set(${routput} ${out} PARENT_SCOPE)
142 endfunction()
143
144 macro(maketestname testname inverted listinverted listignored listunreliable listlabels)
145   # initialize output variable
146   set(${inverted} 0)
147   string(REGEX MATCH "\\/[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${${testname}})
148   if(_v)
149     string(REGEX REPLACE "\\/" "" _v ${_v})
150     set(listinvertedx ${listinverted}_${_v})
151     set(listignoredx ${listignored}_${_v})
152     set(listunreliablex ${listunreliable}_${_v})
153     set(listsuspendedx suspendedTests_${_v})
154   else()
155     set(listinvertedx ${listinverted})
156     set(listignoredx ${listignored})
157     set(listunreliablex ${listunreliable})
158     set(listsuspendedx suspendedTests)
159   endif()
160   set(sublabel "${${listlabels}}")
161   findexpr(mfound ${testname} ${listignoredx} sublabel)
162   if (NOT mfound)
163     set(sublabel2 "")
164     findexpr(foundunreliable ${testname} ${listunreliablex} sublabel2)
165     if (foundunreliable)
166       set(sublabel "unreliable" ${sublabel} ${sublabel2})
167       list(REMOVE_ITEM sublabel "export" "inverted" "templates" "tabletemplates" "mathmacros" "manuals" "autotests")
168     endif()
169     string(REGEX MATCH "(^check_load|_(systemF|texF|pdf3|pdf2|pdf|dvi|lyx[0-9][0-9]|xhtml)$)" _v ${${testname}})
170     # check if test _may_ be in listinverted
171     set(sublabel2 "")
172     findexpr(mfound ${testname} ${listinvertedx} sublabel2)
173     if (mfound)
174       set(sublabel3 "")
175       findexpr(foundsuspended ${testname} ${listsuspendedx} sublabel3)
176       set(${inverted} 1)
177       if (foundsuspended)
178         set(sublabel "suspended" ${sublabel} ${sublabel2} ${sublabel3})
179         list(REMOVE_ITEM sublabel "export" "inverted" )
180       else()
181         set(sublabel "inverted" ${sublabel} ${sublabel2} ${sublabel3})
182       endif()
183     else()
184       set(${inverted} 0)
185     endif()
186     list(REMOVE_DUPLICATES sublabel)
187     if (NOT sublabel STREQUAL "")
188       join(sublabel "." tmpprefixx)
189       if (tmpprefixx)
190         string(TOUPPER "${tmpprefixx}_" tmpprefix)
191       else()
192         set(tmpprefix "")
193       endif()
194       set(${testname} "${tmpprefix}${${testname}}")
195       set(${listlabels} ${sublabel})
196     endif()
197   else()
198     # No testname because ignored
199     set(${testname} "")
200   endif()
201 endmacro()
202
203 macro(loadTestList filename resList depth splitlangs)
204   # Create list of strings from a file without comments
205   # ENCODING parameter is a new feature in cmake 3.1
206   initLangVars(${resList})
207   initLangVars("sublabel")
208   if (CMAKE_VERSION VERSION_GREATER "3.1")
209     file(STRINGS ${filename} tempList ENCODING "UTF-8")
210   else()
211     file(STRINGS ${filename} tempList)
212   endif()
213   set(${resList})
214   set(sublabel)
215   set(mylabels "")
216   set(languages "")
217   message(STATUS "Reading list ${filename}")
218   foreach(_l ${tempList})
219     set(_newl "${_l}")
220     string(REGEX REPLACE "[ \t]+$" "" _newl "${_l}")
221     string(REGEX REPLACE "[ \t]*#.*$" "" _newl "${_l}")
222     if(_newl)
223       list(APPEND ${resList} "${_newl}")
224       if (_newl MATCHES "^Sublabel:")
225         string(REGEX REPLACE "^Sublabel:[ \t]*" "" _newlabels ${_newl})
226         string(REGEX MATCHALL "([0-9]*${label_chars})" _labels ${_newlabels})
227         foreach(labname ${_labels})
228           if (NOT labname STREQUAL "RESET")
229             list(APPEND mylabels ${labname})
230           endif()
231         endforeach()
232         list(REMOVE_DUPLICATES mylabels)
233         set(sublabel ${_newl})
234       else()
235         if (${splitlangs} MATCHES "ON")
236           string(REGEX REPLACE "(\\/|\\||\\(|\\))" "  " _vxx ${_newl})
237           string(REGEX MATCHALL " ([a-z][a-z](_[A-Z][A-Z])?) " _vx ${_vxx})
238         else()
239           set(_vx OFF)
240         endif()
241         if(_vx)
242           foreach(_v ${_vx})
243             string(REGEX REPLACE " " "" _v ${_v})
244             #message(STATUS " ==> ${resList}_${_v}")
245             #message(STATUS "sublabel = ${sublabel}, sublabel_${_v} = ${sublabel_${_v}}")
246             if (NOT sublabel STREQUAL "${sublabel_${_v}}")
247               list(APPEND ${resList}_${_v} "${sublabel}")
248               set(sublabel_${_v} "${sublabel}")
249               #message(STATUS "Setting variable sublabel_${_v} with \"${sublabel}\"")
250             endif()
251             list(APPEND ${resList}_${_v} "${_newl}")
252             list(APPEND languages ${_v})
253           endforeach()
254           list(REMOVE_DUPLICATES languages)
255           #message(STATUS "languages = ${languages}")
256         endif()
257       endif()
258     endif()
259   endforeach()
260   foreach(_l1 ${mylabels})
261     if (_l1 MATCHES "^([0-9]+)(${label_chars})$")
262       set(_l ${CMAKE_MATCH_2})
263       set(depth1 ${CMAKE_MATCH_1})
264     else()
265       set(_l ${_l1})
266       set(depth1 "0")
267     endif()
268     list(FIND known_labels ${_l} _ff)
269     if (_ff GREATER -1)
270       message(STATUS "Label \"${_l}\" already in use. Reused in ${filename}")
271     else()
272       assignLabelDepth(${depth}${depth1} ${_l})
273     endif()
274   endforeach()
275   foreach(_lg ${languages})
276     # reset label for each used language string at end of file
277     #message(STATUS "Resetting variable sublabel_${_lg}, previously set to ${sublabel_${_lg}}")
278     set(sublabel_${_lg} "")
279   endforeach()
280 endmacro()
281
282 # This labels should not be used in .*Tests files
283 set(known_labels "")
284 # Create depth info to each label
285 macro(assignLabelDepth depth)
286   foreach(_lab ${ARGN})
287     list(APPEND known_labels ${_lab})
288     set(depth_${_lab} ${depth})
289   endforeach()
290 endmacro()
291
292 assignLabelDepth(0 "export" "key" "layout" "load" "lyx2lyx" "module" "roundtrip" "url")
293 assignLabelDepth(1 "unreliable" "inverted")
294 assignLabelDepth(2 "suspended")
295 assignLabelDepth(-1 "examples" "manuals" "mathmacros" "templates" "tabletemplates" "autotests")
296
297 loadTestList(invertedTests invertedTests 7 ON)
298 loadTestList(ignoredTests ignoredTests 0 ON)
299 loadTestList(suspendedTests suspendedTests 6 ON)
300 loadTestList(unreliableTests unreliableTests 5 ON)
301 loadTestList(ignoreLatexErrorsTests ignoreLatexErrorsTests 8 OFF)
302
303 foreach(libsubfolderx autotests/export lib/doc lib/examples lib/templates lib/tabletemplates autotests/mathmacros)
304   set(testlabel "export")
305   if (libsubfolderx MATCHES "lib/doc")
306     list(APPEND testlabel "manuals")
307   elseif (libsubfolderx MATCHES "lib/examples")
308     list(APPEND testlabel "examples")
309   elseif (libsubfolderx MATCHES "lib/templates")
310     list(APPEND testlabel "templates")
311   elseif (libsubfolderx MATCHES "lib/tabletemplates")
312     list(APPEND testlabel "tabletemplates")
313   elseif (libsubfolderx MATCHES "autotests/mathmacros")
314     list(APPEND testlabel "mathmacros")
315   elseif (libsubfolderx MATCHES "autotests/.+")
316     list(APPEND testlabel "autotests")
317   endif()
318   set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/${libsubfolderx}")
319   string(REGEX REPLACE "^(lib|development|autotests)/" "" libsubfolder "${libsubfolderx}")
320   set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/${libsubfolderx}")
321   message(STATUS "Handling export dir ${LIBSUB_SRC_DIR}")
322   file(GLOB_RECURSE lyx_files RELATIVE "${LIBSUB_SRC_DIR}" "${LIBSUB_SRC_DIR}/*.lyx")
323   list(SORT lyx_files)
324   # Now create 2 lists. One for files in a language dir, one without
325   set(lang_lyx_files)
326   set(nolang_lyx_files)
327   foreach(f ${lyx_files})
328     if (${f} MATCHES "#")
329       # Do nothing, probably wrong temporary file
330     else()
331       string(REGEX MATCHALL "^[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${f})
332       if(_v)
333         list(APPEND lang_lyx_files ${f})
334       else()
335         list(APPEND nolang_lyx_files ${f})
336       endif()
337     endif()
338   endforeach()
339   foreach(f ${nolang_lyx_files} ${lang_lyx_files})
340     # Strip extension
341     string(REGEX REPLACE "\\.lyx$" "" f ${f})
342     foreach(_lyx_format_num 16 20 21 22 23)
343       set(TestName1 "export/${libsubfolder}/${f}_lyx${_lyx_format_num}")
344       string(REGEX REPLACE "[\\(\\)]" "_" TestName "${TestName1}")
345       set(mytestlabel ${testlabel} "lyx2lyx" "load")
346       maketestname(TestName inverted invertedTests ignoredTests unreliableTests mytestlabel)
347       if(TestName)
348         add_test(NAME ${TestName}
349           WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
350           COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
351           -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
352           -Dlyx=$<TARGET_FILE:${_lyx}>
353           -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
354           -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
355           -Dformat=lyx${_lyx_format_num}x
356           -Dextension=${_lyx_format_num}.lyx
357           -DLYX_FORMAT_NUM=${_lyx_format_num}
358           -Dfile=${f}
359           -Dinverted=${inverted}
360           -DTOP_SRC_DIR=${TOP_SRC_DIR}
361           -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
362           -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
363         setmarkedtestlabel(${TestName} ${mytestlabel})
364       endif()
365     endforeach()
366     if(LYX_PYTHON_EXECUTABLE)
367       set(lyx2lyxtestlabel "lyx2lyx")
368       # For use of lyx2lyx we need the python executable
369       set(mytestlabel ${lyx2lyxtestlabel})
370       set(TestName1 "lyx2lyx/${libsubfolder}/${f}")
371       string(REGEX REPLACE "[\\(\\)]" "_" TestName "${TestName1}")
372       maketestname(TestName inverted invertedTests ignoredTests unreliableTests mytestlabel)
373       if(TestName)
374         add_test(NAME ${TestName}
375           WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
376           COMMAND ${CMAKE_COMMAND}
377           "-DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}"
378           "-DLYX2LYX=${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx"
379           "-DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}"
380           "-DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx"
381           -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake")
382         setmarkedtestlabel(${TestName} ${mytestlabel})
383       endif()
384     endif()
385     set(loadtestlabel "load")
386     set(mytestlabel ${loadtestlabel})
387     set(TestName1 "check_load/${libsubfolder}/${f}")
388     string(REGEX REPLACE "[\\(\\)]" "_" TestName "${TestName1}")
389     maketestname(TestName inverted invertedTests ignoredTests unreliableTests mytestlabel)
390     if(TestName)
391       add_test(NAME ${TestName}
392         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
393         COMMAND ${CMAKE_COMMAND} -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
394         -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
395         -Dlyx=$<TARGET_FILE:${_lyx}>
396         -DPARAMS_DIR=${TOP_SRC_DIR}/development/autotests
397         -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
398         -Dinverted=${inverted}
399         -P "${TOP_SRC_DIR}/development/autotests/check_load.cmake")
400       setmarkedtestlabel(${TestName} ${mytestlabel})
401       #set_tests_properties(${TestName} PROPERTIES RUN_SERIAL ON)
402     endif()
403     set(default_output_format)
404     getoutputformats("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist default_output_format)
405     foreach(format ${formatlist})
406       if(format MATCHES "dvi3|pdf4|pdf5")
407         set(fonttypes "texF" "systemF")
408       else()
409         set(fonttypes "defaultF")
410       endif()
411       foreach(fonttype ${fonttypes})
412         if (format MATCHES "pdf2" AND f MATCHES "latex/unicodesymbols")
413           #message(STATUS "Test ${TestName} matches Unicode encodings")
414           # test_encodings does not include "default", since it should be covered
415           # by one of the supplied encodings
416           set(test_encodings "ascii" "utf8" "utf8x" "armscii8" "applemac"
417             "cp437" "cp437de" "cp850" "cp852"
418             "cp855" "cp862" "cp865"
419             "cp866" "cp1250" "cp1251" "cp1252"
420             "cp1255" "cp1256" "cp1257"
421             "koi8-r" "koi8-u"
422             "iso8859-1" "iso8859-2" "iso8859-3"
423             "iso8859-4" "iso8859-5" "iso8859-6"
424             "iso8859-7" "iso8859-8" "iso8859-9"
425             "iso8859-13" "iso8859-15" "iso8859-16"
426             "pt154" "big5" "shift-jis"
427             "euc-cn" "gbk" "jis" "euc-kr"
428             "utf8-cjk" "euc-tw" "euc-jp"
429             "euc-jp-platex" "jis-platex"
430             "shift-jis-platex" "utf8-platex"
431             "tis620-0")
432         else()
433           set(test_encodings "default")
434         endif()
435         foreach (_enc2 ${test_encodings})
436           if ("${_enc2}" STREQUAL "default")
437             set(_enc "")
438           else()
439             set(_enc "_${_enc2}")
440           endif()
441           if(fonttype MATCHES "defaultF")
442             set(TestName1 "export/${libsubfolder}/${f}${_enc}_${format}")
443           else()
444             set(TestName1 "export/${libsubfolder}/${f}${_enc}_${format}_${fonttype}")
445           endif()
446           if (format MATCHES "^${default_output_format}$")
447             set(extraLabels "defaultoutput")
448           else()
449             set(extraLabels )
450           endif()
451           set(missingLabels )
452           findexpr(mfound TestName1 ignoreLatexErrorsTests missingLabels)
453           if (mfound)
454             set(mytestlabel ${testlabel} "ignoring" ${missingLabels} ${extraLabels})
455           else()
456             set(mytestlabel ${testlabel} ${extraLabels})
457           endif()
458           string(REGEX REPLACE "[\\(\\)]" "_" TestName "${TestName1}")
459           maketestname(TestName inverted invertedTests ignoredTests unreliableTests mytestlabel)
460           if (format MATCHES "docbook5")
461             set(f_extension "xml")
462           else()
463             set(f_extension ${format})
464           endif()
465           if(TestName)
466             add_test(NAME ${TestName}
467               WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
468               COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
469               -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
470               -Dlyx=$<TARGET_FILE:${_lyx}>
471               -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
472               -Dformat=${format}
473               -Dfonttype=${fonttype}
474               -Dextension=${f_extension}
475               -Dfile=${f}
476               -Dinverted=${inverted}
477               -DTOP_SRC_DIR=${TOP_SRC_DIR}
478               "-DIgnoreErrorMessage=${missingLabels}"
479               -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
480               -DXMLLINT_EXECUTABLE=${XMLLINT_EXECUTABLE}
481               -DJAVA_EXECUTABLE=${jingjava}
482               -DENCODING=${_enc2}
483               -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
484             setmarkedtestlabel(${TestName} ${mytestlabel}) # check for suspended pdf/dvi exports
485           endif()
486         endforeach()
487       endforeach()
488     endforeach()
489   endforeach()
490 endforeach()