Cmake tests: Display process while executing for target updatetex2lyxtests

The execution took some time and the messages were delayed
until all test files were processed. Now as each testfile
is processed, the appropriate messages are printed.

There is also a new target: cleanupdatetex2lyxtests
It is the same as updatetex2lyxtests, but removes also
some extra created files from the source directory.
This commit is contained in:
Kornel Benko 2015-10-30 13:28:20 +01:00
parent 50e99b82c9
commit ea70c1ff0d
2 changed files with 49 additions and 20 deletions

View File

@ -61,17 +61,43 @@ endforeach()
add_dependencies(lyx_run_tests ${_tex2lyx} ${_lyx})
set(LyxTestFiles "") # "'" separated test-filenames
set(LyxRemoveFiles) # Extra files created by runtests.py
foreach(_fl ${_tex_tests})
set(LyxTestFiles "${LyxTestFiles}'${_fl}")
if (_fl MATCHES "^\(.*\)\\.\([^\\.]+)$")
list(APPEND LyxRemoveFiles "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_MATCH_1}.lyx.tex")
endif()
endforeach()
foreach(_lrf "DummyDocument.lyx.tex" "Dummy~Document.lyx.tex" "foo.pdf" "xfigtest.pdf" "xfigtest.pdftex_t")
list(APPEND LyxRemoveFiles "${CMAKE_CURRENT_SOURCE_DIR}/${_lrf}")
endforeach()
list(APPEND LyxRemoveFiles "${TOP_SRC_DIR}/lib/examples/longsheet.tex")
add_custom_command(
OUTPUT LyxTestFiles
COMMAND ${CMAKE_COMMAND} -E touch LyxTestFiles
OUTPUT Tex2lyxFilesUpdated
COMMAND ${CMAKE_COMMAND}
-DENVIRON="${LYX_USERDIR_VER}=${LYX_TESTS_USERDIR}"
-DCOMMAND="${LYX_PYTHON_EXECUTABLE}"
-DPARAMS="${runtestsScript}'$<TARGET_FILE:${_tex2lyx}>'${scriptDir}'${CMAKE_CURRENT_SOURCE_DIR}"
-P ${TOP_SRC_DIR}/src/tex2lyx/test/env_custom_command.cmake
-DCOMMAND="${LYX_PYTHON_EXECUTABLE}"
-DENVIRON="${LYX_USERDIR_VER}=${LYX_TESTS_USERDIR}"
-DPARAMS="${runtestsScript}'$<TARGET_FILE:${_tex2lyx}>'${scriptDir}'${CMAKE_CURRENT_SOURCE_DIR}"
-DSINGLEPARLIST="${LyxTestFiles}"
-P ${TOP_SRC_DIR}/src/tex2lyx/test/env_custom_command.cmake
COMMAND ${CMAKE_COMMAND} -E touch Tex2lyxFilesUpdated
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
DEPENDS ${_tex2lyx} ${_lyx}
)
add_custom_target(updatetex2lyxtests DEPENDS Tex2lyxFilesUpdated)
set_target_properties(updatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")
# In order to not pollute the source directory
# now remove some untracked files created by the target updatetex2lyxtests
add_custom_command(
OUTPUT UpdateFilesRemoved
COMMAND ${CMAKE_COMMAND} -E remove -f ${LyxRemoveFiles}
COMMAND ${CMAKE_COMMAND} -E touch UpdateFilesRemoved
DEPENDS Tex2lyxFilesUpdated
)
add_custom_target(updatetex2lyxtests DEPENDS LyxTestFiles)
set_target_properties(updatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")
add_custom_target(cleanupdatetex2lyxtests DEPENDS UpdateFilesRemoved)
set_target_properties(cleanupdatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")

View File

@ -3,13 +3,14 @@
#
# Copyright (c) 2015 Kornel Benko <kornel@lyx.org>
#
# Environ and parameter strings are separated by "'"
# ENVIRON, SINGLEPARLIST and PARAMS strings are separated by "'"
# Script should be called like:
# add_custom_command(
# COMMAND ${CMAKE_COMMAND}
# -DENVIRON="${LYX_USERDIR_VER}=${LYX_TESTS_USERDIR}" \
# -DCOMMAND="${LYX_PYTHON_EXECUTABLE}" \
# -DCOMMAND="${LYX_PYTHON_EXECUTABLE}"
# -DENVIRON="${LYX_USERDIR_VER}=${LYX_TESTS_USERDIR}"
# -DPARAMS="${runtestsScript}'$<TARGET_FILE:${_tex2lyx}>'${scriptDir}'${CMAKE_CURRENT_SOURCE_DIR}"
# -DSINGLEPARLIST="${LyxTestFiles}"
# -P ${TOP_SRC_DIR}/src/tex2lyx/test/env_custom_command.cmake
# WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
# DEPENDS ...
@ -26,15 +27,17 @@ foreach(_env ${ENVIRON_LIST})
endforeach()
string(REGEX MATCHALL "[^']+" parameters "${PARAMS}")
execute_process(COMMAND "${COMMAND}" ${parameters}
RESULT_VARIABLE _err
OUTPUT_VARIABLE _out)
string(REGEX MATCHALL "[^']+" extrasingleparamlist "${SINGLEPARLIST}")
message(STATUS ${_out})
#message(STATUS "Error output of \"${COMMAND}\" " ${parameters} " = ${_err}")
string(COMPARE NOTEQUAL ${_err} 0 _erg)
foreach(_extraparam ${extrasingleparamlist} )
execute_process(COMMAND "${COMMAND}" ${parameters} ${_extraparam}
RESULT_VARIABLE _err
OUTPUT_VARIABLE _out)
if(_erg)
message(FATAL_ERROR "\"${COMMAND}\" ${parameters} failed")
endif()
message(STATUS ${_out})
string(COMPARE NOTEQUAL ${_err} 0 _erg)
if(_erg)
message(FATAL_ERROR "\"${COMMAND}\" ${parameters} failed")
endif()
endforeach()