]> git.lyx.org Git - features.git/blob - development/autotests/CMakeLists.txt
Add templates to export tests (CMake & autotools)
[features.git] / development / autotests / CMakeLists.txt
1 # This file is part of LyX, the document processor.
2 # Licence details can be found in the file COPYING.
3 #
4 # Copyright (c) 2012 Kornel Benko kornel@lyx.org
5 #
6
7 if(Q_WS_X11)
8   # Make sure, the needed programs are in PATH
9   find_program(PCREGREP_EXE "pcregrep")
10   find_program(WMCTRL_EXE "wmctrl")
11   # This is needed to build xvkbd
12   # Programs pcregrep wmctrl and xvkbd are used in subsequent scripts
13   # while testing
14   find_package(X11)
15   if(X11_FOUND AND PCREGREP_EXE AND WMCTRL_EXE)
16     #message(STATUS "PCREGREP_EXE and WMCTRL_EXE found")
17     project(autotests)
18
19     add_subdirectory(xvkbd)
20
21     set(KEYTEST "${CMAKE_CURRENT_SOURCE_DIR}/keytest.py")
22     set(LYX_HOME "out-home")
23     set(LYX_USERDIR "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}/.lyx")
24     set(LOCALE_DIR "${CMAKE_CURRENT_BINARY_DIR}/locale") 
25     file(GLOB TESTST RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.txt")
26     file(GLOB TESTSS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.sh")
27     list(REMOVE_ITEM TESTST hello-world-in.txt first-time-in.txt)
28     list(SORT TESTST)
29     file(MAKE_DIRECTORY "${LYX_USERDIR}" "${LOCALE_DIR}")
30
31     foreach(_tf first-time-in.txt hello-world-in.txt ${TESTST})
32       string(REGEX REPLACE "-in\\.(txt|sh)" "" _t ${_tf})
33       add_test(NAME autotests/${_t}
34         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
35         COMMAND ${CMAKE_COMMAND}
36         -DAUTOTEST_ROOT=${TOP_SRC_DIR}/development/autotests
37         -DPO_BUILD_DIR=${TOP_BINARY_DIR}/po
38         -DKEYTEST_INFILE=${_tf}
39         -DBINDIR=$<TARGET_FILE_DIR:${_lyx}>
40         -DLYX=${_lyx}
41         -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
42         -DKEYTEST_OUTFILE=${_t}-out.txt
43         -DPACKAGE=${PACKAGE}
44         -DLOCALE_DIR=${LOCALE_DIR}
45         -P ${TOP_SRC_DIR}/development/autotests/single-test.cmake)
46     endforeach()
47   endif()
48 endif()
49
50 macro(getdefaultoutputformat filepath varname)
51   file(STRINGS "${filepath}" lines)
52   set(${varname} "pdf") # try at least this one
53   foreach(_l ${lines})
54     if(_l MATCHES "^\\\\default_output_format +\([^ ]+\)")
55       set(found ${CMAKE_MATCH_1})
56       if(found STREQUAL "default")
57         set(found "pdf" "pdf2" "pdf5")
58       endif()
59       set(${varname} ${found})
60       break()
61     endif()
62   endforeach()
63 endmacro()
64
65 foreach(libsubfolder doc examples templates)
66   set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/lib/${libsubfolder}")
67   file(GLOB_RECURSE lyx_files RELATIVE "${LIBSUB_SRC_DIR}" "${LIBSUB_SRC_DIR}/*.lyx")
68   list(SORT lyx_files)
69   # Now create 2 lists. One for files in a language dir, one without
70   set(lang_lyx_files)
71   set(nolang_lyx_files)
72   foreach(f ${lyx_files})
73     string(REGEX MATCHALL "^[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${f})
74     if(_v)
75       list(APPEND lang_lyx_files ${f})
76     else()
77       list(APPEND nolang_lyx_files ${f})
78     endif()
79   endforeach()
80   foreach(f ${nolang_lyx_files} ${lang_lyx_files})
81     # Strip extension
82     string(REGEX REPLACE "\\.lyx$" "" f ${f})
83     add_test(NAME export/${libsubfolder}/${f}_lyx16
84       WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
85       COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
86           -Dlyx=$<TARGET_FILE:${_lyx}>
87           -Dformat=lyx16x
88           -Dextension=16.lyx
89           -Dfile=${f}
90           -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
91     getdefaultoutputformat("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
92     foreach(format "xhtml" ${formatlist})
93       add_test(NAME export/${libsubfolder}/${f}_${format}
94         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
95         COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
96             -Dlyx=$<TARGET_FILE:${_lyx}>
97             -Dformat=${format}
98             -Dextension=${format}
99             -Dfile=${f}
100             -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
101     endforeach()
102   endforeach()
103 endforeach()
104
105