commit ea70c1ff0d5071806014415a4f965a413d99295a
Author: Kornel Benko <[email protected]>
Date:   Fri Oct 30 13:28:20 2015 +0100

    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.

diff --git a/src/tex2lyx/test/CMakeLists.txt b/src/tex2lyx/test/CMakeLists.txt
index 304e162..55510a4 100644
--- a/src/tex2lyx/test/CMakeLists.txt
+++ b/src/tex2lyx/test/CMakeLists.txt
@@ -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 LyxTestFiles)
+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(cleanupdatetex2lyxtests DEPENDS UpdateFilesRemoved)
+set_target_properties(cleanupdatetex2lyxtests PROPERTIES FOLDER 
"tests/tex2lyx")
diff --git a/src/tex2lyx/test/env_custom_command.cmake 
b/src/tex2lyx/test/env_custom_command.cmake
index 24acaae..1d3332d 100644
--- a/src/tex2lyx/test/env_custom_command.cmake
+++ b/src/tex2lyx/test/env_custom_command.cmake
@@ -3,13 +3,14 @@
 #
 # Copyright (c) 2015 Kornel Benko <[email protected]>
 #
-# 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()
 

Reply via email to