From: Tim Kientzle Date: Sun, 16 Aug 2009 02:10:09 +0000 (-0400) Subject: Experimenting with a new way to run tests from cmake. X-Git-Tag: v2.8.0~421 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f7a479b5eca701567bf4fdcf1e53773100c602c;p=thirdparty%2Flibarchive.git Experimenting with a new way to run tests from cmake. SVN-Revision: 1377 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c79dae1cc..f265f9b86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -699,7 +699,20 @@ IF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$") ADD_DEFINITIONS(-Wall -Werror) ENDIF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$") +DEFINE_PROPERTY(GLOBAL + PROPERTY ALL_TESTS + BRIEF_DOCS "Test targets to be run by run_all_tests" + FULL_DOCS "Test targets to be run by run_all_tests") + add_subdirectory(libarchive) add_subdirectory(tar) add_subdirectory(cpio) +# This doesn't quite work and I don't understand why: the dependent +# tests do get run, but the final invocation of run_all_tests chokes. +# (At least on FreeBSD; I'll have to test on VS and MinGW and see what +# happens there.) +IF(ENABLE_TEST) +GET_PROPERTY(TESTS GLOBAL PROPERTY ALL_TESTS) +ADD_CUSTOM_TARGET(run_all_tests DEPENDS ${TESTS}) +ENDIF(ENABLE_TEST) diff --git a/cpio/test/CMakeLists.txt b/cpio/test/CMakeLists.txt index 1c0efc722..4a0bb4b79 100644 --- a/cpio/test/CMakeLists.txt +++ b/cpio/test/CMakeLists.txt @@ -54,6 +54,8 @@ IF(ENABLE_CPIO AND ENABLE_TEST) # ADD_EXECUTABLE(bsdcpio_test ${bsdcpio_test_SOURCES}) SET_PROPERTY(TARGET bsdcpio_test PROPERTY COMPILE_DEFINITIONS LIST_H) + + # ADD_TEST() for each separate test SET(num 0) FOREACH(test ${bsdcpio_test_SOURCES}) IF(test MATCHES "^test_[^/]+[.]c$") @@ -63,5 +65,14 @@ IF(ENABLE_CPIO AND ENABLE_TEST) MATH(EXPR num "${num} + 1") ENDIF(test MATCHES "^test_[^/]+[.]c$") ENDFOREACH(test) + + # + # Experimental new test handling + # + ADD_CUSTOM_TARGET(run_bsdcpio_test + DEPENDS bsdcpio_test bsdcpio + COMMAND bsdcpio_test -v -p ${BSDCPIO} -r ${CMAKE_CURRENT_SOURCE_DIR}) + + SET_PROPERTY(GLOBAL APPEND PROPERTY ALL_TESTS run_bsdcpio_test) ENDIF(ENABLE_CPIO AND ENABLE_TEST) diff --git a/libarchive/test/CMakeLists.txt b/libarchive/test/CMakeLists.txt index d3a6ec397..320f3a90c 100644 --- a/libarchive/test/CMakeLists.txt +++ b/libarchive/test/CMakeLists.txt @@ -119,6 +119,8 @@ IF(ENABLE_TEST) TARGET_LINK_LIBRARIES(libarchive_test ${ADDITIONAL_LIBS}) SET_PROPERTY(TARGET libarchive_test PROPERTY COMPILE_DEFINITIONS LIBARCHIVE_STATIC LIST_H) + + # Register ADD_TEST() for each separate test SET(num 0) FOREACH(test ${libarchive_test_SOURCES}) IF(test MATCHES "^test_[^/]+[.]c$") @@ -128,5 +130,15 @@ IF(ENABLE_TEST) MATH(EXPR num "${num} + 1") ENDIF(test MATCHES "^test_[^/]+[.]c$") ENDFOREACH(test) + + + # + # Experimental new test handling + # + ADD_CUSTOM_TARGET(run_libarchive_test + DEPENDS libarchive_test + COMMAND libarchive_test -v -r ${CMAKE_CURRENT_SOURCE_DIR}) + + SET_PROPERTY(GLOBAL APPEND PROPERTY ALL_TESTS run_libarchive_test) ENDIF(ENABLE_TEST) diff --git a/tar/test/CMakeLists.txt b/tar/test/CMakeLists.txt index 4f4391bd9..24a835b33 100644 --- a/tar/test/CMakeLists.txt +++ b/tar/test/CMakeLists.txt @@ -41,6 +41,8 @@ IF(ENABLE_TAR AND ENABLE_TEST) # ADD_EXECUTABLE(bsdtar_test ${bsdtar_test_SOURCES}) SET_PROPERTY(TARGET bsdtar_test PROPERTY COMPILE_DEFINITIONS LIST_H) + + # ADD_TEST() for each separate test SET(num 0) FOREACH(test ${bsdtar_test_SOURCES}) IF(test MATCHES "^test_[^/]+[.]c$") @@ -50,4 +52,13 @@ IF(ENABLE_TAR AND ENABLE_TEST) MATH(EXPR num "${num} + 1") ENDIF(test MATCHES "^test_[^/]+[.]c$") ENDFOREACH(test) + + # + # Experimental new test handling + # + ADD_CUSTOM_TARGET(run_bsdtar_test + DEPENDS bsdtar_test bsdtar + COMMAND bsdtar_test -v -p ${BSDTAR} -r ${CMAKE_CURRENT_SOURCE_DIR}) + + SET_PROPERTY(GLOBAL APPEND PROPERTY ALL_TESTS run_bsdtar_test) ENDIF (ENABLE_TAR AND ENABLE_TEST)