ENH: Increase test + coverage

This commit is contained in:
Sebastien Barre 2002-01-18 20:32:06 -05:00
parent 2b5bb96e23
commit c26008ccf3
12 changed files with 255 additions and 33 deletions

View File

@ -12,7 +12,9 @@ ENDIF (CMAKE_ANSI_CXXFLAGS)
ADD_DEFINITIONS(-DCMAKE_IS_FUN)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
LOAD_CACHE(${Complex_SOURCE_DIR})
@ -53,13 +55,18 @@ SUBDIRS(Library Executable)
SUBDIR_DEPENDS(Executable Library)
#
# Exec program
# Exec program (TODO: test a result)
# Increase coverage.
#
OPTION(EXEC_PROGRAM "Test EXEC_PROGRAM" ON)
IF (EXEC_PROGRAM)
EXEC_PROGRAM("echo EXEC_PROGRAM")
ENDIF (EXEC_PROGRAM)
OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
IF (NOT NO_EXEC_PROGRAM)
EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}")
ELSE (NOT NO_EXEC_PROGRAM)
MESSAGE("Set this option ON")
ENDIF (NOT NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM)
#
# More coverage
@ -77,6 +84,11 @@ INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
#
MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
#
# Testing
#
ENABLE_TESTING()
#
# Test Cable
#

View File

@ -14,7 +14,13 @@ FIND_LIBRARY(CMAKE_LIB
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
LINK_LIBRARIES(${CMAKE_LIB})
# More coverage
#
# Testing
#
ADD_TEST(complex ${Complex_BINARY_DIR}/bin/complex)
#
# More coverage
#
INSTALL_TARGETS(/tmp complex)
INSTALL_PROGRAMS(/tmp complex)

View File

@ -106,6 +106,42 @@ int main()
Passed("SHOULD_BE_DEFINED is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_AND
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
#else
Passed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_AND
Failed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
#else
Passed("SHOULD_BE_DEFINED_AND is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_OR
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
#else
Passed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_OR
Failed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
#else
Passed("SHOULD_BE_DEFINED_OR is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_MATCHES
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
#else
Passed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_MATCHES
Failed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
#else
Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
#endif
#ifndef ONE_VAR
Failed("cmakedefine is broken, ONE_VAR is not defined.");
#else
@ -188,7 +224,7 @@ int main()
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_NAME is not defined.");
#else
if(strcmp(FILENAME_VAR_NAME, "VarTests.txt") != 0)
if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
{
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
@ -203,7 +239,7 @@ int main()
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_EXT is not defined.");
#else
if(strcmp(FILENAME_VAR_EXT, ".txt") != 0)
if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
{
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);

View File

@ -11,13 +11,33 @@ SET(ONE_VAR 1)
VARIABLE_REQUIRES(ONE_VAR
ONE_VAR_IS_DEFINED ONE_VAR)
SET (ONE_VAR2 1)
IF(ONE_VAR AND ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND)
ELSE(ONE_VAR AND ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_AND)
ENDIF(ONE_VAR AND ONE_VAR2)
IF(ZERO_VAR OR ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_OR)
ELSE(ZERO_VAR OR ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR)
ENDIF(ZERO_VAR OR ONE_VAR2)
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
IF(STRING_VAR MATCHES "^CMake")
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES)
ELSE(STRING_VAR MATCHES "^CMake")
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
ENDIF(STRING_VAR MATCHES "^CMake")
FOREACH (INDEX 1 2)
SET(FOREACH_VAR${INDEX} "VALUE${INDEX}")
ENDFOREACH(INDEX)
FIND_FILE(FILENAME_VAR "VarTests.txt" ${Complex_SOURCE_DIR})
FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH)
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME)
@ -25,7 +45,7 @@ GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME)
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE)
FIND_PATH(PATH_VAR "VarTests.txt" ${Complex_SOURCE_DIR})
FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
# Coverage only

View File

@ -12,7 +12,9 @@ ENDIF (CMAKE_ANSI_CXXFLAGS)
ADD_DEFINITIONS(-DCMAKE_IS_FUN)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
LOAD_CACHE(${Complex_SOURCE_DIR})
@ -53,13 +55,18 @@ SUBDIRS(Library Executable)
SUBDIR_DEPENDS(Executable Library)
#
# Exec program
# Exec program (TODO: test a result)
# Increase coverage.
#
OPTION(EXEC_PROGRAM "Test EXEC_PROGRAM" ON)
IF (EXEC_PROGRAM)
EXEC_PROGRAM("echo EXEC_PROGRAM")
ENDIF (EXEC_PROGRAM)
OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
IF (NOT NO_EXEC_PROGRAM)
EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}")
ELSE (NOT NO_EXEC_PROGRAM)
MESSAGE("Set this option ON")
ENDIF (NOT NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM)
#
# More coverage
@ -77,6 +84,11 @@ INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
#
MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
#
# Testing
#
ENABLE_TESTING()
#
# Test Cable
#

View File

@ -14,7 +14,13 @@ FIND_LIBRARY(CMAKE_LIB
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
LINK_LIBRARIES(${CMAKE_LIB})
# More coverage
#
# Testing
#
ADD_TEST(complex ${Complex_BINARY_DIR}/bin/complex)
#
# More coverage
#
INSTALL_TARGETS(/tmp complex)
INSTALL_PROGRAMS(/tmp complex)

View File

@ -106,6 +106,42 @@ int main()
Passed("SHOULD_BE_DEFINED is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_AND
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
#else
Passed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_AND
Failed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
#else
Passed("SHOULD_BE_DEFINED_AND is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_OR
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
#else
Passed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_OR
Failed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
#else
Passed("SHOULD_BE_DEFINED_OR is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_MATCHES
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
#else
Passed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_MATCHES
Failed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
#else
Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
#endif
#ifndef ONE_VAR
Failed("cmakedefine is broken, ONE_VAR is not defined.");
#else
@ -188,7 +224,7 @@ int main()
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_NAME is not defined.");
#else
if(strcmp(FILENAME_VAR_NAME, "VarTests.txt") != 0)
if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
{
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
@ -203,7 +239,7 @@ int main()
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_EXT is not defined.");
#else
if(strcmp(FILENAME_VAR_EXT, ".txt") != 0)
if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
{
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);

View File

@ -11,13 +11,33 @@ SET(ONE_VAR 1)
VARIABLE_REQUIRES(ONE_VAR
ONE_VAR_IS_DEFINED ONE_VAR)
SET (ONE_VAR2 1)
IF(ONE_VAR AND ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND)
ELSE(ONE_VAR AND ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_AND)
ENDIF(ONE_VAR AND ONE_VAR2)
IF(ZERO_VAR OR ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_OR)
ELSE(ZERO_VAR OR ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR)
ENDIF(ZERO_VAR OR ONE_VAR2)
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
IF(STRING_VAR MATCHES "^CMake")
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES)
ELSE(STRING_VAR MATCHES "^CMake")
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
ENDIF(STRING_VAR MATCHES "^CMake")
FOREACH (INDEX 1 2)
SET(FOREACH_VAR${INDEX} "VALUE${INDEX}")
ENDFOREACH(INDEX)
FIND_FILE(FILENAME_VAR "VarTests.txt" ${Complex_SOURCE_DIR})
FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH)
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME)
@ -25,7 +45,7 @@ GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME)
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE)
FIND_PATH(PATH_VAR "VarTests.txt" ${Complex_SOURCE_DIR})
FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
# Coverage only

View File

@ -12,7 +12,9 @@ ENDIF (CMAKE_ANSI_CXXFLAGS)
ADD_DEFINITIONS(-DCMAKE_IS_FUN)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
LOAD_CACHE(${Complex_SOURCE_DIR})
@ -53,13 +55,18 @@ SUBDIRS(Library Executable)
SUBDIR_DEPENDS(Executable Library)
#
# Exec program
# Exec program (TODO: test a result)
# Increase coverage.
#
OPTION(EXEC_PROGRAM "Test EXEC_PROGRAM" ON)
IF (EXEC_PROGRAM)
EXEC_PROGRAM("echo EXEC_PROGRAM")
ENDIF (EXEC_PROGRAM)
OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
IF (NOT NO_EXEC_PROGRAM)
EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}")
ELSE (NOT NO_EXEC_PROGRAM)
MESSAGE("Set this option ON")
ENDIF (NOT NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM)
#
# More coverage
@ -77,6 +84,11 @@ INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
#
MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
#
# Testing
#
ENABLE_TESTING()
#
# Test Cable
#

View File

@ -14,7 +14,13 @@ FIND_LIBRARY(CMAKE_LIB
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
LINK_LIBRARIES(${CMAKE_LIB})
# More coverage
#
# Testing
#
ADD_TEST(complex ${Complex_BINARY_DIR}/bin/complex)
#
# More coverage
#
INSTALL_TARGETS(/tmp complex)
INSTALL_PROGRAMS(/tmp complex)

View File

@ -106,6 +106,42 @@ int main()
Passed("SHOULD_BE_DEFINED is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_AND
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
#else
Passed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_AND
Failed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
#else
Passed("SHOULD_BE_DEFINED_AND is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_OR
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
#else
Passed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_OR
Failed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
#else
Passed("SHOULD_BE_DEFINED_OR is defined.");
#endif
#ifdef SHOULD_NOT_BE_DEFINED_MATCHES
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
#else
Passed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
#endif
#ifndef SHOULD_BE_DEFINED_MATCHES
Failed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
#else
Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
#endif
#ifndef ONE_VAR
Failed("cmakedefine is broken, ONE_VAR is not defined.");
#else
@ -188,7 +224,7 @@ int main()
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_NAME is not defined.");
#else
if(strcmp(FILENAME_VAR_NAME, "VarTests.txt") != 0)
if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
{
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
@ -203,7 +239,7 @@ int main()
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_EXT is not defined.");
#else
if(strcmp(FILENAME_VAR_EXT, ".txt") != 0)
if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
{
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);

View File

@ -11,13 +11,33 @@ SET(ONE_VAR 1)
VARIABLE_REQUIRES(ONE_VAR
ONE_VAR_IS_DEFINED ONE_VAR)
SET (ONE_VAR2 1)
IF(ONE_VAR AND ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND)
ELSE(ONE_VAR AND ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_AND)
ENDIF(ONE_VAR AND ONE_VAR2)
IF(ZERO_VAR OR ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_OR)
ELSE(ZERO_VAR OR ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR)
ENDIF(ZERO_VAR OR ONE_VAR2)
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
IF(STRING_VAR MATCHES "^CMake")
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES)
ELSE(STRING_VAR MATCHES "^CMake")
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
ENDIF(STRING_VAR MATCHES "^CMake")
FOREACH (INDEX 1 2)
SET(FOREACH_VAR${INDEX} "VALUE${INDEX}")
ENDFOREACH(INDEX)
FIND_FILE(FILENAME_VAR "VarTests.txt" ${Complex_SOURCE_DIR})
FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH)
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME)
@ -25,7 +45,7 @@ GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME)
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE)
FIND_PATH(PATH_VAR "VarTests.txt" ${Complex_SOURCE_DIR})
FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
# Coverage only