1 # This file is part of LyX, the document processor.
2 # Licence details can be found in the file COPYING.
4 # Copyright (c) 2012 Kornel Benko, <kornel@lyx.org>
9 #file(GLOB _tex_tests RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*.ltx" "${CMAKE_CURRENT_SOURCE_DIR}/*.tex")
11 #list(REMOVE_ITEM _tex_tests DummyDocument.tex)
13 set(_tex_tests test.ltx
16 box-color-size-space-align.tex
26 test-refstyle-theorems.tex
30 XeTeX-polyglossia.tex)
32 set(runtestsScript "${TOP_SRC_DIR}/src/tex2lyx/test/runtests.py")
33 set(scriptDir "${TOP_SRC_DIR}/lib/scripts")
35 foreach(_fl ${_tex_tests})
37 add_test(NAME tex2lyx/roundtrip/${_fl}
38 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
39 COMMAND ${CMAKE_COMMAND}
40 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
41 -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
42 -DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}
43 -DPY_SCRIPT=${runtestsScript}
44 -DTEX2LYX_EXE=$<TARGET_FILE:${_tex2lyx}>
45 -DSCRIPT_DIR=${scriptDir}
46 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}
48 -P ${TOP_SRC_DIR}/src/tex2lyx/test/runtests.cmake)
49 set_tests_properties(tex2lyx/roundtrip/${_fl} PROPERTIES RESOURCE_LOCK "runtests.lock" LABELS "roundtrip:tex2lyx")
50 add_test(NAME tex2lyx/cmplyx/${_fl}
51 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
52 COMMAND ${CMAKE_COMMAND}
53 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
54 -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
55 -DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}
56 -DPY_SCRIPT=${runtestsScript}
57 -DFIRST_PARAM=uselyx2lyx
58 -DTEX2LYX_EXE=$<TARGET_FILE:${_tex2lyx}>
59 -DSCRIPT_DIR=${scriptDir}
60 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}
62 -P ${TOP_SRC_DIR}/src/tex2lyx/test/runtests.cmake)
63 set_tests_properties(tex2lyx/cmplyx/${_fl} PROPERTIES RESOURCE_LOCK "runtests.lock" LABELS "cmplyx:tex2lyx")
66 add_dependencies(lyx_run_tests ${_tex2lyx} ${_lyx})
68 set(LyxTestFiles "") # "'" separated test-filenames
69 set(LyxRemoveFiles) # Extra files created by runtests.py
70 foreach(_fl ${_tex_tests})
71 set(LyxTestFiles "${LyxTestFiles}'${_fl}")
72 if (_fl MATCHES "^\(.*\)\\.\([^\\.]+)$")
73 list(APPEND LyxRemoveFiles "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_MATCH_1}.lyx.tex")
76 foreach(_lrf "DummyDocument.lyx.tex" "Dummy~Document.lyx.tex" "foo.pdf" "xfigtest.pdf" "xfigtest.pdftex_t")
77 list(APPEND LyxRemoveFiles "${CMAKE_CURRENT_SOURCE_DIR}/${_lrf}")
79 list(APPEND LyxRemoveFiles "${TOP_SRC_DIR}/lib/examples/longsheet.tex")
82 OUTPUT Tex2lyxFilesUpdated
83 COMMAND ${CMAKE_COMMAND}
84 -DCOMMAND="${LYX_PYTHON_EXECUTABLE}"
85 -DENVIRON="${LYX_USERDIR_VER}=${LYX_TESTS_USERDIR}"
86 -DPARAMS="${runtestsScript}'$<TARGET_FILE:${_tex2lyx}>'${scriptDir}'${CMAKE_CURRENT_SOURCE_DIR}"
87 -DSINGLEPARLIST="${LyxTestFiles}"
88 -P ${TOP_SRC_DIR}/src/tex2lyx/test/env_custom_command.cmake
89 COMMAND ${CMAKE_COMMAND} -E touch Tex2lyxFilesUpdated
90 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
91 DEPENDS ${_tex2lyx} ${_lyx}
94 add_custom_target(updatetex2lyxtests DEPENDS Tex2lyxFilesUpdated)
95 set_target_properties(updatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")
97 # In order to not pollute the source directory
98 # now remove some untracked files created by the target updatetex2lyxtests
100 OUTPUT UpdateFilesRemoved
101 COMMAND ${CMAKE_COMMAND} -E remove -f ${LyxRemoveFiles}
102 COMMAND ${CMAKE_COMMAND} -E touch UpdateFilesRemoved
103 DEPENDS Tex2lyxFilesUpdated
106 add_custom_target(cleanupdatetex2lyxtests DEPENDS UpdateFilesRemoved)
107 set_target_properties(cleanupdatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")