Fix CMake-based testing
This commit is contained in:
1 parent
6f40ee4f1d
commit
f833d13e6d
6 files changed
+38
-70
No files matched your search
@@ -374,6 +374,38 @@ MACRO (GENERATE_LIST_H _listfile _cmlist _target __list_sources)
|
||||
# Attaching list.h to the target tells CMake to build it before compiling.
|
||||
TARGET_SOURCES(${_target} PRIVATE "${_listfile}")
|
||||
ENDMACRO (GENERATE_LIST_H)
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
MACRO(DISCOVER_TESTS _component __list_sources)
|
||||
IF(ENABLE_TEST)
|
||||
SET(_sources ${ARGV})
|
||||
LIST(REMOVE_AT _sources 0)
|
||||
FOREACH(_src ${_sources})
|
||||
IF(_src MATCHES "test_[^/]+\\.c$")
|
||||
FILE(STRINGS "${_src}" _lines REGEX "^DEFINE_TEST\(.*\)")
|
||||
FOREACH(_line ${_lines})
|
||||
STRING(REGEX MATCH "DEFINE_TEST\((.*)\)" _full_match ${_line})
|
||||
# CMake REGEX seems to handle ( and \( rather inconsistently...
|
||||
# So we go through an extra dance to definitively strip the parens
|
||||
STRING(REPLACE "(" "" _test_name_with_paren "${CMAKE_MATCH_1}")
|
||||
STRING(REPLACE ")" "" _test_name "${_test_name_with_paren}")
|
||||
SET(_full_test_name "${_component}_${_test_name}")
|
||||
MESSAGE("Found test ${_full_test_name} command ${_component}_test")
|
||||
ADD_TEST(NAME ${_full_test_name}
|
||||
COMMAND ${_component}_test -vv
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-s
|
||||
${_test_name})
|
||||
SET_TESTS_PROPERTIES(${_full_test_name} PROPERTIES SKIP_RETURN_CODE 2)
|
||||
|
||||
ENDFOREACH()
|
||||
ENDIF()
|
||||
endforeach()
|
||||
ENDIF(ENABLE_TEST)
|
||||
ENDMACRO(DISCOVER_TESTS __sources)
|
||||
|
||||
#
|
||||
# Generate installation rules for man pages.
|
||||
#
|
||||
|
||||
+2
-15
@@ -3,7 +3,7 @@
|
||||
#
|
||||
############################################
|
||||
#
|
||||
# How to build bsdtar_test
|
||||
# How to build bsdcat_test
|
||||
#
|
||||
############################################
|
||||
IF(ENABLE_CAT AND ENABLE_TEST)
|
||||
@@ -55,21 +55,8 @@ IF(ENABLE_CAT AND ENABLE_TEST)
|
||||
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(
|
||||
NAME bsdcat_${_testname}
|
||||
COMMAND bsdcat_test -vv
|
||||
-p $<TARGET_FILE:bsdcat>
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-s
|
||||
${_testname})
|
||||
SET_TESTS_PROPERTIES(bsdcat_${_testname} PROPERTIES SKIP_RETURN_CODE 2)
|
||||
ENDMACRO (DEFINE_TEST _testname)
|
||||
DISCOVER_TESTS(bsdcat ${bsdcat_test_SOURCES})
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h OPTIONAL)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/cat/test)
|
||||
|
||||
@@ -88,21 +88,8 @@ IF(ENABLE_CPIO AND ENABLE_TEST)
|
||||
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(
|
||||
NAME bsdcpio_${_testname}
|
||||
COMMAND bsdcpio_test -vv
|
||||
-p $<TARGET_FILE:bsdcpio>
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-s
|
||||
${_testname})
|
||||
SET_TESTS_PROPERTIES(bsdcpio_${_testname} PROPERTIES SKIP_RETURN_CODE 2)
|
||||
ENDMACRO (DEFINE_TEST _testname)
|
||||
DISCOVER_TESTS(bsdcpio ${bsdcpio_test_SOURCES})
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h OPTIONAL)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/cpio/test)
|
||||
|
||||
@@ -353,20 +353,8 @@ IF(ENABLE_TEST)
|
||||
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(
|
||||
NAME libarchive_${_testname}
|
||||
COMMAND libarchive_test -vv
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-s
|
||||
${_testname})
|
||||
SET_TESTS_PROPERTIES(libarchive_${_testname} PROPERTIES SKIP_RETURN_CODE 2)
|
||||
ENDMACRO (DEFINE_TEST _testname)
|
||||
DISCOVER_TESTS(libarchive ${libarchive_test_SOURCES})
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h OPTIONAL)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/libarchive/test)
|
||||
|
||||
+1
-14
@@ -109,21 +109,8 @@ IF(ENABLE_TAR AND ENABLE_TEST)
|
||||
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(
|
||||
NAME bsdtar_${_testname}
|
||||
COMMAND bsdtar_test -vv
|
||||
-p $<TARGET_FILE:bsdtar>
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-s
|
||||
${_testname})
|
||||
SET_TESTS_PROPERTIES(bsdtar_${_testname} PROPERTIES SKIP_RETURN_CODE 2)
|
||||
ENDMACRO (DEFINE_TEST _testname)
|
||||
DISCOVER_TESTS(bsdtar ${bsdtar_test_SOURCES})
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h OPTIONAL)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/tar/test)
|
||||
|
||||
@@ -56,21 +56,8 @@ IF(ENABLE_UNZIP AND ENABLE_TEST)
|
||||
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(
|
||||
NAME bsdunzip_${_testname}
|
||||
COMMAND bsdunzip_test -vv
|
||||
-p $<TARGET_FILE:bsdunzip>
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-s
|
||||
${_testname})
|
||||
SET_TESTS_PROPERTIES(bsdunzip_${_testname} PROPERTIES SKIP_RETURN_CODE 2)
|
||||
ENDMACRO (DEFINE_TEST _testname)
|
||||
DISCOVER_TESTS(bsdunzip ${bsdunzip_test_SOURCES})
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h OPTIONAL)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/unzip/test)
|
||||
|
||||
Reference in new issue
Block a user