]> git.lyx.org Git - features.git/blob - development/autotests/CMakeLists.txt
Re-add MergedManual test
[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       elseif(found STREQUAL "xhtml")
59         set(found "") # we test xhtml regardless of default format
60       endif()
61       set(${varname} ${found})
62       break()
63     endif()
64   endforeach()
65 endmacro()
66
67 foreach(libsubfolder doc examples templates)
68   set(LIBSUB_SRC_DIR "${TOP_SRC_DIR}/lib/${libsubfolder}")
69   file(GLOB_RECURSE lyx_files RELATIVE "${LIBSUB_SRC_DIR}" "${LIBSUB_SRC_DIR}/*.lyx")
70   list(SORT lyx_files)
71   # Now create 2 lists. One for files in a language dir, one without
72   set(lang_lyx_files)
73   set(nolang_lyx_files)
74   foreach(f ${lyx_files})
75     string(REGEX MATCHALL "^[a-z][a-z](_[A-Z][A-Z])?\\/" _v ${f})
76     if(_v)
77       list(APPEND lang_lyx_files ${f})
78     else()
79       list(APPEND nolang_lyx_files ${f})
80     endif()
81   endforeach()
82   foreach(f ${nolang_lyx_files} ${lang_lyx_files})
83     # Strip extension
84     string(REGEX REPLACE "\\.lyx$" "" f ${f})
85     add_test(NAME export/${libsubfolder}/${f}_lyx16
86       WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
87       COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
88           -Dlyx=$<TARGET_FILE:${_lyx}>
89           -Dformat=lyx16x
90           -Dextension=16.lyx
91           -Dfile=${f}
92           -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
93     getdefaultoutputformat("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
94     foreach(format "xhtml" ${formatlist})
95       add_test(NAME export/${libsubfolder}/${f}_${format}
96         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
97         COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR}
98             -Dlyx=$<TARGET_FILE:${_lyx}>
99             -Dformat=${format}
100             -Dextension=${format}
101             -Dfile=${f}
102             -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
103     endforeach()
104   endforeach()
105 endforeach()
106
107