mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 00:10:59 +00:00
New ctests to check for parsing and other errors
These tests load the .lyx files to see if there are any parsing errors or other LyX errors/warnings. The tests fail if LyX writes a line to STDERR that does not match any of the regexes stored in filterCheckWarnings. Thanks to Kornel for the CMake expertise and corrections. This patch was written jointly with him.
This commit is contained in:
parent
48e8f93d9a
commit
7affdd5764
@ -4,6 +4,11 @@
|
||||
# Copyright (c) 2012 Kornel Benko kornel@lyx.org
|
||||
#
|
||||
|
||||
set(LYX_HOME "out-home")
|
||||
set(LYX_USERDIR "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}/.lyx")
|
||||
set(LOCALE_DIR "${CMAKE_CURRENT_BINARY_DIR}/locale")
|
||||
file(MAKE_DIRECTORY "${LYX_USERDIR}" "${LOCALE_DIR}")
|
||||
|
||||
if(Q_WS_X11)
|
||||
set(Missing)
|
||||
set(XVFBDLIBS)
|
||||
@ -69,9 +74,6 @@ if(Q_WS_X11)
|
||||
add_subdirectory(xvkbd)
|
||||
|
||||
set(KEYTEST "${CMAKE_CURRENT_SOURCE_DIR}/keytest.py")
|
||||
set(LYX_HOME "out-home")
|
||||
set(LYX_USERDIR "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}/.lyx")
|
||||
set(LOCALE_DIR "${CMAKE_CURRENT_BINARY_DIR}/locale")
|
||||
file(GLOB TESTST RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.txt")
|
||||
file(GLOB TESTSS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.sh")
|
||||
list(REMOVE_ITEM TESTST hello-world-in.txt first-time-in.txt)
|
||||
@ -167,6 +169,15 @@ foreach(libsubfolder doc examples templates)
|
||||
COMMAND ${CMAKE_COMMAND} -DLYX2LYX=${TOP_SRC_DIR}/lib/lyx2lyx/lyx2lyx
|
||||
-DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
|
||||
-P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake")
|
||||
set(TestName "check_load/${libsubfolder}/${f}")
|
||||
getreverted(TestName reverted revertedTests)
|
||||
add_test(NAME ${TestName}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
|
||||
COMMAND ${CMAKE_COMMAND} -DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
|
||||
-Dlyx=$<TARGET_FILE:${_lyx}>
|
||||
-DPARAMS_DIR=${TOP_SRC_DIR}/development/autotests
|
||||
-DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
|
||||
-P "${TOP_SRC_DIR}/development/autotests/check_load.cmake")
|
||||
getoutputformats("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
|
||||
foreach(format ${formatlist})
|
||||
set(TestName "export/${libsubfolder}/${f}_${format}")
|
||||
|
56
development/autotests/check_load.cmake
Normal file
56
development/autotests/check_load.cmake
Normal file
@ -0,0 +1,56 @@
|
||||
# This file is part of LyX, the document processor.
|
||||
# Licence details can be found in the file COPYING.
|
||||
#
|
||||
# Copyright (c) 2013 Kornel Benko kornel@lyx.org
|
||||
# Copyright (c) 2013 Scott Kostyshak skotysh@lyx.org
|
||||
#
|
||||
#
|
||||
# LYXFILE = xxx
|
||||
# lyx =
|
||||
#
|
||||
# Script should be called like:
|
||||
# cmake -DWORKDIR=${BUILD_DIR}/autotests/out-home \
|
||||
# -DLYXFILE=xxx \
|
||||
# -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \
|
||||
# -DPARAMS_DIR="${TOP_SRC_DIR}/development/autotests" \
|
||||
# -P "${TOP_SRC_DIR}/development/autotests/check_load.cmake"
|
||||
#
|
||||
|
||||
message(STATUS "Executing ${lyx} -batch ${LYXFILE}")
|
||||
set(ENV{${LYX_USERDIR_VER}} "${WORKDIR}/.lyx")
|
||||
set(ENV{LANG} "en") # to get all error-messages in english
|
||||
|
||||
execute_process(
|
||||
COMMAND ${lyx} -batch -userdir ${WORKDIR}/.lyx ${LYXFILE}
|
||||
RESULT_VARIABLE _err
|
||||
ERROR_VARIABLE lyxerr)
|
||||
|
||||
message(STATUS "Error code of lyx = ${_err}")
|
||||
string(COMPARE NOTEQUAL ${_err} 0 _erg)
|
||||
|
||||
if(lyxerr)
|
||||
file(STRINGS "${PARAMS_DIR}/filterCheckWarnings" ignoreRegexp)
|
||||
# Split lyxerr into lines
|
||||
string(REGEX REPLACE "[\n]+" ";" foundErrors ${lyxerr})
|
||||
foreach(_l ${foundErrors})
|
||||
message(STATUS "Checking line: \"${_l}\"")
|
||||
set(found 0)
|
||||
foreach(_r ${ignoreRegexp})
|
||||
string(REGEX MATCHALL "${_r}" _match ${_l})
|
||||
if(_match)
|
||||
set(found 1)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT found)
|
||||
# It is error, because the error-line does not match
|
||||
# any ignoring expression
|
||||
set(_erg 1)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(_erg)
|
||||
# We print here the whole error output, even the ignored part
|
||||
message(FATAL_ERROR "lyx gave warnings/errors:\n${lyxerr}")
|
||||
endif()
|
1
development/autotests/filterCheckWarnings
Normal file
1
development/autotests/filterCheckWarnings
Normal file
@ -0,0 +1 @@
|
||||
Cannot find translation for language
|
Loading…
Reference in New Issue
Block a user