]> git.lyx.org Git - features.git/blob - development/autotests/check_load.cmake
New ctests to check for parsing and other errors
[features.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 #       -DLYXFILE=xxx \
14 #       -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \
15 #       -DPARAMS_DIR="${TOP_SRC_DIR}/development/autotests" \
16 #       -P "${TOP_SRC_DIR}/development/autotests/check_load.cmake"
17 #
18
19 message(STATUS "Executing ${lyx} -batch ${LYXFILE}")
20 set(ENV{${LYX_USERDIR_VER}} "${WORKDIR}/.lyx")
21 set(ENV{LANG} "en") # to get all error-messages in english
22
23 execute_process(
24   COMMAND ${lyx} -batch -userdir ${WORKDIR}/.lyx ${LYXFILE}
25   RESULT_VARIABLE _err
26   ERROR_VARIABLE lyxerr)
27
28 message(STATUS "Error code of lyx = ${_err}")
29 string(COMPARE NOTEQUAL  ${_err} 0 _erg)
30
31 if(lyxerr)
32   file(STRINGS "${PARAMS_DIR}/filterCheckWarnings" ignoreRegexp)
33   # Split lyxerr into lines
34   string(REGEX REPLACE "[\n]+" ";" foundErrors ${lyxerr})
35   foreach(_l ${foundErrors})
36     message(STATUS "Checking line: \"${_l}\"")
37     set(found 0)
38     foreach(_r ${ignoreRegexp})
39       string(REGEX MATCHALL "${_r}" _match ${_l})
40       if(_match)
41         set(found 1)
42         break()
43       endif()
44     endforeach()
45     if(NOT found)
46       # It is error, because the error-line does not match
47       # any ignoring expression
48       set(_erg 1)
49     endif()
50   endforeach()
51 endif()
52
53 if(_erg)
54   # We print here the whole error output, even the ignored part
55   message(FATAL_ERROR "lyx gave warnings/errors:\n${lyxerr}")
56 endif()