]> git.lyx.org Git - features.git/blob - src/tex2lyx/test/CMakeLists.txt
1b3b68d38a777d643f389dcb529fcb7dcd4d551c
[features.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                beamer.tex
16                box-color-size-space-align.tex
17                CJK.tex
18                CJKutf8.tex
19                listpreamble.tex
20                tabular-x-test.tex
21                test-insets-basic.tex
22                test-insets.tex
23                test-memoir.tex
24                    test-minted.tex
25                test-modules.tex
26                test-refstyle-theorems.tex
27                test-scr.tex
28                test-structure.tex
29                verbatim.tex
30                XeTeX-polyglossia.tex)
31
32 set(runtestsScript "${TOP_SRC_DIR}/src/tex2lyx/test/runtests.py")
33 set(scriptDir "${TOP_SRC_DIR}/lib/scripts")
34
35 foreach(_fl ${_tex_tests})
36   set(fl ${_fl})
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}
47       -DTESTFILE=${fl}
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}
61       -DTESTFILE=${fl}
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")
64 endforeach()
65
66 add_dependencies(lyx_run_tests ${_tex2lyx} ${_lyx})
67
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")
74   endif()
75 endforeach()
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}")
78 endforeach()
79 list(APPEND LyxRemoveFiles "${TOP_SRC_DIR}/lib/examples/longsheet.tex")
80
81 add_custom_command(
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}
92   )
93
94 add_custom_target(updatetex2lyxtests DEPENDS Tex2lyxFilesUpdated)
95 set_target_properties(updatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")
96
97 # In order to not pollute the source directory
98 # now remove some untracked files created by the target updatetex2lyxtests
99 add_custom_command(
100   OUTPUT UpdateFilesRemoved
101   COMMAND ${CMAKE_COMMAND} -E remove -f ${LyxRemoveFiles}
102   COMMAND ${CMAKE_COMMAND} -E touch UpdateFilesRemoved
103   DEPENDS Tex2lyxFilesUpdated
104 )
105
106 add_custom_target(cleanupdatetex2lyxtests DEPENDS UpdateFilesRemoved)
107 set_target_properties(cleanupdatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")