]> git.lyx.org Git - features.git/blob - development/autotests/lyx2lyxtest.cmake
Cmake build tests: make lyx2lyx tests threadsafe
[features.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 -DLYX2LYX=xxx \
12 #       -DWORKDIR=${BUILD_DIR}/autotests/out-home \
13 #       -DLYXFILE=xxx \
14 #       -P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake"
15 #
16
17 string(RANDOM LENGTH 5 errorfile)
18 string(RANDOM LENGTH 6 outputfile)
19 message(STATUS "Executing ${LYX2LYX} -e ${errorfile} -o ${outputfile} ${LYXFILE}")
20 execute_process(
21   COMMAND ${LYX2LYX} -e ${errorfile} -o ${outputfile} ${LYXFILE}
22   RESULT_VARIABLE _err)
23
24 message(STATUS "Error output of lyx2lyx = ${_err}")
25 string(COMPARE NOTEQUAL  ${_err} 0 _erg)
26
27 # Check file "errors" being empty
28 file(STRINGS ${errorfile} foundErrors)
29 if(foundErrors)
30   set(_erg 1)
31   foreach(_l ${foundErrors})
32     message(STATUS "${_l}")
33   endforeach()
34 endif()
35
36 # Check the output-file being not empty
37 file(STRINGS ${outputfile} createdLyx)
38 if(NOT createdLyx)
39   set(_erg 1)
40   message(STATUS "Created file empty")
41 endif()
42
43 execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${errorfile} ${outputfile})
44 if(_erg)
45   message(FATAL_ERROR "lyx2lyx failed")
46 endif()