]> git.lyx.org Git - lyx.git/blob - src/tex2lyx/test/CMakeLists.txt
Amend 26ea1e1 for roundtrip tests
[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                beamer.tex
16                box-color-size-space-align.tex
17                CJK.tex
18                CJKutf8.tex
19                test-insets-basic.tex
20                test-insets.tex
21                test-memoir.tex
22                test-minted.tex
23                test-modules.tex
24                test-refstyle-theorems.tex
25                test-scr.tex
26                test-structure.tex
27                verbatim.tex
28                XeTeX-polyglossia.tex)
29
30 set(runtestsScript "${TOP_SRC_DIR}/src/tex2lyx/test/runtests.py")
31 set(scriptDir "${TOP_SRC_DIR}/lib/scripts")
32
33 foreach(_fl ${_tex_tests})
34   set(fl ${_fl})
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}
45       -DTESTFILE=${fl}
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}
59       -DTESTFILE=${fl}
60       -P ${TOP_SRC_DIR}/src/tex2lyx/test/runtests.cmake)
61   set_tests_properties(tex2lyx/cmplyx/${_fl} PROPERTIES RESOURCE_LOCK "runtests.lock" LABELS "cmplyx")
62 endforeach()
63
64 add_dependencies(lyx_run_tests ${_tex2lyx} ${_lyx})
65
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")
72   endif()
73 endforeach()
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}")
76 endforeach()
77 list(APPEND LyxRemoveFiles "${TOP_SRC_DIR}/lib/examples/longsheet.tex")
78
79 add_custom_command(
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}
90   )
91
92 add_custom_target(updatetex2lyxtests DEPENDS Tex2lyxFilesUpdated)
93 set_target_properties(updatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")
94
95 # In order to not pollute the source directory
96 # now remove some untracked files created by the target updatetex2lyxtests
97 add_custom_command(
98   OUTPUT UpdateFilesRemoved
99   COMMAND ${CMAKE_COMMAND} -E remove -f ${LyxRemoveFiles}
100   COMMAND ${CMAKE_COMMAND} -E touch UpdateFilesRemoved
101   DEPENDS Tex2lyxFilesUpdated
102 )
103
104 add_custom_target(cleanupdatetex2lyxtests DEPENDS UpdateFilesRemoved)
105 set_target_properties(cleanupdatetex2lyxtests PROPERTIES FOLDER "tests/tex2lyx")