Cmake lyx2lyx tests: Use a loop to execute roundtrips

Exporting to some previous lyx format:
Inside the loop
  Stop at export with errors/warnings
  Stop if exported file not loadable
  Stop if exported file identical to previous exported file (OK case)
    This is done through creating MD5SUM
This commit is contained in:
Kornel Benko 2015-12-28 06:00:10 +01:00
parent 8d1d46743b
commit a10b671317
2 changed files with 85 additions and 45 deletions

View File

@ -317,7 +317,7 @@ foreach(libsubfolderx autotests/export lib/doc lib/examples lib/templates autote
-DLYX_USERDIR_VER=${LYX_USERDIR_VER} -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
-Dformat=lyx${_lyx_format_num}x -Dformat=lyx${_lyx_format_num}x
-Dextension=${_lyx_format_num}.lyx -Dextension=${_lyx_format_num}.lyx
-Dextension2=${_lyx_format_num}.${_lyx_format_num}.lyx -DLYX_FORMAT_NUM=${_lyx_format_num}
-Dfile=${f} -Dfile=${f}
-Dinverted=${inverted} -Dinverted=${inverted}
-DTOP_SRC_DIR=${TOP_SRC_DIR} -DTOP_SRC_DIR=${TOP_SRC_DIR}

View File

@ -20,6 +20,7 @@
# -Dformat=xxx \ # -Dformat=xxx \
# -Dfonttype=xxx \ # -Dfonttype=xxx \
# -Dextension=xxx \ # -Dextension=xxx \
# -DLYX_FORMAT_NUM=${_lyx_format_num} \
# -Dfile=xxx \ # -Dfile=xxx \
# -Dinverted=[01] \ # -Dinverted=[01] \
# -DTOP_SRC_DIR=${TOP_SRC_DIR} # -DTOP_SRC_DIR=${TOP_SRC_DIR}
@ -51,60 +52,99 @@ else()
message(STATUS "Not converting") message(STATUS "Not converting")
set(LYX_SOURCE "${LYX_ROOT}/${file}.lyx") set(LYX_SOURCE "${LYX_ROOT}/${file}.lyx")
# Font-type not relevant for lyx16/lyx21 exports # Font-type not relevant for lyx16/lyx21 exports
set(result_file_name ${file}.${extension}) set(result_file_base ${file})
set(result_file_name2 ${file}.${extension2})
endif() endif()
message(STATUS "Executing ${lyx} -userdir \"${LYX_TESTS_USERDIR}\" -E ${format} ${result_file_name} \"${LYX_SOURCE}\"")
set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}") set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${result_file_name} ${result_file_name}.emergency) if (extension MATCHES "\\.lyx$")
execute_process( set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}")
COMMAND ${lyx} -userdir "${LYX_TESTS_USERDIR}" -E ${format} ${result_file_name} "${LYX_SOURCE}" set(ENV{LANG} "en") # to get all error-messages in english
RESULT_VARIABLE _err)
#check if result file created include(${TOP_SRC_DIR}/development/autotests/CheckLoadErrors.cmake)
if (NOT _err) execute_process(
if (NOT EXISTS "${result_file_name}") COMMAND ${CMAKE_COMMAND} -E md5sum "${LYX_SOURCE}"
message(STATUS "Expected result file \"${result_file_name}\" does not exist") OUTPUT_VARIABLE source_md5sum_x
set(_err -1) RESULT_VARIABLE _err
else() ERROR_VARIABLE lyxerr)
message(STATUS "Expected result file \"${result_file_name}\" exists") string(REGEX REPLACE " .*" "" source_md5sum ${source_md5sum_x})
endif() message(STATUS "MD5SUM of \"${LYX_SOURCE}\" is ${source_md5sum}")
endif() foreach(_lv RANGE 1 5)
set(result_file_base "${result_file_base}.${LYX_FORMAT_NUM}")
include(${TOP_SRC_DIR}/development/autotests/CheckLoadErrors.cmake) set(result_file_name "${result_file_base}.lyx")
# If no error, and extension matches '\.lyx$', try to load the created lyx file file(REMOVE "${result_file_name}" "${result_file_name}.emergency" )
if (NOT _err) message(STATUS "Executing ${lyx} -userdir \"${LYX_TESTS_USERDIR}\" -E ${format} ${result_file_name} \"${LYX_SOURCE}\"")
if (result_file_name MATCHES "\\.lyx$") execute_process(
set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}") COMMAND ${lyx} -userdir "${LYX_TESTS_USERDIR}" -E ${format} ${result_file_name} "${LYX_SOURCE}"
set(ENV{LANG} "en") # to get all error-messages in english RESULT_VARIABLE _err
ERROR_VARIABLE lyxerr)
if(_err)
break()
else()
if (NOT EXISTS "${result_file_name}")
message(STATUS "Expected result file \"${result_file_name}\" does not exist")
set(_err -1)
break()
else()
message(STATUS "Expected result file \"${result_file_name}\" exists")
checkLoadErrors(lyxerr "${TOP_SRC_DIR}/development/autotests" _err)
if(_err)
break()
endif()
endif()
endif()
execute_process(
COMMAND ${CMAKE_COMMAND} -E md5sum ${result_file_name}
OUTPUT_VARIABLE result_md5sum_x
RESULT_VARIABLE _err
ERROR_VARIABLE lyxerr)
string(REGEX REPLACE " .*" "" result_md5sum ${result_md5sum_x})
message(STATUS "MD5SUM of \"${result_file_name}\" is ${result_md5sum}")
if(_err)
break()
endif()
message(STATUS "check structures of ${result_file_name}") message(STATUS "check structures of ${result_file_name}")
execute_process( execute_process(
COMMAND ${PERL_EXECUTABLE} ${Structure_Script} "${WORKDIR}/${result_file_name}" COMMAND ${PERL_EXECUTABLE} ${Structure_Script} "${WORKDIR}/${result_file_name}"
RESULT_VARIABLE _err RESULT_VARIABLE _err
ERROR_VARIABLE lyxerr) ERROR_VARIABLE lyxerr)
if (NOT _err) if(_err)
message(STATUS "check load of ${result_file_name}") break()
execute_process( endif()
COMMAND ${lyx} -batch -userdir "${LYX_TESTS_USERDIR}" ${result_file_name} message(STATUS "check load of ${result_file_name}")
RESULT_VARIABLE _err execute_process(
ERROR_VARIABLE lyxerr) COMMAND ${lyx} -batch -userdir "${LYX_TESTS_USERDIR}" ${result_file_name}
if (NOT _err) RESULT_VARIABLE _err
CheckLoadErrors(lyxerr "${TOP_SRC_DIR}/development/autotests" _err) ERROR_VARIABLE lyxerr)
if (NOT _err) if(_err)
execute_process( break()
COMMAND ${lyx} -userdir "${LYX_TESTS_USERDIR}" -E ${format} ${result_file_name2} ${result_file_name} endif()
RESULT_VARIABLE _err checkLoadErrors(lyxerr "${TOP_SRC_DIR}/development/autotests" _err)
ERROR_VARIABLE lyxerr) if(_err)
if (NOT _err) break()
message(STATUS "check load of ${result_file_name2}") endif()
CheckLoadErrors(lyxerr "${TOP_SRC_DIR}/development/autotests" _err) # Check if result file identical to source file
endif() if(result_md5sum STREQUAL ${source_md5sum})
endif() message(STATUS "Source(${LYX_SOURCE}) and dest(${result_file_name}) are equal")
endif() break()
endif()
set(source_md5sum ${result_md5sum})
set(LYX_SOURCE ${result_file_name})
endforeach()
else()
message(STATUS "Executing ${lyx} -userdir \"${LYX_TESTS_USERDIR}\" -E ${format} ${result_file_name} \"${LYX_SOURCE}\"")
file(REMOVE ${result_file_name})
execute_process(
COMMAND ${lyx} -userdir "${LYX_TESTS_USERDIR}" -E ${format} ${result_file_name} "${LYX_SOURCE}"
RESULT_VARIABLE _err)
#check if result file created
if (NOT _err)
if (NOT EXISTS "${result_file_name}")
message(STATUS "Expected result file \"${result_file_name}\" does not exist")
set(_err -1)
else()
message(STATUS "Expected result file \"${result_file_name}\" exists")
endif() endif()
else()
message(STATUS "\"${result_file_name}\" is not a lyx file, do not check load")
endif() endif()
endif() endif()