]> git.lyx.org Git - lyx.git/blob - development/autotests/CMakeLists.txt
Add custom target to run tests
[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         -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
41         -DKEYTEST_OUTFILE=${_t}-out.txt
42         -DPACKAGE=${PACKAGE}
43         -DLOCALE_DIR=${LOCALE_DIR}
44         -P ${TOP_SRC_DIR}/development/autotests/single-test.cmake)
45     endforeach()
46   endif()
47 endif()
48
49 file(GLOB lyx_files RELATIVE "${TOP_SRC_DIR}/lib/doc" "${TOP_SRC_DIR}/lib/doc/*.lyx")
50 foreach(f ${lyx_files})
51   # Strip extension
52   string(REGEX REPLACE "\\.lyx$" "" f ${f})
53   add_test(NAME autotests/export/${f}_lyx16
54     WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
55     COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${TOP_SRC_DIR}/lib/doc
56             -Dlyx=$<TARGET_FILE:${_lyx}>
57             -Dformat=lyx16x
58             -Dextension=16.lyx
59             -Dfile=${f}
60             -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
61   add_test(NAME autotests/export/${f}_xhtml
62     WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
63     COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${TOP_SRC_DIR}/lib/doc
64             -Dlyx=$<TARGET_FILE:${_lyx}>
65             -Dformat=xhtml
66             -Dextension=xhtml
67             -Dfile=${f}
68             -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
69 endforeach()
70
71