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