]> git.lyx.org Git - lyx.git/blob - src/tex2lyx/test/CMakeLists.txt
tex2lyx: import minted listings
[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-modules.tex
22                test-refstyle-theorems.tex
23                test-scr.tex
24                test-structure.tex
25                verbatim.tex
26                XeTeX-polyglossia.tex)
27
28 set(runtestsScript "${TOP_SRC_DIR}/src/tex2lyx/test/runtests.py")
29 set(scriptDir "${TOP_SRC_DIR}/lib/scripts")
30
31 foreach(_fl ${_tex_tests})
32   set(fl ${_fl})
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}
43       -DTESTFILE=${fl}
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}
57       -DTESTFILE=${fl}
58       -P ${TOP_SRC_DIR}/src/tex2lyx/test/runtests.cmake)
59   set_tests_properties(tex2lyx/cmplyx/${_fl} PROPERTIES RESOURCE_LOCK "runtests.lock" LABELS "cmplyx")
60 endforeach()
61
62 add_dependencies(lyx_run_tests ${_tex2lyx} ${_lyx})
63
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")
70   endif()
71 endforeach()
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}")
74 endforeach()
75 list(APPEND LyxRemoveFiles "${TOP_SRC_DIR}/lib/examples/longsheet.tex")
76
77 add_custom_command(
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}
88   )
89
90 add_custom_target(updatetex2lyxtests DEPENDS Tex2lyxFilesUpdated)
91 set_target_properties(updatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")
92
93 # In order to not pollute the source directory
94 # now remove some untracked files created by the target updatetex2lyxtests
95 add_custom_command(
96   OUTPUT UpdateFilesRemoved
97   COMMAND ${CMAKE_COMMAND} -E remove -f ${LyxRemoveFiles}
98   COMMAND ${CMAKE_COMMAND} -E touch UpdateFilesRemoved
99   DEPENDS Tex2lyxFilesUpdated
100 )
101
102 add_custom_target(cleanupdatetex2lyxtests DEPENDS UpdateFilesRemoved)
103 set_target_properties(cleanupdatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")