X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftex2lyx%2Ftest%2FCMakeLists.txt;h=e620e067c4bef34364e06cef0e0f7eb2224a5ab1;hb=afd6e1d45e1a535eb8f4016da6207a7d00196a19;hp=19abf65affc38e7222acb51c496ad1e6f2499a23;hpb=6fa12b09718bb1709f0c613c2fb8f40b71f1e147;p=features.git diff --git a/src/tex2lyx/test/CMakeLists.txt b/src/tex2lyx/test/CMakeLists.txt index 19abf65aff..e620e067c4 100644 --- a/src/tex2lyx/test/CMakeLists.txt +++ b/src/tex2lyx/test/CMakeLists.txt @@ -4,32 +4,104 @@ # Copyright (c) 2012 Kornel Benko, # -project(test) - -set(_test_depend "${TOP_SRC_DIR}/src/tex2lyx/test/test.ltx") -set(_test_output "${TOP_SRC_DIR}/src/tex2lyx/test/test.lyx.tex") -foreach(_arg runtests.py DummyDocument.tex test.ltx foo.eps foo.png) - configure_file("${TOP_SRC_DIR}/src/tex2lyx/test/${_arg}" "${CMAKE_CURRENT_BINARY_DIR}/${_arg}" COPYONLY) -endforeach(_arg) - -foreach(_arg test-structure test-insets box-color-size-space-align CJK XeTeX-polyglossia) - add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_arg}.tex" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${TOP_SRC_DIR}/src/tex2lyx/test/${_arg}.tex" "${CMAKE_CURRENT_BINARY_DIR}/${_arg}.tex" - DEPENDS "${TOP_SRC_DIR}/src/tex2lyx/test/${_arg}.tex" - ) - list(APPEND _test_depend "${CMAKE_CURRENT_BINARY_DIR}/${_arg}.tex") - list(APPEND _test_output "${CMAKE_CURRENT_BINARY_DIR}/${_arg}.lyx.tex") - list(APPEND _test_output "${CMAKE_CURRENT_BINARY_DIR}/${_arg}.lyx.lyx") -endforeach(_arg) - -ADD_CUSTOM_COMMAND( - OUTPUT ${_test_output} - COMMAND ${LYX_PYTHON_EXECUTABLE} - ARGS "${CMAKE_CURRENT_BINARY_DIR}/runtests.py" "${TOP_BINARY_DIR}/bin/${_tex2lyx}" "${TOP_SRC_DIR}/lib/scripts" +project(testTex2lyx) + +#file(GLOB _tex_tests RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*.ltx" "${CMAKE_CURRENT_SOURCE_DIR}/*.tex") +# +#list(REMOVE_ITEM _tex_tests DummyDocument.tex) + +set(_tex_tests test.ltx + algo2e.tex + beamer.tex + box-color-size-space-align.tex + CJK.tex + CJKutf8.tex + listpreamble.tex + tabular-x-test.tex + test-insets-basic.tex + test-insets.tex + test-memoir.tex + test-minted.tex + test-modules.tex + test-refstyle-theorems.tex + test-scr.tex + test-structure.tex + verbatim.tex + XeTeX-polyglossia.tex) + +set(runtestsScript "${TOP_SRC_DIR}/src/tex2lyx/test/runtests.py") +set(scriptDir "${TOP_SRC_DIR}/lib/scripts") + +foreach(_fl ${_tex_tests}) + set(fl ${_fl}) + add_test(NAME tex2lyx/roundtrip/${_fl} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + COMMAND ${CMAKE_COMMAND} + -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} + -DLYX_USERDIR_VER=${LYX_USERDIR_VER} + -DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE} + -DPY_SCRIPT=${runtestsScript} + -DTEX2LYX_EXE=$ + -DSCRIPT_DIR=${scriptDir} + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR} + -DTESTFILE=${fl} + -P ${TOP_SRC_DIR}/src/tex2lyx/test/runtests.cmake) + set_tests_properties(tex2lyx/roundtrip/${_fl} PROPERTIES RESOURCE_LOCK "runtests.lock" LABELS "roundtrip:tex2lyx") + add_test(NAME tex2lyx/cmplyx/${_fl} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + COMMAND ${CMAKE_COMMAND} + -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} + -DLYX_USERDIR_VER=${LYX_USERDIR_VER} + -DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE} + -DPY_SCRIPT=${runtestsScript} + -DFIRST_PARAM=uselyx2lyx + -DTEX2LYX_EXE=$ + -DSCRIPT_DIR=${scriptDir} + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR} + -DTESTFILE=${fl} + -P ${TOP_SRC_DIR}/src/tex2lyx/test/runtests.cmake) + set_tests_properties(tex2lyx/cmplyx/${_fl} PROPERTIES RESOURCE_LOCK "runtests.lock" LABELS "cmplyx:tex2lyx") +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 Tex2lyxFilesUpdated + COMMAND ${CMAKE_COMMAND} + -DCOMMAND="${LYX_PYTHON_EXECUTABLE}" + -DENVIRON="${LYX_USERDIR_VER}=${LYX_TESTS_USERDIR}" + -DPARAMS="${runtestsScript}'$'${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} ${_test_depend} -) + DEPENDS ${_tex2lyx} ${_lyx} + ) -ADD_CUSTOM_TARGET(test DEPENDS ${_tex2lyx} ${_test_output}) +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")