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