]> git.lyx.org Git - lyx.git/blob - development/autotests/CMakeLists.txt
Cmake tests: Add lyx-files for export testing recursively.
[lyx.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)
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   foreach(f ${lyx_files})
69     # Strip extension
70     string(REGEX REPLACE "\\.lyx$" "" f ${f})
71     add_test(NAME export/${libsubfolder}/${f}_lyx16
72       WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
73       COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
74           -Dlyx=$<TARGET_FILE:${_lyx}>
75           -Dformat=lyx16x
76           -Dextension=16.lyx
77           -Dfile=${f}
78           -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
79     getdefaultoutputformat("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
80     foreach(format "xhtml" ${formatlist})
81       add_test(NAME export/${libsubfolder}/${f}_${format}
82         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
83         COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
84             -Dlyx=$<TARGET_FILE:${_lyx}>
85             -Dformat=${format}
86             -Dextension=${format}
87             -Dfile=${f}
88             -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
89     endforeach()
90   endforeach()
91 endforeach()
92
93