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