From e3cd6db4a789c5df4ba32672fdbd8dac965afb92 Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Fri, 25 Dec 2015 10:28:40 +0100 Subject: [PATCH] Cmake export tests: Check if exported lyx files are loadable Also added tests for export to lyx21 format. --- development/autotests/ExportTests.cmake | 44 +++++++++++++------------ development/autotests/check_load.cmake | 35 ++------------------ development/autotests/export.cmake | 25 ++++++++++++-- 3 files changed, 47 insertions(+), 57 deletions(-) diff --git a/development/autotests/ExportTests.cmake b/development/autotests/ExportTests.cmake index a2c07a770b..fbf2eba180 100644 --- a/development/autotests/ExportTests.cmake +++ b/development/autotests/ExportTests.cmake @@ -136,7 +136,7 @@ macro(maketestname testname inverted listsuspicious listignored listunreliable l set(sublabel "unreliable" ${sublabel} ${sublabel2}) list(REMOVE_ITEM sublabel "export" "inverted" "templates" "mathmacros" "manuals" "autotests") 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 set(sublabel2 "") if (_v) @@ -303,26 +303,28 @@ foreach(libsubfolderx autotests/export lib/doc lib/examples lib/templates autote foreach(f ${nolang_lyx_files} ${lang_lyx_files}) # Strip extension string(REGEX REPLACE "\\.lyx$" "" f ${f}) - set(TestName "export/${libsubfolder}/${f}_lyx16") - set(mytestlabel ${testlabel}) - maketestname(TestName inverted suspiciousTests ignoredTests unreliableTests mytestlabel) - if(TestName) - add_test(NAME ${TestName} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}" - COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR} - -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} - -Dlyx=$ - -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME} - -DLYX_USERDIR_VER=${LYX_USERDIR_VER} - -Dformat=lyx16x - -Dextension=16.lyx - -Dfile=${f} - -Dinverted=${inverted} - -DTOP_SRC_DIR=${TOP_SRC_DIR} - -DPERL_EXECUTABLE=${PERL_EXECUTABLE} - -P "${TOP_SRC_DIR}/development/autotests/export.cmake") - setmarkedtestlabel(${TestName} ${mytestlabel}) - endif() + foreach(_lyx_format_num 16 21) + set(TestName "export/${libsubfolder}/${f}_lyx${_lyx_format_num}") + set(mytestlabel ${testlabel}) + maketestname(TestName inverted suspiciousTests ignoredTests unreliableTests mytestlabel) + if(TestName) + add_test(NAME ${TestName} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}" + COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${LIBSUB_SRC_DIR} + -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} + -Dlyx=$ + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME} + -DLYX_USERDIR_VER=${LYX_USERDIR_VER} + -Dformat=lyx${_lyx_format_num}x + -Dextension=${_lyx_format_num}.lyx + -Dfile=${f} + -Dinverted=${inverted} + -DTOP_SRC_DIR=${TOP_SRC_DIR} + -DPERL_EXECUTABLE=${PERL_EXECUTABLE} + -P "${TOP_SRC_DIR}/development/autotests/export.cmake") + setmarkedtestlabel(${TestName} ${mytestlabel}) + endif() + endforeach() if(LYX_PYTHON_EXECUTABLE) set(lyx2lyxtestlabel "lyx2lyx") # For use of lyx2lyx we need the python executable diff --git a/development/autotests/check_load.cmake b/development/autotests/check_load.cmake index 4a22a27fa4..e4872009ba 100644 --- a/development/autotests/check_load.cmake +++ b/development/autotests/check_load.cmake @@ -32,39 +32,8 @@ string(COMPARE NOTEQUAL ${_err} 0 _erg) # # Ignore messages between "reconfiguring user directory" and "LyX: Done!" # (Reconfigure-messages are not symptom of an error) -if(lyxerr) - set(ConfigureOutput 0) - 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() +include(${PARAMS_DIR}/CheckLoadErrors.cmake) +CheckLoadErrors(lyxerr "${PARAMS_DIR}" _erg) if(_erg) # We print here the whole error output, even the ignored part diff --git a/development/autotests/export.cmake b/development/autotests/export.cmake index 6ff47187e2..0f2cbf2801 100755 --- a/development/autotests/export.cmake +++ b/development/autotests/export.cmake @@ -7,8 +7,8 @@ # LYX_ROOT = ${TOP_SRC_DIR}/lib/{doc,examples,templates} # LYX_USERDIR_VER = Name of environment variable for the user directory # lyx = -# format = lyx16x|xhtml -# extension = 16.lyx|xhtml +# format = lyx16x|lyx21x|xhtml +# extension = 16.lyx|21.lyx|xhtml # file = xxx # # Script should be called like: @@ -68,6 +68,25 @@ if (NOT _err) 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) string(COMPARE EQUAL ${_err} 0 _erg) else() @@ -75,6 +94,6 @@ else() endif() execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${TempDir}") if(_erg) - message(STATUS "Exporting ${f}.lyx to ${format}") + message(STATUS "Exporting ${file}.lyx to ${format}") message(FATAL_ERROR "Export failed") endif() -- 2.39.2