]> git.lyx.org Git - lyx.git/blob - development/autotests/lyx2lyxtest.cmake
Added a testcase for #8381 (advanced find & replace for lists)
[lyx.git] / development / autotests / lyx2lyxtest.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 Kornel Benko kornel@lyx.org
5 #
6 #
7 # LYX2LYX  = ${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx
8 # LYXFILE  = xxx
9 #
10 # Script should be called like:
11 # cmake -DLYX_PYTHON_EXECUTABLE=xxx \
12 #       -DLYX2LYX=xxx \
13 #       -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} \
14 #       -DWORKDIR=${BUILD_DIR}/autotests/out-home \
15 #       -DLYXFILE=xxx \
16 #       -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake"
17 #
18
19 string(RANDOM LENGTH 5 errorfile)
20 string(RANDOM LENGTH 6 outputfile)
21 message(STATUS "Executing ${LYX_PYTHON_EXECUTABLE} ${LYX2LYX} -e ${errorfile} -o ${outputfile} ${LYXFILE}")
22 execute_process(
23   COMMAND ${LYX_PYTHON_EXECUTABLE} ${LYX2LYX} -e ${errorfile} -o ${outputfile} ${LYXFILE}
24   RESULT_VARIABLE _err)
25
26 message(STATUS "Error output of lyx2lyx = ${_err}")
27 string(COMPARE NOTEQUAL  ${_err} 0 _erg)
28
29 # Check file "errors" being empty
30 file(STRINGS ${errorfile} foundErrors)
31 if(foundErrors)
32   foreach(_l ${foundErrors})
33     if (NOT _l MATCHES "Warning: No conversion needed:")
34       set(_erg 1)
35       message(STATUS "${_l}")
36   endif()
37   endforeach()
38 endif()
39
40 # Check the output-file being not empty
41 file(STRINGS ${outputfile} createdLyx)
42 if(NOT createdLyx)
43   set(_erg 1)
44   message(STATUS "Created file empty")
45 endif()
46
47 execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${errorfile} ${outputfile})
48 if(_erg)
49   message(FATAL_ERROR "lyx2lyx failed")
50 endif()