commit f2553ebf6cfdb79fd3a87f1f11722f87a9211a92
Author: Kornel Benko <[email protected]>
Date:   Sat Sep 7 08:58:21 2013 +0200

    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

diff --git a/development/autotests/CMakeLists.txt 
b/development/autotests/CMakeLists.txt
index 87dfeac..20f3503 100644
--- a/development/autotests/CMakeLists.txt
+++ b/development/autotests/CMakeLists.txt
@@ -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()
diff --git a/development/autotests/single-test.cmake 
b/development/autotests/single-test.cmake
index 0758e7f..e42c6e0 100755
--- a/development/autotests/single-test.cmake
+++ b/development/autotests/single-test.cmake
@@ -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})
diff --git a/development/checkurls/CMakeLists.txt 
b/development/checkurls/CMakeLists.txt
index 7d697a3..2f261b6 100644
--- a/development/checkurls/CMakeLists.txt
+++ b/development/checkurls/CMakeLists.txt
@@ -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")
diff --git a/development/cmake/modules/LyXMacros.cmake 
b/development/cmake/modules/LyXMacros.cmake
index e865b25..48e29d8 100644
--- a/development/cmake/modules/LyXMacros.cmake
+++ b/development/cmake/modules/LyXMacros.cmake
@@ -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()
+
diff --git a/src/tex2lyx/test/CMakeLists.txt b/src/tex2lyx/test/CMakeLists.txt
index c0ba51d..2b11152 100644
--- a/src/tex2lyx/test/CMakeLists.txt
+++ b/src/tex2lyx/test/CMakeLists.txt
@@ -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})

Reply via email to