mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-21 21:06:23 +00:00
Cmake build: First try to use autotests.
Many test are not running, but if changed the '-dbg xxx' to '-dbg any' then all of sudden they pass ... (The buffered output of lyx is often disrupted too early with 'kill -9', so the expected data are not available for the appropriate test)
This commit is contained in:
parent
146b754f1d
commit
57b04ac7f4
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,6 +11,7 @@ config.h
|
||||
config.log
|
||||
config.status
|
||||
lyx.1
|
||||
.history
|
||||
stamp-h1
|
||||
*.old
|
||||
|
||||
|
@ -716,6 +716,7 @@ if(LYX_INSTALL)
|
||||
endif()
|
||||
|
||||
add_subdirectory(sourcedoc "${TOP_BINARY_DIR}/sourcedoc")
|
||||
add_subdirectory(development/autotests "${TOP_BINARY_DIR}/autotests")
|
||||
|
||||
message(STATUS)
|
||||
message(STATUS "Build options, switch LYX_* variables by -DLYX_*=ON or OFF:")
|
||||
|
38
development/autotests/CMakeLists.txt
Normal file
38
development/autotests/CMakeLists.txt
Normal file
@ -0,0 +1,38 @@
|
||||
# This file is part of LyX, the document processor.
|
||||
# Licence details can be found in the file COPYING.
|
||||
#
|
||||
# Copyright (c) 2012 Kornel Benko kornel@lyx.org
|
||||
#
|
||||
|
||||
if(UNIX)
|
||||
project(autotests)
|
||||
|
||||
add_subdirectory(xvkbd)
|
||||
|
||||
set(KEYTEST "${CMAKE_CURRENT_SOURCE_DIR}/keytest.py")
|
||||
set(LYX_HOME "out-home")
|
||||
set(LYX_USERDIR "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}/.lyx")
|
||||
set(LOCALE_DIR "${CMAKE_CURRENT_BINARY_DIR}/locale")
|
||||
file(GLOB TESTST RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.txt")
|
||||
file(GLOB TESTSS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*-in.sh")
|
||||
list(REMOVE_ITEM TESTST hello-world-in.txt first-time-in.txt)
|
||||
list(SORT TESTST)
|
||||
file(MAKE_DIRECTORY "${LYX_USERDIR}" "${LOCALE_DIR}")
|
||||
|
||||
foreach(_tf first-time-in.txt hello-world-in.txt ${TESTST})
|
||||
string(REGEX REPLACE "-in\\.(txt|sh)" "" _t ${_tf})
|
||||
add_test(NAME "auto_${_t}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DAUTOTEST_ROOT=${TOP_SRC_DIR}/development/autotests
|
||||
-DKEYTEST_INFILE=${_tf}
|
||||
-DBINDIR=${TOP_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}
|
||||
-DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
|
||||
-DKEYTEST_OUTFILE=${_t}-out.txt
|
||||
-P ${TOP_SRC_DIR}/development/autotests/single-test.cmake)
|
||||
endforeach()
|
||||
add_test(NAME lyx_export
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
|
||||
COMMAND ${CMAKE_COMMAND} -DLYX_ROOT=${TOP_SRC_DIR} -Dlyx=${TOP_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/lyx -P "${TOP_SRC_DIR}/development/autotests/export.cmake")
|
||||
set_tests_properties(lyx_export PROPERTIES DEPENDS lyx)
|
||||
endif()
|
25
development/autotests/export.cmake
Executable file
25
development/autotests/export.cmake
Executable file
@ -0,0 +1,25 @@
|
||||
|
||||
file(GLOB lyx_files "${LYX_ROOT}/lib/doc/*.lyx")
|
||||
message(STATUS "lyx_files = ${lyx_files}")
|
||||
|
||||
set(ERRORS)
|
||||
foreach(format lyx16x xhtml)
|
||||
foreach(f ${lyx_files})
|
||||
message(STATUS "Executing ${lyx} -e ${format} ${f}")
|
||||
#execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${f} localtest.lyx)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E remove localtest.xhtml localtest.16.lyx)
|
||||
execute_process(
|
||||
COMMAND ${lyx} -E ${format} localtest.lyx ${f}
|
||||
RESULT_VARIABLE _err)
|
||||
string(COMPARE NOTEQUAL ${_err} 0 _erg)
|
||||
if(_erg)
|
||||
list(APPEND ERRORS "Exporting ${f} to ${format}")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
if(ERRORS)
|
||||
foreach(m ${ERRORS})
|
||||
message(STATUS ${m})
|
||||
endforeach()
|
||||
message(FATAL_ERROR "Export failed")
|
||||
endif()
|
66
development/autotests/single-test.cmake
Executable file
66
development/autotests/single-test.cmake
Executable file
@ -0,0 +1,66 @@
|
||||
# This script invokes the keytest.py script with the simple set-up needed
|
||||
# to re-run deterministic regression tests that one would like to have.
|
||||
#
|
||||
# AUTOTEST_ROOT = ${LYX_ROOT}/development/autotests
|
||||
# KEYTEST_INFILE = xxx-in.txt
|
||||
# KEYTEST_OUTFILE = xxx-out.txt
|
||||
# BINDIR = ${BUILD_DIR}/bin
|
||||
# WORKDIR = ${BUILD_DIR}/autotests/out-home
|
||||
#
|
||||
# Script should be called like:
|
||||
# cmake -DAUTOTEST_ROOT=xxxx \
|
||||
# -DKEYTEST_INFILE=xxxx \
|
||||
# -DKEYTEST_OUTFILE=xxx \
|
||||
# -DBINDIR=xxx \
|
||||
# -WWORKDIR=xxx \
|
||||
# -P ${AUTOTEST_ROOT}/single-test.cmake
|
||||
|
||||
set(KEYTEST "${AUTOTEST_ROOT}/keytest.py")
|
||||
|
||||
set(MAX_DROP 0)
|
||||
execute_process(COMMAND pidof lyx OUTPUT_VARIABLE LYX_PID RESULT_VARIABLE pidstat OUTPUT_VARIABLE pidres)
|
||||
message(STATUS "pidres = ${pidres}")
|
||||
if (NOT pidstat)
|
||||
# lyx already running, remove trailing '\n' from pid
|
||||
string(REGEX REPLACE "\n" "" pidres ${pidres})
|
||||
execute_process(COMMAND wmctrl -l -p OUTPUT_VARIABLE _wmco)
|
||||
string(REGEX REPLACE "[\n]+" ";" _wmc ${_wmco})
|
||||
foreach(_w ${_wmc})
|
||||
string(REGEX MATCH "${pidres}" _wr ${_w})
|
||||
if (${_wr} MATCHES ${pidres})
|
||||
# this entry contains the pid, go search for X11-window-id
|
||||
string(REGEX REPLACE " .*" "" _wr ${_w})
|
||||
set(LYX_WINDOW_NAME ${_wr})
|
||||
message(STATUS "Set LYX_WINDOW_NAME to ${_wr}")
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
set(pidres "")
|
||||
set(LYX_WINDOW_NAME "")
|
||||
endif()
|
||||
|
||||
set(LYX_EXE "${BINDIR}/lyx")
|
||||
set(XVKBD_EXE "${BINDIR}/xvkbd")
|
||||
|
||||
# Environments needed by keytest.py
|
||||
set(ENV{LYX_USERDIR} ${LYX_USERDIR})
|
||||
set(ENV{LYX_PID} ${pidres})
|
||||
set(ENV{LYX_WINDOW_NAME} ${LYX_WINDOW_NAME})
|
||||
set(ENV{LYX_EXE} ${LYX_EXE})
|
||||
set(ENV{XVKBD_EXE} ${XVKBD_EXE})
|
||||
set(ENV{KEYTEST_INFILE} "${AUTOTEST_ROOT}/${KEYTEST_INFILE}")
|
||||
set(ENV{KEYTEST_OUTFILE} "${WORKDIR}/${KEYTEST_OUTFILE}")
|
||||
set(ENV{MAX_DROP} 1)
|
||||
file(GLOB _testfiles RELATIVE "${WORKDIR}" "test.*")
|
||||
if(_testfiles)
|
||||
# remove some leftover files from previous test
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E remove -f ${_testfiles} )
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND python ${KEYTEST}
|
||||
RESULT_VARIABLE KEYTEST_RES)
|
||||
if(KEYTEST_RES)
|
||||
message(FATAL_ERROR "KEYTEST failed: KEYTEST_RES=${KEYTEST_RES}")
|
||||
endif()
|
||||
|
33
development/autotests/xvkbd/CMakeLists.txt
Normal file
33
development/autotests/xvkbd/CMakeLists.txt
Normal file
@ -0,0 +1,33 @@
|
||||
# This file is part of LyX, the document processor.
|
||||
# Licence details can be found in the file COPYING.
|
||||
#
|
||||
# Copyright (c) 2012 Kornel Benko kornel@lyx.org
|
||||
#
|
||||
project(xvkbd)
|
||||
|
||||
find_package(X11 REQUIRED)
|
||||
find_package(PkgConfig)
|
||||
|
||||
add_definitions(-DUSE_XTEST -DUSE_I18N)
|
||||
|
||||
add_executable(xvkbd xvkbd.c findwidget.c)
|
||||
|
||||
set(XVFBDLIBS)
|
||||
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(XAWLIB REQUIRED xaw7)
|
||||
list(APPEND XVFBDLIBS ${XAWLIB_LIBRARIES})
|
||||
pkg_check_modules(XTEST REQUIRED xtst)
|
||||
list(APPEND XVFBDLIBS ${XTEST_LIBRARIES})
|
||||
else()
|
||||
list(APPEND XVFBDLIBS -lXaw7)
|
||||
foreach(_lb Xt XTest X11)
|
||||
if(X11_${_lb}_LIB)
|
||||
list(APPEND XVFBDLIBS ${X11_${_lb}_LIB})
|
||||
else()
|
||||
message(FATAL_ERROR "Library for ${_lb} not found")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
target_link_libraries(xvkbd ${XVFBDLIBS})
|
Loading…
Reference in New Issue
Block a user