]> git.lyx.org Git - lyx.git/commitdiff
Cmake tests: Display process while executing for target updatetex2lyxtests
authorKornel Benko <kornel@lyx.org>
Fri, 30 Oct 2015 12:28:20 +0000 (13:28 +0100)
committerKornel Benko <kornel@lyx.org>
Fri, 30 Oct 2015 12:28:20 +0000 (13:28 +0100)
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.

src/tex2lyx/test/CMakeLists.txt
src/tex2lyx/test/env_custom_command.cmake

index 304e1623f3023a48dc635b3428bb68226da0529b..55510a43a3de9502b6e091f35db8e0475cd87719 100644 (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 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")
index 24acaae3b567a77f7d99c04f16cf55a562a0170a..1d3332d29785a175f167464fb6c647e604f93454 100644 (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()