Cmake export tests: Check if exported lyx files are loadable

Also added tests for export to lyx21 format.
This commit is contained in:
Kornel Benko 2015-12-25 10:28:40 +01:00
parent 041bc943d7
commit e3cd6db4a7
3 changed files with 47 additions and 57 deletions

View File

@ -136,7 +136,7 @@ macro(maketestname testname inverted listsuspicious listignored listunreliable l
set(sublabel "unreliable" ${sublabel} ${sublabel2}) set(sublabel "unreliable" ${sublabel} ${sublabel2})
list(REMOVE_ITEM sublabel "export" "inverted" "templates" "mathmacros" "manuals" "autotests") list(REMOVE_ITEM sublabel "export" "inverted" "templates" "mathmacros" "manuals" "autotests")
else() else()
string(REGEX MATCH "_(systemF|texF|pdf3|pdf2|pdf|dvi|lyx16|xhtml)$" _v ${${testname}}) string(REGEX MATCH "_(systemF|texF|pdf3|pdf2|pdf|dvi|lyx[0-9][0-9]|xhtml)$" _v ${${testname}})
# check if test _may_ be in listsuspicious # check if test _may_ be in listsuspicious
set(sublabel2 "") set(sublabel2 "")
if (_v) if (_v)
@ -303,7 +303,8 @@ foreach(libsubfolderx autotests/export lib/doc lib/examples lib/templates autote
foreach(f ${nolang_lyx_files} ${lang_lyx_files}) foreach(f ${nolang_lyx_files} ${lang_lyx_files})
# Strip extension # Strip extension
string(REGEX REPLACE "\\.lyx$" "" f ${f}) string(REGEX REPLACE "\\.lyx$" "" f ${f})
set(TestName "export/${libsubfolder}/${f}_lyx16") foreach(_lyx_format_num 16 21)
set(TestName "export/${libsubfolder}/${f}_lyx${_lyx_format_num}")
set(mytestlabel ${testlabel}) set(mytestlabel ${testlabel})
maketestname(TestName inverted suspiciousTests ignoredTests unreliableTests mytestlabel) maketestname(TestName inverted suspiciousTests ignoredTests unreliableTests mytestlabel)
if(TestName) if(TestName)
@ -314,8 +315,8 @@ foreach(libsubfolderx autotests/export lib/doc lib/examples lib/templates autote
-Dlyx=$<TARGET_FILE:${_lyx}> -Dlyx=$<TARGET_FILE:${_lyx}>
-DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME} -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
-DLYX_USERDIR_VER=${LYX_USERDIR_VER} -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
-Dformat=lyx16x -Dformat=lyx${_lyx_format_num}x
-Dextension=16.lyx -Dextension=${_lyx_format_num}.lyx
-Dfile=${f} -Dfile=${f}
-Dinverted=${inverted} -Dinverted=${inverted}
-DTOP_SRC_DIR=${TOP_SRC_DIR} -DTOP_SRC_DIR=${TOP_SRC_DIR}
@ -323,6 +324,7 @@ foreach(libsubfolderx autotests/export lib/doc lib/examples lib/templates autote
-P "${TOP_SRC_DIR}/development/autotests/export.cmake") -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
setmarkedtestlabel(${TestName} ${mytestlabel}) setmarkedtestlabel(${TestName} ${mytestlabel})
endif() endif()
endforeach()
if(LYX_PYTHON_EXECUTABLE) if(LYX_PYTHON_EXECUTABLE)
set(lyx2lyxtestlabel "lyx2lyx") set(lyx2lyxtestlabel "lyx2lyx")
# For use of lyx2lyx we need the python executable # For use of lyx2lyx we need the python executable

View File

@ -32,39 +32,8 @@ string(COMPARE NOTEQUAL ${_err} 0 _erg)
# #
# Ignore messages between "reconfiguring user directory" and "LyX: Done!" # Ignore messages between "reconfiguring user directory" and "LyX: Done!"
# (Reconfigure-messages are not symptom of an error) # (Reconfigure-messages are not symptom of an error)
if(lyxerr) include(${PARAMS_DIR}/CheckLoadErrors.cmake)
set(ConfigureOutput 0) CheckLoadErrors(lyxerr "${PARAMS_DIR}" _erg)
file(STRINGS "${PARAMS_DIR}/filterCheckWarnings" ignoreRegexp)
# Split lyxerr into lines
string(REGEX REPLACE "[\n]+" ";" foundErrors ${lyxerr})
foreach(_l ${foundErrors})
if(ConfigureOutput)
if(_l MATCHES "LyX: Done!")
set(ConfigureOutput 0)
endif()
else()
if(_l MATCHES "reconfiguring user directory")
set(ConfigureOutput 1)
endif()
endif()
if(NOT ConfigureOutput)
set(found 0)
foreach(_r ${ignoreRegexp})
if(_l MATCHES "${_r}")
set(found 1)
break()
endif()
endforeach()
if(NOT found)
message(STATUS "Error line = ${_l}")
# It is error, because the error-line does not match
# any ignoring expression
set(_erg 1)
break()
endif()
endif()
endforeach()
endif()
if(_erg) if(_erg)
# We print here the whole error output, even the ignored part # We print here the whole error output, even the ignored part

View File

@ -7,8 +7,8 @@
# LYX_ROOT = ${TOP_SRC_DIR}/lib/{doc,examples,templates} # LYX_ROOT = ${TOP_SRC_DIR}/lib/{doc,examples,templates}
# LYX_USERDIR_VER = Name of environment variable for the user directory # LYX_USERDIR_VER = Name of environment variable for the user directory
# lyx = # lyx =
# format = lyx16x|xhtml # format = lyx16x|lyx21x|xhtml
# extension = 16.lyx|xhtml # extension = 16.lyx|21.lyx|xhtml
# file = xxx # file = xxx
# #
# Script should be called like: # Script should be called like:
@ -68,6 +68,25 @@ if (NOT _err)
endif() endif()
endif() endif()
include(${TOP_SRC_DIR}/development/autotests/CheckLoadErrors.cmake)
# If no error, and extension matches '\.lyx$', try to load the created lyx file
if (NOT _err)
if (result_file_name MATCHES "\\.lyx$")
message(STATUS "check load of ${result_file_name}")
set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}")
set(ENV{LANG} "en") # to get all error-messages in english
execute_process(
COMMAND ${lyx} -batch -userdir "${LYX_TESTS_USERDIR}" ${result_file_name}
RESULT_VARIABLE _err
ERROR_VARIABLE lyxerr)
if (NOT _err)
CheckLoadErrors(lyxerr "${TOP_SRC_DIR}/development/autotests" _err)
endif()
else()
message(STATUS "\"${result_file_name}\" is not a lyx file, do not check load")
endif()
endif()
if(inverted) if(inverted)
string(COMPARE EQUAL ${_err} 0 _erg) string(COMPARE EQUAL ${_err} 0 _erg)
else() else()
@ -75,6 +94,6 @@ else()
endif() endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${TempDir}") execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${TempDir}")
if(_erg) if(_erg)
message(STATUS "Exporting ${f}.lyx to ${format}") message(STATUS "Exporting ${file}.lyx to ${format}")
message(FATAL_ERROR "Export failed") message(FATAL_ERROR "Export failed")
endif() endif()