]> git.lyx.org Git - lyx.git/blob - src/tex2lyx/test/runtests.cmake
Fix #10778 (issue with CJK and language nesting)
[lyx.git] / src / tex2lyx / test / runtests.cmake
1 # This file is part of LyX, the document processor.
2 # Licence details can be found in the file COPYING.
3 #
4 # Copyright (c) 2013-2014 Kornel Benko <kornel@lyx.org>
5 #           (c) 2013-2014 Scott Kostyshak <skotysh@lyx.org>
6 #
7 # Script should be called like:
8 # COMMAND ${CMAKE_COMMAND} \
9 #     -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} \
10 #     -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \
11 #     -DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE} \
12 #     -DPY_SCRIPT=${TOP_SRC_DIR}/src/tex2lyx/test/runtests.py \
13 #     -DFIRST_PARAM=
14 #     -DTEX2LYX_EXE=$<TARGET_FILE:${_tex2lyx}> \
15 #     -DSCRIPT_DIR=${TOP_SRC_DIR}/lib/scripts \
16 #     -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR} \
17 #     -DTESTFILE=${fl} \
18 #     -P ${TOP_SRC_DIR}/src/tex2lyx/test/runtests.cmake
19
20 set(ENV{${LYX_USERDIR_VER}} ${LYX_TESTS_USERDIR})
21 message(STATUS "SCRIPT_DIR = ${SCRIPT_DIR}")
22
23 set(_configure_needed FALSE)
24 foreach(_f lyxrc.defaults lyxmodules.lst textclass.lst packages.lst)
25   if(NOT EXISTS "${LYX_TESTS_USERDIR}/${_f}")
26     message(STATUS "Configure needed, because \"${LYX_TESTS_USERDIR}/${_f}\" does not exist")
27     set(_configure_needed TRUE)
28     break()
29   endif()
30   if("${SCRIPT_DIR}/../configure.py" IS_NEWER_THAN "${LYX_TESTS_USERDIR}/${_f}")
31     message(STATUS "Configure needed, because \"${LYX_TESTS_USERDIR}/${_f}\" too old")
32     set(_configure_needed TRUE)
33     break()
34   endif()
35 endforeach()
36
37 if(_configure_needed)
38   # Determine suffix from ${TEX2LYX_EXE}
39   if(TEX2LYX_EXE MATCHES ".*tex2lyx([0-9]\\.[0-9]).*")
40     set(_suffix ${CMAKE_MATCH_1})
41   else()
42     set(_suffix "")
43   endif()
44
45   if(_suffix STREQUAL "")
46     set(_with_ver "")
47   else()
48     set(_with_ver "--with-version-suffix=${_suffix}")
49   endif()
50
51   # Get binary directory of tex2lyx
52   string(REGEX REPLACE "(.*)tex2lyx${_suffix}.*" "\\1" _bindir "${TEX2LYX_EXE}")
53
54   message(STATUS "executing ${LYX_PYTHON_EXECUTABLE} -tt \"${SCRIPT_DIR}/../configure.py\" ${_with_ver} \"--binary-dir=${_bindir}\"")
55   execute_process(COMMAND ${LYX_PYTHON_EXECUTABLE} -tt "${SCRIPT_DIR}/../configure.py"
56     ${_with_ver} "--binary-dir=${_bindir}"
57     WORKING_DIRECTORY "${LYX_TESTS_USERDIR}"
58   )
59 endif()
60
61 execute_process(COMMAND ${LYX_PYTHON_EXECUTABLE} ${PY_SCRIPT} ${FIRST_PARAM}
62   ${TEX2LYX_EXE} ${SCRIPT_DIR} ${WORKDIR} ${TESTFILE}
63   RESULT_VARIABLE _err
64   OUTPUT_VARIABLE _out)
65
66 message(STATUS ${_out})
67 message(STATUS "Error output of ${PY_SCRIPT} = ${_err}")
68 string(COMPARE NOTEQUAL  ${_err} 0 _erg)
69
70 if(_erg)
71   message(FATAL_ERROR "${PY_SCRIPT} failed")
72 endif()
73
74