]> git.lyx.org Git - lyx.git/blob - src/tex2lyx/test/CMakeLists.txt
Small update of TODO
[lyx.git] / src / tex2lyx / test / CMakeLists.txt
1 # This file is part of LyX, the document processor.
2 # Licence details can be found in the file COPYING.
3 #
4 # Copyright (c) 2012 Kornel Benko, <kornel@lyx.org>
5 #
6
7 project(testTex2lyx)
8
9 #file(GLOB _tex_tests RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*.ltx" "${CMAKE_CURRENT_SOURCE_DIR}/*.tex")
10 #
11 #list(REMOVE_ITEM _tex_tests DummyDocument.tex)
12
13 set(_tex_tests test.ltx
14                algo2e.tex
15                box-color-size-space-align.tex
16                CJK.tex
17                CJKutf8.tex
18                test-insets-basic.tex
19                test-insets.tex
20                test-memoir.tex
21                test-minted.tex
22                test-modules.tex
23                test-refstyle-theorems.tex
24                test-scr.tex
25                test-structure.tex
26                verbatim.tex
27                XeTeX-polyglossia.tex)
28
29 set(runtestsScript "${TOP_SRC_DIR}/src/tex2lyx/test/runtests.py")
30 set(scriptDir "${TOP_SRC_DIR}/lib/scripts")
31
32 foreach(_fl ${_tex_tests})
33   set(fl ${_fl})
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}
44       -DTESTFILE=${fl}
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}
58       -DTESTFILE=${fl}
59       -P ${TOP_SRC_DIR}/src/tex2lyx/test/runtests.cmake)
60   set_tests_properties(tex2lyx/cmplyx/${_fl} PROPERTIES RESOURCE_LOCK "runtests.lock" LABELS "cmplyx")
61 endforeach()
62
63 add_dependencies(lyx_run_tests ${_tex2lyx} ${_lyx})
64
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")
71   endif()
72 endforeach()
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}")
75 endforeach()
76 list(APPEND LyxRemoveFiles "${TOP_SRC_DIR}/lib/examples/longsheet.tex")
77
78 add_custom_command(
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}
89   )
90
91 add_custom_target(updatetex2lyxtests DEPENDS Tex2lyxFilesUpdated)
92 set_target_properties(updatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")
93
94 # In order to not pollute the source directory
95 # now remove some untracked files created by the target updatetex2lyxtests
96 add_custom_command(
97   OUTPUT UpdateFilesRemoved
98   COMMAND ${CMAKE_COMMAND} -E remove -f ${LyxRemoveFiles}
99   COMMAND ${CMAKE_COMMAND} -E touch UpdateFilesRemoved
100   DEPENDS Tex2lyxFilesUpdated
101 )
102
103 add_custom_target(cleanupdatetex2lyxtests DEPENDS UpdateFilesRemoved)
104 set_target_properties(cleanupdatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")