]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Make the CTest integration simpler and a little more robust
authorTim Kientzle <kientzle@gmail.com>
Sat, 7 Nov 2009 23:35:18 +0000 (18:35 -0500)
committerTim Kientzle <kientzle@gmail.com>
Sat, 7 Nov 2009 23:35:18 +0000 (18:35 -0500)
by just reading list.h directly into cmake.  This only requires
a suitable "DEFINE_TEST" macro.

SVN-Revision: 1587

cpio/test/CMakeLists.txt
libarchive/test/CMakeLists.txt
tar/test/CMakeLists.txt

index 4a4fb90403a5512369a8df0ac4de1c7a573c8324..ddc69cce3fa72211f99aeabf5a5e60ac8eb3de88 100644 (file)
@@ -43,28 +43,31 @@ IF(ENABLE_CPIO AND ENABLE_TEST)
   ENDIF(WIN32 AND NOT CYGWIN)
 
   #
-  # Generate the list.h
+  # Register target
+  #
+  ADD_EXECUTABLE(bsdcpio_test ${bsdcpio_test_SOURCES})
+  SET_PROPERTY(TARGET bsdcpio_test PROPERTY COMPILE_DEFINITIONS LIST_H)
+
+  #
+  # Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
   #
   GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
     ${CMAKE_CURRENT_LIST_FILE} ${bsdcpio_test_SOURCES})
   SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
     ${CMAKE_CURRENT_BINARY_DIR})
-  #
-  # Register target
-  #
-  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$")
-      STRING(REGEX REPLACE "^(test_[^/]+)[.]c$" "\\1" testname ${test})
-      ADD_TEST("bsdcpio_${testname}" bsdcpio_test
-        -v -p ${BSDCPIO} -r ${CMAKE_CURRENT_SOURCE_DIR} ${num})
-      MATH(EXPR num "${num} + 1")
-    ENDIF(test MATCHES "^test_[^/]+[.]c$")
-  ENDFOREACH(test)
+  # list.h has a line DEFINE_TEST(testname) for every
+  # test.  We can use that to define the tests for cmake by
+  # defining a DEFINE_TEST macro and reading list.h in.
+  MACRO (DEFINE_TEST _testname)
+    ADD_TEST("bsdcpio_${_testname}"
+                 bsdcpio_test -vv
+                              -p ${BSDCPIO}
+                              -r ${CMAKE_CURRENT_SOURCE_DIR}
+                              ${_testname})
+  ENDMACRO (DEFINE_TEST _testname)
+
+  INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
 
   # Experimental new test handling
   ADD_CUSTOM_TARGET(run_bsdcpio_test
index 91e24919065785173116cd01d7fe6ee067b712ac..682a58cc5793a6505212356aba2c9e2964b33259 100644 (file)
@@ -117,13 +117,6 @@ IF(ENABLE_TEST)
     test_write_open_memory.c
   )
 
-  #
-  # Generate the list.h
-  #
-  GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
-    ${CMAKE_CURRENT_LIST_FILE} ${libarchive_test_SOURCES})
-  SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
-    ${CMAKE_CURRENT_BINARY_DIR})
   #
   # Register target
   #
@@ -132,17 +125,25 @@ IF(ENABLE_TEST)
   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$")
-      STRING(REGEX REPLACE "^(test_[^/]+)[.]c$" "\\1" testname ${test})
-      ADD_TEST("libarchive_${testname}" libarchive_test
-        -q -r ${CMAKE_CURRENT_SOURCE_DIR} ${num})
-      MATH(EXPR num "${num} + 1")
-    ENDIF(test MATCHES "^test_[^/]+[.]c$")
-  ENDFOREACH(test)
+  #
+  # Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
+  #
+  GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
+    ${CMAKE_CURRENT_LIST_FILE} ${libarchive_test_SOURCES})
+  SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
+    ${CMAKE_CURRENT_BINARY_DIR})
+
+  # list.h has a line DEFINE_TEST(testname) for every
+  # test.  We can use that to define the tests for cmake by
+  # defining a DEFINE_TEST macro and reading list.h in.
+  MACRO (DEFINE_TEST _testname)
+  ADD_TEST("libarchive_${_testname}"
+                 libarchive_test -vv
+                              -r ${CMAKE_CURRENT_SOURCE_DIR}
+                              ${_testname})
+  ENDMACRO (DEFINE_TEST _testname)
 
+  INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
 
   # Experimental new test handling
   ADD_CUSTOM_TARGET(run_libarchive_test
index 35a6de7b922b1fcb6393f727b9e49170d97414b6..fe5f0ba6ea99c12be19a899174e77d5436cb708f 100644 (file)
@@ -30,28 +30,31 @@ IF(ENABLE_TAR AND ENABLE_TEST)
   ENDIF(WIN32 AND NOT CYGWIN)
 
   #
-  # Generate the list.h
+  # Register target
+  #
+  ADD_EXECUTABLE(bsdtar_test ${bsdtar_test_SOURCES})
+  SET_PROPERTY(TARGET bsdtar_test PROPERTY COMPILE_DEFINITIONS LIST_H)
+
+  #
+  # Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
   #
   GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
     ${CMAKE_CURRENT_LIST_FILE} ${bsdtar_test_SOURCES})
   SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
     ${CMAKE_CURRENT_BINARY_DIR})
-  #
-  # Register target
-  #
-  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$")
-      STRING(REGEX REPLACE "^(test_[^/]+)[.]c$" "\\1" testname ${test})
-      ADD_TEST("bsdtar_${testname}" bsdtar_test
-        -q -v -p ${BSDTAR} -r ${CMAKE_CURRENT_SOURCE_DIR} ${num})
-      MATH(EXPR num "${num} + 1")
-    ENDIF(test MATCHES "^test_[^/]+[.]c$")
-  ENDFOREACH(test)
+  # list.h has a line DEFINE_TEST(testname) for every
+  # test.  We can use that to define the tests for cmake by
+  # defining a DEFINE_TEST macro and reading list.h in.
+  MACRO (DEFINE_TEST _testname)
+    ADD_TEST("bsdtar_${_testname}"
+                 bsdtar_test -vv
+                              -p ${BSDTAR}
+                              -r ${CMAKE_CURRENT_SOURCE_DIR}
+                              ${_testname})
+  ENDMACRO (DEFINE_TEST _testname)
+
+  INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
 
   # Experimental new test handling
   ADD_CUSTOM_TARGET(run_bsdtar_test