[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/utils/krecipes
From:       Martin Engelmann <murphi.oss () googlemail ! com>
Date:       2010-06-12 6:17:50
Message-ID: 20100612061750.24F56AC8D5 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1137251 by mengelmann:

Execute tests via CTest. Run them with "make test"

Also the infrastructure to execute unit tests is setup.

 M  +1 -0      ChangeLog  
 M  +33 -24    src/CMakeLists.txt  


--- trunk/extragear/utils/krecipes/ChangeLog #1137250:1137251
@@ -7,6 +7,7 @@
     for writing it.
   * Porting of datablock classes to Qt4
   * Renamed internal library libkrecipescommon to avoid double lib in filename
+  * Execute tests via CTest. To run them use "make test"
   * Fixes for bugs:
     + Right pane header, diet helper title and list titles follow theme colour
       settings rather than set absolute colours. Thanks to Mike Ferguson for the
--- trunk/extragear/utils/krecipes/src/CMakeLists.txt #1137250:1137251
@@ -210,41 +210,50 @@
 
 ############### tests ################
 
+
+set(IMPORT_EXPORT_TESTS
+    kretest mmftest mx2test mxptest nyctest recipemltest rezkonvtest
+    )
+
+set(UNIT_TESTS
+    )
+
+macro(add_import_export_test _TEST)
 if(KDE4_BUILD_TESTS)
+        kde4_add_executable(krecipes-${_TEST} tests/${_TEST}.cpp)
+        target_link_libraries(krecipes-${_TEST} ${UNIT_TEST_LIBRARIES})
 
-set(TESTS kretest mmftest mx2test mxptest nyctest recipemltest rezkonvtest)
+        set(_TEST_DATA
+            ${CMAKE_CURRENT_SOURCE_DIR}/tests/${_TEST}.txt
+            ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_photo.jpg)
 
-foreach(TEST ${TESTS})
+        add_test(NAME krecipes-${_TEST} COMMAND $<TARGET_FILE:krecipes-${_TEST}> ${_TEST_DATA})
+    endif(KDE4_BUILD_TESTS)
+endmacro(add_import_export_test)
 
-set(TEST_SRCS tests/${TEST}.cpp)
+macro(add_unit_test _TEST)
+    kde4_add_unit_test(krecipes-${_TEST} tests/${_TEST}.cpp)
+    target_link_libraries(krecipes-${_TEST} ${UNIT_TEST_LIBRARIES})
+endmacro(add_unit_test)
 
-kde4_add_executable(${TEST} ${TEST_SRCS})
-
-target_link_libraries(${TEST} krecipescommon
+set(UNIT_TEST_LIBRARIES krecipescommon
    ${KDE4_KDECORE_LIBS} ${KDE4_KDE3SUPPORT_LIBS}
-   ${QT_QTSQL_LIBRARY} ${NEPOMUK_LIBRARIES} 
-   ${LIBXSLT_LIBRARIES} ${LIBXML2_LIBRARIES}) 
-
+    ${QT_QTSQL_LIBRARY}  ${QT_QTTEST_LIBRARY} ${NEPOMUK_LIBRARIES}
+    ${LIBXSLT_LIBRARIES} ${LIBXML2_LIBRARIES}
+    )
 if ( SQLITE_FOUND )
-   target_link_libraries(${TEST} ${SQLITE_LIBRARIES})
+   list(APPEND UNIT_TEST_LIBRARIES ${SQLITE_LIBRARIES})
 elseif ( SQLITE2_FOUND )
-   target_link_libraries(${TEST} ${SQLITE2_LIBRARIES})
+   list(APPEND UNIT_TEST_LIBRARIES ${SQLITE2_LIBRARIES})
 endif ( SQLITE_FOUND )
 
-install(TARGETS ${TEST}
-   DESTINATION ${DATA_INSTALL_DIR}/krecipes/tests)
+foreach(_TEST ${IMPORT_EXPORT_TESTS})
+    add_import_export_test(${_TEST})
+endforeach(_TEST)
+foreach(_TEST ${UNIT_TESTS})
+    add_unit_test(${_TEST})
+endforeach(_TEST)
 
-install(FILES
-   tests/${TEST}.txt
-   DESTINATION ${DATA_INSTALL_DIR}/krecipes/tests)
-
-endforeach(TEST)
-
-install(FILES tests/test_photo.jpg
-   DESTINATION ${DATA_INSTALL_DIR}/krecipes/tests)
-
-endif(KDE4_BUILD_TESTS)
-
 ############# Main  #################
 
 set(krecipes_SRCS 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic