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
15 box-color-size-space-align.tex
23 test-refstyle-theorems.tex
27 XeTeX-polyglossia.tex)
29 set(runtestsScript "${TOP_SRC_DIR}/src/tex2lyx/test/runtests.py")
30 set(scriptDir "${TOP_SRC_DIR}/lib/scripts")
32 foreach(_fl ${_tex_tests})
34 add_test(NAME tex2lyx/roundtrip/${_fl}
35 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
36 COMMAND ${CMAKE_COMMAND}
37 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
38 -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
39 -DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}
40 -DPY_SCRIPT=${runtestsScript}
41 -DTEX2LYX_EXE=$<TARGET_FILE:${_tex2lyx}>
42 -DSCRIPT_DIR=${scriptDir}
43 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}
45 -P ${TOP_SRC_DIR}/src/tex2lyx/test/runtests.cmake)
46 set_tests_properties(tex2lyx/roundtrip/${_fl} PROPERTIES RESOURCE_LOCK "runtests.lock" LABELS "roundtrip")
47 add_test(NAME tex2lyx/cmplyx/${_fl}
48 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
49 COMMAND ${CMAKE_COMMAND}
50 -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
51 -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
52 -DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}
53 -DPY_SCRIPT=${runtestsScript}
54 -DFIRST_PARAM=uselyx2lyx
55 -DTEX2LYX_EXE=$<TARGET_FILE:${_tex2lyx}>
56 -DSCRIPT_DIR=${scriptDir}
57 -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}
59 -P ${TOP_SRC_DIR}/src/tex2lyx/test/runtests.cmake)
60 set_tests_properties(tex2lyx/cmplyx/${_fl} PROPERTIES RESOURCE_LOCK "runtests.lock" LABELS "cmplyx")
63 add_dependencies(lyx_run_tests ${_tex2lyx} ${_lyx})
65 set(LyxTestFiles "") # "'" separated test-filenames
66 set(LyxRemoveFiles) # Extra files created by runtests.py
67 foreach(_fl ${_tex_tests})
68 set(LyxTestFiles "${LyxTestFiles}'${_fl}")
69 if (_fl MATCHES "^\(.*\)\\.\([^\\.]+)$")
70 list(APPEND LyxRemoveFiles "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_MATCH_1}.lyx.tex")
73 foreach(_lrf "DummyDocument.lyx.tex" "Dummy~Document.lyx.tex" "foo.pdf" "xfigtest.pdf" "xfigtest.pdftex_t")
74 list(APPEND LyxRemoveFiles "${CMAKE_CURRENT_SOURCE_DIR}/${_lrf}")
76 list(APPEND LyxRemoveFiles "${TOP_SRC_DIR}/lib/examples/longsheet.tex")
79 OUTPUT Tex2lyxFilesUpdated
80 COMMAND ${CMAKE_COMMAND}
81 -DCOMMAND="${LYX_PYTHON_EXECUTABLE}"
82 -DENVIRON="${LYX_USERDIR_VER}=${LYX_TESTS_USERDIR}"
83 -DPARAMS="${runtestsScript}'$<TARGET_FILE:${_tex2lyx}>'${scriptDir}'${CMAKE_CURRENT_SOURCE_DIR}"
84 -DSINGLEPARLIST="${LyxTestFiles}"
85 -P ${TOP_SRC_DIR}/src/tex2lyx/test/env_custom_command.cmake
86 COMMAND ${CMAKE_COMMAND} -E touch Tex2lyxFilesUpdated
87 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
88 DEPENDS ${_tex2lyx} ${_lyx}
91 add_custom_target(updatetex2lyxtests DEPENDS Tex2lyxFilesUpdated)
92 set_target_properties(updatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")
94 # In order to not pollute the source directory
95 # now remove some untracked files created by the target updatetex2lyxtests
97 OUTPUT UpdateFilesRemoved
98 COMMAND ${CMAKE_COMMAND} -E remove -f ${LyxRemoveFiles}
99 COMMAND ${CMAKE_COMMAND} -E touch UpdateFilesRemoved
100 DEPENDS Tex2lyxFilesUpdated
103 add_custom_target(cleanupdatetex2lyxtests DEPENDS UpdateFilesRemoved)
104 set_target_properties(cleanupdatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")