]> git.lyx.org Git - lyx.git/blob - development/autotests/check_load.cmake
#5502 add binding for full screen toggle on mac
[lyx.git] / development / autotests / check_load.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 # Copyright (c) 2013 Scott Kostyshak skotysh@lyx.org
6 #
7 #
8 # LYXFILE  = xxx
9 # lyx      =
10 #
11 # Script should be called like:
12 # cmake -DWORKDIR=${BUILD_DIR}/autotests/out-home \
13 #       -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} \
14 #       -DLYXFILE=xxx \
15 #       -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \
16 #       -DPARAMS_DIR="${TOP_SRC_DIR}/development/autotests" \
17 #       -P "${TOP_SRC_DIR}/development/autotests/check_load.cmake"
18 #
19
20 message(STATUS "Executing ${lyx} -batch -userdir \"${LYX_TESTS_USERDIR}\" ${LYXFILE}")
21 set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}")
22 set(ENV{LANG} "en") # to get all error-messages in english
23
24 execute_process(
25   COMMAND ${lyx} -batch -userdir "${LYX_TESTS_USERDIR}" ${LYXFILE}
26   RESULT_VARIABLE _err
27   ERROR_VARIABLE lyxerr)
28
29 message(STATUS "Error code of lyx = ${_err}")
30 string(COMPARE NOTEQUAL  ${_err} 0 _erg)
31
32 #
33 # Ignore messages between "reconfiguring user directory" and "LyX: Done!"
34 # (Reconfigure-messages are not symptom of an error)
35 if(lyxerr)
36   set(ConfigureOutput 0)
37   file(STRINGS "${PARAMS_DIR}/filterCheckWarnings" ignoreRegexp)
38   # Split lyxerr into lines
39   string(REGEX REPLACE "[\n]+" ";" foundErrors ${lyxerr})
40   foreach(_l ${foundErrors})
41     if(ConfigureOutput)
42       if(_l MATCHES "LyX: Done!")
43         set(ConfigureOutput 0)
44       endif()
45     else()
46       if(_l MATCHES "reconfiguring user directory")
47         set(ConfigureOutput 1)
48       endif()
49     endif()
50     if(NOT ConfigureOutput)
51       set(found 0)
52       foreach(_r ${ignoreRegexp})
53         if(_l MATCHES "${_r}")
54           set(found 1)
55           break()
56         endif()
57       endforeach()
58       if(NOT found)
59         message(STATUS "Error line = ${_l}")
60         # It is error, because the error-line does not match
61         # any ignoring expression
62         set(_erg 1)
63         break()
64       endif()
65     endif()
66   endforeach()
67 endif()
68
69 if(_erg)
70   # We print here the whole error output, even the ignored part
71   message(FATAL_ERROR "lyx gave warnings/errors:\n${lyxerr}")
72 endif()