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