Cmake build tests: Threadsafety and test-labeling

The tests are now more robust if ctest uses '-j' (number of threads) parameter.
a.) keytests are running in sequence and in one thread only, no other thread running
b.) tex2lyx tests are locking in respect to each other
c.) Test gets one or more labels, so that we can select
        ctest -L url
  to run tests labeled url
d.) New macro settestlabel() to add labels to a test
This commit is contained in:
Kornel Benko 2013-09-07 08:58:21 +02:00
parent 1a96a9cf72
commit f2553ebf6c
5 changed files with 33 additions and 1 deletions

View File

@ -95,6 +95,8 @@ if(Q_WS_X11)
-DPACKAGE=${PACKAGE}
-DLOCALE_DIR=${LOCALE_DIR}
-P ${TOP_SRC_DIR}/development/autotests/single-test.cmake)
settestlabel(keytest/${_t} "key")
set_tests_properties(keytest/${_t} PROPERTIES RUN_SERIAL ON)
endforeach()
endif()
endif()
@ -181,6 +183,7 @@ foreach(libsubfolder doc examples templates)
-Dfile=${f}
-Dreverted=${reverted}
-P "${TOP_SRC_DIR}/development/autotests/export.cmake")
setmarkedtestlabel(${TestName} ${reverted} "export")
endif()
set(TestName "lyx2lyx/${libsubfolder}/${f}")
maketestname(TestName reverted revertedTests ignoredTests)
@ -191,6 +194,7 @@ foreach(libsubfolder doc examples templates)
-DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR}
-DLYXFILE=${LIBSUB_SRC_DIR}/${f}.lyx
-P "${TOP_SRC_DIR}/development/autotests/lyx2lyxtest.cmake")
setmarkedtestlabel(${TestName} ${reverted} "export")
endif()
set(TestName "check_load/${libsubfolder}/${f}")
maketestname(TestName reverted revertedTests ignoredTests)
@ -203,6 +207,7 @@ foreach(libsubfolder doc examples templates)
-DPARAMS_DIR=${TOP_SRC_DIR}/development/autotests
-DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
-P "${TOP_SRC_DIR}/development/autotests/check_load.cmake")
setmarkedtestlabel(${TestName} ${reverted} "load")
endif()
getoutputformats("${LIBSUB_SRC_DIR}/${f}.lyx" formatlist)
foreach(format ${formatlist})
@ -220,6 +225,7 @@ foreach(libsubfolder doc examples templates)
-Dfile=${f}
-Dreverted=${reverted}
-P "${TOP_SRC_DIR}/development/autotests/export.cmake")
setmarkedtestlabel(${TestName} ${reverted} "export")
endif()
endforeach()
endforeach()

View File

@ -75,7 +75,7 @@ endif()
# Environments needed by keytest.py
set(ENV{PACKAGE} ${PACKAGE})
set(ENV{LOCALE_DIR} ${LOCALE_DIR})
set(ENV{LYX_LOCALEDIR} "${WORKDIR}/../locale")
set(ENV{LYX_LOCALEDIR} "${LOCALE_DIR}")
set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}")
set(ENV{LYX_PID} ${pidres})
set(ENV{LYX_WINDOW_NAME} ${LYX_WINDOW_NAME})

View File

@ -48,4 +48,8 @@ add_test(NAME "check_invalid_urls"
"extraURLS=${CMAKE_CURRENT_SOURCE_DIR}/knownInvalidURLS"
"revertedURLS=${CMAKE_CURRENT_SOURCE_DIR}/knownInvalidURLS")
set_tests_properties("check_accessible_urls" "check_inaccessible_urls" "check_invalid_urls"
PROPERTIES RESOURCE_LOCK "url.lock" LABELS "url")
settestlabel("check_inaccessible_urls" "reverted")
settestlabel("check_invalid_urls" "reverted")

View File

@ -290,3 +290,23 @@ macro(lyx_find_info_files group files)
file(GLOB _filelist ${files})
lyx_add_info_files(${group} ${_filelist})
endmacro()
macro(settestlabel testname)
get_property(_lab_list TEST ${testname} PROPERTY LABELS)
if(_lab_list)
list(APPEND _lab_list "${ARGN}")
else()
set(_lab_list "${ARGN}")
endif()
list(REMOVE_DUPLICATES _lab_list)
set_tests_properties(${testname} PROPERTIES LABELS "${_lab_list}")
endmacro()
macro(setmarkedtestlabel testname reverted)
if(reverted)
settestlabel(${testname} "reverted" ${ARGN})
else()
settestlabel(${testname} ${ARGN})
endif()
endmacro()

View File

@ -35,6 +35,7 @@ foreach(_fl ${_tex_tests})
-DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}
-DTESTFILE=${fl}
-P ${TOP_SRC_DIR}/src/tex2lyx/test/runtests.cmake)
set_tests_properties(tex2lyx/roundtrip/${_fl} PROPERTIES RESOURCE_LOCK "runtests.lock" LABELS "roundtrip")
add_test(NAME tex2lyx/cmplyx/${_fl}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND ${CMAKE_COMMAND}
@ -48,6 +49,7 @@ foreach(_fl ${_tex_tests})
-DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}
-DTESTFILE=${fl}
-P ${TOP_SRC_DIR}/src/tex2lyx/test/runtests.cmake)
set_tests_properties(tex2lyx/cmplyx/${_fl} PROPERTIES RESOURCE_LOCK "runtests.lock" LABELS "cmplyx")
endforeach()
add_dependencies(lyx_run_tests ${_tex2lyx} ${_lyx})