More tests + coverage
This commit is contained in:
parent
df5131adc2
commit
049a4820a2
|
@ -21,3 +21,14 @@ CACHE_TEST_VAR2:FILEPATH=bar
|
|||
|
||||
//A var.
|
||||
CACHE_TEST_VAR3:BOOL=1
|
||||
|
||||
//A var.
|
||||
CACHE_TEST_VAR_EXCLUDED:BOOL=1
|
||||
|
||||
|
||||
########################
|
||||
# INTERNAL cache entries
|
||||
########################
|
||||
|
||||
//A var.
|
||||
CACHE_TEST_VAR_INTERNAL:INTERNAL=bar
|
||||
|
|
|
@ -19,7 +19,11 @@ 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})
|
||||
LOAD_CACHE(${Complex_SOURCE_DIR}
|
||||
EXCLUDE
|
||||
CACHE_TEST_VAR_EXCLUDED
|
||||
INCLUDE_INTERNALS
|
||||
CACHE_TEST_VAR_INTERNAL)
|
||||
|
||||
#
|
||||
# Configure file
|
||||
|
@ -31,13 +35,17 @@ CONFIGURE_FILE(
|
|||
|
||||
#
|
||||
# Specify include and lib dirs
|
||||
# (BEFORE is for coverage)
|
||||
#
|
||||
INCLUDE_DIRECTORIES(
|
||||
${Complex_BINARY_DIR}
|
||||
${Complex_SOURCE_DIR}/Library
|
||||
${Complex_SOURCE_DIR}/../../Source
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(BEFORE
|
||||
${Complex_BINARY_DIR}
|
||||
)
|
||||
|
||||
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
|
||||
|
||||
LINK_DIRECTORIES(
|
||||
|
@ -65,6 +73,7 @@ SUBDIR_DEPENDS(Executable Library)
|
|||
# Exec program (TODO: test a result)
|
||||
# Increase coverage.
|
||||
#
|
||||
MESSAGE("Trying to increase coverage...")
|
||||
OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
|
||||
IF (NOT NO_EXEC_PROGRAM)
|
||||
EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}")
|
||||
|
|
|
@ -19,6 +19,14 @@ FIND_LIBRARY(CMAKE_LIB
|
|||
|
||||
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
|
||||
|
||||
#
|
||||
# Output the files required by 'complex' to a file.
|
||||
# The 'complex' executable will then test if this file exists and remove it.
|
||||
# The contents of this file is not tested (absolute paths).
|
||||
#
|
||||
#OUTPUT_REQUIRED_FILES(${Complex_SOURCE_DIR}/Executable/complex.cxx
|
||||
# ${Complex_BINARY_DIR}/Executable/complex-required.txt)
|
||||
|
||||
#
|
||||
# Extra coverage.Not used.
|
||||
#
|
||||
|
@ -26,3 +34,4 @@ INSTALL_TARGETS(/tmp complex)
|
|||
INSTALL_PROGRAMS(/tmp complex)
|
||||
|
||||
SOURCE_GROUP(A_GROUP ".cxx")
|
||||
|
||||
|
|
|
@ -5,23 +5,23 @@
|
|||
#include "cmStandardIncludes.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
int passed = 0;
|
||||
int failed = 0;
|
||||
int cm_passed = 0;
|
||||
int cm_failed = 0;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void Failed(const char* Message, const char* m2= "")
|
||||
void cmFailed(const char* Message, const char* m2= "")
|
||||
{
|
||||
std::cerr << "Failed: " << Message << m2 << "\n";
|
||||
failed++;
|
||||
cm_failed++;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void Passed(const char* Message, const char* m2="")
|
||||
void cmPassed(const char* Message, const char* m2="")
|
||||
{
|
||||
std::cout << "Passed: " << Message << m2 << "\n";
|
||||
passed++;
|
||||
cm_passed++;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
@ -30,17 +30,17 @@ void TestAndRemoveFile(const char* filename)
|
|||
{
|
||||
if (!cmSystemTools::FileExists(filename))
|
||||
{
|
||||
Failed("Could not find file: ", filename);
|
||||
cmFailed("Could not find file: ", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!cmSystemTools::RemoveFile(filename))
|
||||
{
|
||||
Failed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename);
|
||||
cmFailed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Find and remove file: ", filename);
|
||||
cmPassed("Find and remove file: ", filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,17 +51,17 @@ void TestDir(const char* filename)
|
|||
{
|
||||
if (!cmSystemTools::FileExists(filename))
|
||||
{
|
||||
Failed("Could not find dir: ", filename);
|
||||
cmFailed("Could not find dir: ", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!cmSystemTools::FileIsDirectory(filename))
|
||||
{
|
||||
Failed("Unable to check if file is a directory: ", filename);
|
||||
cmFailed("Unable to check if file is a directory: ", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Find dir: ", filename);
|
||||
cmPassed("Find dir: ", filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,85 +72,85 @@ int main()
|
|||
{
|
||||
if(sharedFunction() != 1)
|
||||
{
|
||||
Failed("Call to sharedFunction from shared library failed.");
|
||||
cmFailed("Call to sharedFunction from shared library failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Call to sharedFunction from shared library worked.");
|
||||
cmPassed("Call to sharedFunction from shared library worked.");
|
||||
}
|
||||
|
||||
if(file1() != 1)
|
||||
{
|
||||
Failed("Call to file1 function from library failed.");
|
||||
cmFailed("Call to file1 function from library failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Call to file1 function returned 1.");
|
||||
cmPassed("Call to file1 function returned 1.");
|
||||
}
|
||||
|
||||
if(file2() != 1)
|
||||
{
|
||||
Failed("Call to file2 function from library failed.");
|
||||
cmFailed("Call to file2 function from library failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Call to file2 function returned 1.");
|
||||
cmPassed("Call to file2 function returned 1.");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test ADD_DEFINITIONS
|
||||
|
||||
#ifndef CMAKE_IS_FUN
|
||||
Failed("CMake is not fun, so it is broken and should be fixed.");
|
||||
cmFailed("CMake is not fun, so it is broken and should be fixed.");
|
||||
#else
|
||||
Passed("CMAKE_IS_FUN is defined.");
|
||||
cmPassed("CMAKE_IS_FUN is defined.");
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test SET, VARIABLE_REQUIRES
|
||||
|
||||
#ifdef SHOULD_NOT_BE_DEFINED
|
||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
|
||||
#else
|
||||
Passed("SHOULD_NOT_BE_DEFINED is not defined.");
|
||||
cmPassed("SHOULD_NOT_BE_DEFINED is not defined.");
|
||||
#endif
|
||||
|
||||
#ifndef SHOULD_BE_DEFINED
|
||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
|
||||
#else
|
||||
Passed("SHOULD_BE_DEFINED is defined.");
|
||||
cmPassed("SHOULD_BE_DEFINED is defined.");
|
||||
#endif
|
||||
|
||||
#ifndef ONE_VAR
|
||||
Failed("cmakedefine is broken, ONE_VAR is not defined.");
|
||||
cmFailed("cmakedefine is broken, ONE_VAR is not defined.");
|
||||
#else
|
||||
Passed("ONE_VAR is defined.");
|
||||
cmPassed("ONE_VAR is defined.");
|
||||
#endif
|
||||
|
||||
#ifndef ONE_VAR_IS_DEFINED
|
||||
Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
|
||||
cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
|
||||
"ONE_VAR_IS_DEFINED is not defined.");
|
||||
#else
|
||||
Passed("ONE_VAR_IS_DEFINED is defined.");
|
||||
cmPassed("ONE_VAR_IS_DEFINED is defined.");
|
||||
#endif
|
||||
|
||||
#ifdef ZERO_VAR
|
||||
Failed("cmakedefine is broken, ZERO_VAR is defined.");
|
||||
cmFailed("cmakedefine is broken, ZERO_VAR is defined.");
|
||||
#else
|
||||
Passed("ZERO_VAR is not defined.");
|
||||
cmPassed("ZERO_VAR is not defined.");
|
||||
#endif
|
||||
|
||||
#ifndef STRING_VAR
|
||||
Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
|
||||
cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
|
||||
#else
|
||||
if(strcmp(STRING_VAR, "CMake is great") != 0)
|
||||
{
|
||||
Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
|
||||
cmFailed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
|
||||
STRING_VAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("STRING_VAR == ", STRING_VAR);
|
||||
cmPassed("STRING_VAR == ", STRING_VAR);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -158,71 +158,83 @@ int main()
|
|||
// Test various IF/ELSE combinations
|
||||
|
||||
#ifdef SHOULD_NOT_BE_DEFINED_AND
|
||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
|
||||
#else
|
||||
Passed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
|
||||
cmPassed("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");
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
|
||||
#else
|
||||
Passed("SHOULD_BE_DEFINED_AND is defined.");
|
||||
cmPassed("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.");
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
|
||||
#else
|
||||
Passed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
|
||||
cmPassed("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");
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
|
||||
#else
|
||||
Passed("SHOULD_BE_DEFINED_OR is defined.");
|
||||
cmPassed("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.");
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
|
||||
#else
|
||||
Passed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
|
||||
cmPassed("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");
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
|
||||
#else
|
||||
Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
|
||||
cmPassed("SHOULD_BE_DEFINED_MATCHES is defined.");
|
||||
#endif
|
||||
|
||||
#ifdef SHOULD_NOT_BE_DEFINED_COMMAND
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND is defined.");
|
||||
#else
|
||||
cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND is not defined.");
|
||||
#endif
|
||||
|
||||
#ifndef SHOULD_BE_DEFINED_COMMAND
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND is not defined.\n");
|
||||
#else
|
||||
cmPassed("SHOULD_BE_DEFINED_COMMAND is defined.");
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test FOREACH
|
||||
|
||||
#ifndef FOREACH_VAR1
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
"FOREACH_VAR1 is not defined.");
|
||||
#else
|
||||
if(strcmp(FOREACH_VAR1, "VALUE1") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
"FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||
cmPassed("FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FOREACH_VAR2
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
"FOREACH_VAR2 is not defined.");
|
||||
#else
|
||||
if(strcmp(FOREACH_VAR2, "VALUE2") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
"FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||
cmPassed("FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -230,77 +242,77 @@ int main()
|
|||
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
|
||||
|
||||
#ifndef FILENAME_VAR_PATH_NAME
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_PATH_NAME is not defined.");
|
||||
#else
|
||||
if(strcmp(FILENAME_VAR_PATH_NAME, "Complex") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||
cmPassed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FILENAME_VAR_NAME
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_NAME is not defined.");
|
||||
#else
|
||||
if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||
cmPassed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FILENAME_VAR_EXT
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_EXT is not defined.");
|
||||
#else
|
||||
if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||
cmPassed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FILENAME_VAR_NAME_WE
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_NAME_WE is not defined.");
|
||||
#else
|
||||
if(strcmp(FILENAME_VAR_NAME_WE, "VarTests") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||
cmPassed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef PATH_VAR_NAME
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"PATH_VAR_NAME is not defined.");
|
||||
#else
|
||||
if(strcmp(PATH_VAR_NAME, "Complex") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||
cmPassed("PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -308,47 +320,69 @@ int main()
|
|||
// Test LOAD_CACHE
|
||||
|
||||
#ifndef CACHE_TEST_VAR1
|
||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR1 is not defined.");
|
||||
#else
|
||||
if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||
cmPassed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef CACHE_TEST_VAR2
|
||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR2 is not defined.");
|
||||
#else
|
||||
if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||
cmPassed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef CACHE_TEST_VAR3
|
||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR3 is not defined.");
|
||||
#else
|
||||
if(strcmp(CACHE_TEST_VAR3, "1") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||
cmPassed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CACHE_TEST_VAR_EXCLUDED
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, "
|
||||
"CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded).");
|
||||
#else
|
||||
cmPassed("CACHE_TEST_VAR_EXCLUDED is not defined.");
|
||||
#endif
|
||||
|
||||
#ifndef CACHE_TEST_VAR_INTERNAL
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR_INTERNAL is not defined.");
|
||||
#else
|
||||
if(strcmp(CACHE_TEST_VAR_INTERNAL, "bar") != 0)
|
||||
{
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmPassed("CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -369,14 +403,21 @@ int main()
|
|||
|
||||
TestDir(BINARY_DIR "/make_dir");
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test OUTPUT_REQUIRED_FILES
|
||||
// The files required by 'complex' have been output to a file.
|
||||
// The contents of this file is not tested (absolute paths).
|
||||
|
||||
TestAndRemoveFile(BINARY_DIR "/Executable/complex-required.txt");
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Summary
|
||||
|
||||
std::cout << "Passed: " << passed << "\n";
|
||||
if(failed)
|
||||
std::cout << "Passed: " << cm_passed << "\n";
|
||||
if(cm_failed)
|
||||
{
|
||||
std::cout << "Failed: " << failed << "\n";
|
||||
return failed;
|
||||
std::cout << "Failed: " << cm_failed << "\n";
|
||||
return cm_failed;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -54,4 +54,5 @@ ABSTRACT_FILES(
|
|||
)
|
||||
|
||||
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
||||
INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
||||
|
||||
|
|
|
@ -40,6 +40,12 @@ ELSE(STRING_VAR MATCHES "^CMake")
|
|||
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
|
||||
ENDIF(STRING_VAR MATCHES "^CMake")
|
||||
|
||||
IF(COMMAND "IF")
|
||||
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND)
|
||||
ELSE(COMMAND "IF")
|
||||
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND)
|
||||
ENDIF(COMMAND "IF")
|
||||
|
||||
#
|
||||
# Test FOREACH
|
||||
#
|
||||
|
@ -58,5 +64,5 @@ 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 CACHE)
|
||||
|
||||
FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
|
||||
FIND_PATH(PATH_VAR "cmTestConfigure.h.in" ${Complex_SOURCE_DIR})
|
||||
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
|
||||
#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
|
||||
#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
|
||||
#cmakedefine CACHE_TEST_VAR_EXCLUDED
|
||||
#define CACHE_TEST_VAR_INTERNAL "${CACHE_TEST_VAR_INTERNAL}"
|
||||
|
||||
// Test internal CMake vars from C++ flags
|
||||
|
||||
|
|
|
@ -21,3 +21,14 @@ CACHE_TEST_VAR2:FILEPATH=bar
|
|||
|
||||
//A var.
|
||||
CACHE_TEST_VAR3:BOOL=1
|
||||
|
||||
//A var.
|
||||
CACHE_TEST_VAR_EXCLUDED:BOOL=1
|
||||
|
||||
|
||||
########################
|
||||
# INTERNAL cache entries
|
||||
########################
|
||||
|
||||
//A var.
|
||||
CACHE_TEST_VAR_INTERNAL:INTERNAL=bar
|
||||
|
|
|
@ -19,7 +19,11 @@ 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})
|
||||
LOAD_CACHE(${Complex_SOURCE_DIR}
|
||||
EXCLUDE
|
||||
CACHE_TEST_VAR_EXCLUDED
|
||||
INCLUDE_INTERNALS
|
||||
CACHE_TEST_VAR_INTERNAL)
|
||||
|
||||
#
|
||||
# Configure file
|
||||
|
@ -31,13 +35,17 @@ CONFIGURE_FILE(
|
|||
|
||||
#
|
||||
# Specify include and lib dirs
|
||||
# (BEFORE is for coverage)
|
||||
#
|
||||
INCLUDE_DIRECTORIES(
|
||||
${Complex_BINARY_DIR}
|
||||
${Complex_SOURCE_DIR}/Library
|
||||
${Complex_SOURCE_DIR}/../../Source
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(BEFORE
|
||||
${Complex_BINARY_DIR}
|
||||
)
|
||||
|
||||
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
|
||||
|
||||
LINK_DIRECTORIES(
|
||||
|
@ -65,6 +73,7 @@ SUBDIR_DEPENDS(Executable Library)
|
|||
# Exec program (TODO: test a result)
|
||||
# Increase coverage.
|
||||
#
|
||||
MESSAGE("Trying to increase coverage...")
|
||||
OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
|
||||
IF (NOT NO_EXEC_PROGRAM)
|
||||
EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}")
|
||||
|
|
|
@ -19,6 +19,14 @@ FIND_LIBRARY(CMAKE_LIB
|
|||
|
||||
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
|
||||
|
||||
#
|
||||
# Output the files required by 'complex' to a file.
|
||||
# The 'complex' executable will then test if this file exists and remove it.
|
||||
# The contents of this file is not tested (absolute paths).
|
||||
#
|
||||
#OUTPUT_REQUIRED_FILES(${Complex_SOURCE_DIR}/Executable/complex.cxx
|
||||
# ${Complex_BINARY_DIR}/Executable/complex-required.txt)
|
||||
|
||||
#
|
||||
# Extra coverage.Not used.
|
||||
#
|
||||
|
@ -26,3 +34,4 @@ INSTALL_TARGETS(/tmp complex)
|
|||
INSTALL_PROGRAMS(/tmp complex)
|
||||
|
||||
SOURCE_GROUP(A_GROUP ".cxx")
|
||||
|
||||
|
|
|
@ -5,23 +5,23 @@
|
|||
#include "cmStandardIncludes.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
int passed = 0;
|
||||
int failed = 0;
|
||||
int cm_passed = 0;
|
||||
int cm_failed = 0;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void Failed(const char* Message, const char* m2= "")
|
||||
void cmFailed(const char* Message, const char* m2= "")
|
||||
{
|
||||
std::cerr << "Failed: " << Message << m2 << "\n";
|
||||
failed++;
|
||||
cm_failed++;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void Passed(const char* Message, const char* m2="")
|
||||
void cmPassed(const char* Message, const char* m2="")
|
||||
{
|
||||
std::cout << "Passed: " << Message << m2 << "\n";
|
||||
passed++;
|
||||
cm_passed++;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
@ -30,17 +30,17 @@ void TestAndRemoveFile(const char* filename)
|
|||
{
|
||||
if (!cmSystemTools::FileExists(filename))
|
||||
{
|
||||
Failed("Could not find file: ", filename);
|
||||
cmFailed("Could not find file: ", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!cmSystemTools::RemoveFile(filename))
|
||||
{
|
||||
Failed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename);
|
||||
cmFailed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Find and remove file: ", filename);
|
||||
cmPassed("Find and remove file: ", filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,17 +51,17 @@ void TestDir(const char* filename)
|
|||
{
|
||||
if (!cmSystemTools::FileExists(filename))
|
||||
{
|
||||
Failed("Could not find dir: ", filename);
|
||||
cmFailed("Could not find dir: ", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!cmSystemTools::FileIsDirectory(filename))
|
||||
{
|
||||
Failed("Unable to check if file is a directory: ", filename);
|
||||
cmFailed("Unable to check if file is a directory: ", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Find dir: ", filename);
|
||||
cmPassed("Find dir: ", filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,85 +72,85 @@ int main()
|
|||
{
|
||||
if(sharedFunction() != 1)
|
||||
{
|
||||
Failed("Call to sharedFunction from shared library failed.");
|
||||
cmFailed("Call to sharedFunction from shared library failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Call to sharedFunction from shared library worked.");
|
||||
cmPassed("Call to sharedFunction from shared library worked.");
|
||||
}
|
||||
|
||||
if(file1() != 1)
|
||||
{
|
||||
Failed("Call to file1 function from library failed.");
|
||||
cmFailed("Call to file1 function from library failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Call to file1 function returned 1.");
|
||||
cmPassed("Call to file1 function returned 1.");
|
||||
}
|
||||
|
||||
if(file2() != 1)
|
||||
{
|
||||
Failed("Call to file2 function from library failed.");
|
||||
cmFailed("Call to file2 function from library failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Call to file2 function returned 1.");
|
||||
cmPassed("Call to file2 function returned 1.");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test ADD_DEFINITIONS
|
||||
|
||||
#ifndef CMAKE_IS_FUN
|
||||
Failed("CMake is not fun, so it is broken and should be fixed.");
|
||||
cmFailed("CMake is not fun, so it is broken and should be fixed.");
|
||||
#else
|
||||
Passed("CMAKE_IS_FUN is defined.");
|
||||
cmPassed("CMAKE_IS_FUN is defined.");
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test SET, VARIABLE_REQUIRES
|
||||
|
||||
#ifdef SHOULD_NOT_BE_DEFINED
|
||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
|
||||
#else
|
||||
Passed("SHOULD_NOT_BE_DEFINED is not defined.");
|
||||
cmPassed("SHOULD_NOT_BE_DEFINED is not defined.");
|
||||
#endif
|
||||
|
||||
#ifndef SHOULD_BE_DEFINED
|
||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
|
||||
#else
|
||||
Passed("SHOULD_BE_DEFINED is defined.");
|
||||
cmPassed("SHOULD_BE_DEFINED is defined.");
|
||||
#endif
|
||||
|
||||
#ifndef ONE_VAR
|
||||
Failed("cmakedefine is broken, ONE_VAR is not defined.");
|
||||
cmFailed("cmakedefine is broken, ONE_VAR is not defined.");
|
||||
#else
|
||||
Passed("ONE_VAR is defined.");
|
||||
cmPassed("ONE_VAR is defined.");
|
||||
#endif
|
||||
|
||||
#ifndef ONE_VAR_IS_DEFINED
|
||||
Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
|
||||
cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
|
||||
"ONE_VAR_IS_DEFINED is not defined.");
|
||||
#else
|
||||
Passed("ONE_VAR_IS_DEFINED is defined.");
|
||||
cmPassed("ONE_VAR_IS_DEFINED is defined.");
|
||||
#endif
|
||||
|
||||
#ifdef ZERO_VAR
|
||||
Failed("cmakedefine is broken, ZERO_VAR is defined.");
|
||||
cmFailed("cmakedefine is broken, ZERO_VAR is defined.");
|
||||
#else
|
||||
Passed("ZERO_VAR is not defined.");
|
||||
cmPassed("ZERO_VAR is not defined.");
|
||||
#endif
|
||||
|
||||
#ifndef STRING_VAR
|
||||
Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
|
||||
cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
|
||||
#else
|
||||
if(strcmp(STRING_VAR, "CMake is great") != 0)
|
||||
{
|
||||
Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
|
||||
cmFailed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
|
||||
STRING_VAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("STRING_VAR == ", STRING_VAR);
|
||||
cmPassed("STRING_VAR == ", STRING_VAR);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -158,71 +158,83 @@ int main()
|
|||
// Test various IF/ELSE combinations
|
||||
|
||||
#ifdef SHOULD_NOT_BE_DEFINED_AND
|
||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
|
||||
#else
|
||||
Passed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
|
||||
cmPassed("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");
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
|
||||
#else
|
||||
Passed("SHOULD_BE_DEFINED_AND is defined.");
|
||||
cmPassed("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.");
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
|
||||
#else
|
||||
Passed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
|
||||
cmPassed("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");
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
|
||||
#else
|
||||
Passed("SHOULD_BE_DEFINED_OR is defined.");
|
||||
cmPassed("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.");
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
|
||||
#else
|
||||
Passed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
|
||||
cmPassed("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");
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
|
||||
#else
|
||||
Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
|
||||
cmPassed("SHOULD_BE_DEFINED_MATCHES is defined.");
|
||||
#endif
|
||||
|
||||
#ifdef SHOULD_NOT_BE_DEFINED_COMMAND
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND is defined.");
|
||||
#else
|
||||
cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND is not defined.");
|
||||
#endif
|
||||
|
||||
#ifndef SHOULD_BE_DEFINED_COMMAND
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND is not defined.\n");
|
||||
#else
|
||||
cmPassed("SHOULD_BE_DEFINED_COMMAND is defined.");
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test FOREACH
|
||||
|
||||
#ifndef FOREACH_VAR1
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
"FOREACH_VAR1 is not defined.");
|
||||
#else
|
||||
if(strcmp(FOREACH_VAR1, "VALUE1") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
"FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||
cmPassed("FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FOREACH_VAR2
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
"FOREACH_VAR2 is not defined.");
|
||||
#else
|
||||
if(strcmp(FOREACH_VAR2, "VALUE2") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
"FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||
cmPassed("FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -230,77 +242,77 @@ int main()
|
|||
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
|
||||
|
||||
#ifndef FILENAME_VAR_PATH_NAME
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_PATH_NAME is not defined.");
|
||||
#else
|
||||
if(strcmp(FILENAME_VAR_PATH_NAME, "Complex") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||
cmPassed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FILENAME_VAR_NAME
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_NAME is not defined.");
|
||||
#else
|
||||
if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||
cmPassed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FILENAME_VAR_EXT
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_EXT is not defined.");
|
||||
#else
|
||||
if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||
cmPassed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FILENAME_VAR_NAME_WE
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_NAME_WE is not defined.");
|
||||
#else
|
||||
if(strcmp(FILENAME_VAR_NAME_WE, "VarTests") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||
cmPassed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef PATH_VAR_NAME
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"PATH_VAR_NAME is not defined.");
|
||||
#else
|
||||
if(strcmp(PATH_VAR_NAME, "Complex") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||
cmPassed("PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -308,47 +320,69 @@ int main()
|
|||
// Test LOAD_CACHE
|
||||
|
||||
#ifndef CACHE_TEST_VAR1
|
||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR1 is not defined.");
|
||||
#else
|
||||
if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||
cmPassed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef CACHE_TEST_VAR2
|
||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR2 is not defined.");
|
||||
#else
|
||||
if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||
cmPassed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef CACHE_TEST_VAR3
|
||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR3 is not defined.");
|
||||
#else
|
||||
if(strcmp(CACHE_TEST_VAR3, "1") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||
cmPassed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CACHE_TEST_VAR_EXCLUDED
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, "
|
||||
"CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded).");
|
||||
#else
|
||||
cmPassed("CACHE_TEST_VAR_EXCLUDED is not defined.");
|
||||
#endif
|
||||
|
||||
#ifndef CACHE_TEST_VAR_INTERNAL
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR_INTERNAL is not defined.");
|
||||
#else
|
||||
if(strcmp(CACHE_TEST_VAR_INTERNAL, "bar") != 0)
|
||||
{
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmPassed("CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -369,14 +403,21 @@ int main()
|
|||
|
||||
TestDir(BINARY_DIR "/make_dir");
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test OUTPUT_REQUIRED_FILES
|
||||
// The files required by 'complex' have been output to a file.
|
||||
// The contents of this file is not tested (absolute paths).
|
||||
|
||||
TestAndRemoveFile(BINARY_DIR "/Executable/complex-required.txt");
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Summary
|
||||
|
||||
std::cout << "Passed: " << passed << "\n";
|
||||
if(failed)
|
||||
std::cout << "Passed: " << cm_passed << "\n";
|
||||
if(cm_failed)
|
||||
{
|
||||
std::cout << "Failed: " << failed << "\n";
|
||||
return failed;
|
||||
std::cout << "Failed: " << cm_failed << "\n";
|
||||
return cm_failed;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -54,4 +54,5 @@ ABSTRACT_FILES(
|
|||
)
|
||||
|
||||
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
||||
INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
||||
|
||||
|
|
|
@ -40,6 +40,12 @@ ELSE(STRING_VAR MATCHES "^CMake")
|
|||
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
|
||||
ENDIF(STRING_VAR MATCHES "^CMake")
|
||||
|
||||
IF(COMMAND "IF")
|
||||
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND)
|
||||
ELSE(COMMAND "IF")
|
||||
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND)
|
||||
ENDIF(COMMAND "IF")
|
||||
|
||||
#
|
||||
# Test FOREACH
|
||||
#
|
||||
|
@ -58,5 +64,5 @@ 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 CACHE)
|
||||
|
||||
FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
|
||||
FIND_PATH(PATH_VAR "cmTestConfigure.h.in" ${Complex_SOURCE_DIR})
|
||||
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
|
||||
#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
|
||||
#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
|
||||
#cmakedefine CACHE_TEST_VAR_EXCLUDED
|
||||
#define CACHE_TEST_VAR_INTERNAL "${CACHE_TEST_VAR_INTERNAL}"
|
||||
|
||||
// Test internal CMake vars from C++ flags
|
||||
|
||||
|
|
|
@ -21,3 +21,14 @@ CACHE_TEST_VAR2:FILEPATH=bar
|
|||
|
||||
//A var.
|
||||
CACHE_TEST_VAR3:BOOL=1
|
||||
|
||||
//A var.
|
||||
CACHE_TEST_VAR_EXCLUDED:BOOL=1
|
||||
|
||||
|
||||
########################
|
||||
# INTERNAL cache entries
|
||||
########################
|
||||
|
||||
//A var.
|
||||
CACHE_TEST_VAR_INTERNAL:INTERNAL=bar
|
||||
|
|
|
@ -19,7 +19,11 @@ 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})
|
||||
LOAD_CACHE(${Complex_SOURCE_DIR}
|
||||
EXCLUDE
|
||||
CACHE_TEST_VAR_EXCLUDED
|
||||
INCLUDE_INTERNALS
|
||||
CACHE_TEST_VAR_INTERNAL)
|
||||
|
||||
#
|
||||
# Configure file
|
||||
|
@ -31,13 +35,17 @@ CONFIGURE_FILE(
|
|||
|
||||
#
|
||||
# Specify include and lib dirs
|
||||
# (BEFORE is for coverage)
|
||||
#
|
||||
INCLUDE_DIRECTORIES(
|
||||
${Complex_BINARY_DIR}
|
||||
${Complex_SOURCE_DIR}/Library
|
||||
${Complex_SOURCE_DIR}/../../Source
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(BEFORE
|
||||
${Complex_BINARY_DIR}
|
||||
)
|
||||
|
||||
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
|
||||
|
||||
LINK_DIRECTORIES(
|
||||
|
@ -65,6 +73,7 @@ SUBDIR_DEPENDS(Executable Library)
|
|||
# Exec program (TODO: test a result)
|
||||
# Increase coverage.
|
||||
#
|
||||
MESSAGE("Trying to increase coverage...")
|
||||
OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
|
||||
IF (NOT NO_EXEC_PROGRAM)
|
||||
EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}")
|
||||
|
|
|
@ -19,6 +19,14 @@ FIND_LIBRARY(CMAKE_LIB
|
|||
|
||||
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
|
||||
|
||||
#
|
||||
# Output the files required by 'complex' to a file.
|
||||
# The 'complex' executable will then test if this file exists and remove it.
|
||||
# The contents of this file is not tested (absolute paths).
|
||||
#
|
||||
#OUTPUT_REQUIRED_FILES(${Complex_SOURCE_DIR}/Executable/complex.cxx
|
||||
# ${Complex_BINARY_DIR}/Executable/complex-required.txt)
|
||||
|
||||
#
|
||||
# Extra coverage.Not used.
|
||||
#
|
||||
|
@ -26,3 +34,4 @@ INSTALL_TARGETS(/tmp complex)
|
|||
INSTALL_PROGRAMS(/tmp complex)
|
||||
|
||||
SOURCE_GROUP(A_GROUP ".cxx")
|
||||
|
||||
|
|
|
@ -5,23 +5,23 @@
|
|||
#include "cmStandardIncludes.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
int passed = 0;
|
||||
int failed = 0;
|
||||
int cm_passed = 0;
|
||||
int cm_failed = 0;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void Failed(const char* Message, const char* m2= "")
|
||||
void cmFailed(const char* Message, const char* m2= "")
|
||||
{
|
||||
std::cerr << "Failed: " << Message << m2 << "\n";
|
||||
failed++;
|
||||
cm_failed++;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void Passed(const char* Message, const char* m2="")
|
||||
void cmPassed(const char* Message, const char* m2="")
|
||||
{
|
||||
std::cout << "Passed: " << Message << m2 << "\n";
|
||||
passed++;
|
||||
cm_passed++;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
@ -30,17 +30,17 @@ void TestAndRemoveFile(const char* filename)
|
|||
{
|
||||
if (!cmSystemTools::FileExists(filename))
|
||||
{
|
||||
Failed("Could not find file: ", filename);
|
||||
cmFailed("Could not find file: ", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!cmSystemTools::RemoveFile(filename))
|
||||
{
|
||||
Failed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename);
|
||||
cmFailed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Find and remove file: ", filename);
|
||||
cmPassed("Find and remove file: ", filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,17 +51,17 @@ void TestDir(const char* filename)
|
|||
{
|
||||
if (!cmSystemTools::FileExists(filename))
|
||||
{
|
||||
Failed("Could not find dir: ", filename);
|
||||
cmFailed("Could not find dir: ", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!cmSystemTools::FileIsDirectory(filename))
|
||||
{
|
||||
Failed("Unable to check if file is a directory: ", filename);
|
||||
cmFailed("Unable to check if file is a directory: ", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Find dir: ", filename);
|
||||
cmPassed("Find dir: ", filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,85 +72,85 @@ int main()
|
|||
{
|
||||
if(sharedFunction() != 1)
|
||||
{
|
||||
Failed("Call to sharedFunction from shared library failed.");
|
||||
cmFailed("Call to sharedFunction from shared library failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Call to sharedFunction from shared library worked.");
|
||||
cmPassed("Call to sharedFunction from shared library worked.");
|
||||
}
|
||||
|
||||
if(file1() != 1)
|
||||
{
|
||||
Failed("Call to file1 function from library failed.");
|
||||
cmFailed("Call to file1 function from library failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Call to file1 function returned 1.");
|
||||
cmPassed("Call to file1 function returned 1.");
|
||||
}
|
||||
|
||||
if(file2() != 1)
|
||||
{
|
||||
Failed("Call to file2 function from library failed.");
|
||||
cmFailed("Call to file2 function from library failed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("Call to file2 function returned 1.");
|
||||
cmPassed("Call to file2 function returned 1.");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test ADD_DEFINITIONS
|
||||
|
||||
#ifndef CMAKE_IS_FUN
|
||||
Failed("CMake is not fun, so it is broken and should be fixed.");
|
||||
cmFailed("CMake is not fun, so it is broken and should be fixed.");
|
||||
#else
|
||||
Passed("CMAKE_IS_FUN is defined.");
|
||||
cmPassed("CMAKE_IS_FUN is defined.");
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test SET, VARIABLE_REQUIRES
|
||||
|
||||
#ifdef SHOULD_NOT_BE_DEFINED
|
||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
|
||||
#else
|
||||
Passed("SHOULD_NOT_BE_DEFINED is not defined.");
|
||||
cmPassed("SHOULD_NOT_BE_DEFINED is not defined.");
|
||||
#endif
|
||||
|
||||
#ifndef SHOULD_BE_DEFINED
|
||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
|
||||
#else
|
||||
Passed("SHOULD_BE_DEFINED is defined.");
|
||||
cmPassed("SHOULD_BE_DEFINED is defined.");
|
||||
#endif
|
||||
|
||||
#ifndef ONE_VAR
|
||||
Failed("cmakedefine is broken, ONE_VAR is not defined.");
|
||||
cmFailed("cmakedefine is broken, ONE_VAR is not defined.");
|
||||
#else
|
||||
Passed("ONE_VAR is defined.");
|
||||
cmPassed("ONE_VAR is defined.");
|
||||
#endif
|
||||
|
||||
#ifndef ONE_VAR_IS_DEFINED
|
||||
Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
|
||||
cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
|
||||
"ONE_VAR_IS_DEFINED is not defined.");
|
||||
#else
|
||||
Passed("ONE_VAR_IS_DEFINED is defined.");
|
||||
cmPassed("ONE_VAR_IS_DEFINED is defined.");
|
||||
#endif
|
||||
|
||||
#ifdef ZERO_VAR
|
||||
Failed("cmakedefine is broken, ZERO_VAR is defined.");
|
||||
cmFailed("cmakedefine is broken, ZERO_VAR is defined.");
|
||||
#else
|
||||
Passed("ZERO_VAR is not defined.");
|
||||
cmPassed("ZERO_VAR is not defined.");
|
||||
#endif
|
||||
|
||||
#ifndef STRING_VAR
|
||||
Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
|
||||
cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
|
||||
#else
|
||||
if(strcmp(STRING_VAR, "CMake is great") != 0)
|
||||
{
|
||||
Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
|
||||
cmFailed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
|
||||
STRING_VAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("STRING_VAR == ", STRING_VAR);
|
||||
cmPassed("STRING_VAR == ", STRING_VAR);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -158,71 +158,83 @@ int main()
|
|||
// Test various IF/ELSE combinations
|
||||
|
||||
#ifdef SHOULD_NOT_BE_DEFINED_AND
|
||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
|
||||
#else
|
||||
Passed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
|
||||
cmPassed("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");
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
|
||||
#else
|
||||
Passed("SHOULD_BE_DEFINED_AND is defined.");
|
||||
cmPassed("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.");
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
|
||||
#else
|
||||
Passed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
|
||||
cmPassed("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");
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
|
||||
#else
|
||||
Passed("SHOULD_BE_DEFINED_OR is defined.");
|
||||
cmPassed("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.");
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
|
||||
#else
|
||||
Passed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
|
||||
cmPassed("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");
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
|
||||
#else
|
||||
Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
|
||||
cmPassed("SHOULD_BE_DEFINED_MATCHES is defined.");
|
||||
#endif
|
||||
|
||||
#ifdef SHOULD_NOT_BE_DEFINED_COMMAND
|
||||
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND is defined.");
|
||||
#else
|
||||
cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND is not defined.");
|
||||
#endif
|
||||
|
||||
#ifndef SHOULD_BE_DEFINED_COMMAND
|
||||
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND is not defined.\n");
|
||||
#else
|
||||
cmPassed("SHOULD_BE_DEFINED_COMMAND is defined.");
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test FOREACH
|
||||
|
||||
#ifndef FOREACH_VAR1
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
"FOREACH_VAR1 is not defined.");
|
||||
#else
|
||||
if(strcmp(FOREACH_VAR1, "VALUE1") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
"FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||
cmPassed("FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FOREACH_VAR2
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
"FOREACH_VAR2 is not defined.");
|
||||
#else
|
||||
if(strcmp(FOREACH_VAR2, "VALUE2") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
"FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||
cmPassed("FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -230,77 +242,77 @@ int main()
|
|||
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
|
||||
|
||||
#ifndef FILENAME_VAR_PATH_NAME
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_PATH_NAME is not defined.");
|
||||
#else
|
||||
if(strcmp(FILENAME_VAR_PATH_NAME, "Complex") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||
cmPassed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FILENAME_VAR_NAME
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_NAME is not defined.");
|
||||
#else
|
||||
if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||
cmPassed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FILENAME_VAR_EXT
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_EXT is not defined.");
|
||||
#else
|
||||
if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||
cmPassed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FILENAME_VAR_NAME_WE
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_NAME_WE is not defined.");
|
||||
#else
|
||||
if(strcmp(FILENAME_VAR_NAME_WE, "VarTests") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||
cmPassed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef PATH_VAR_NAME
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"PATH_VAR_NAME is not defined.");
|
||||
#else
|
||||
if(strcmp(PATH_VAR_NAME, "Complex") != 0)
|
||||
{
|
||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||
"PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||
cmPassed("PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -308,47 +320,69 @@ int main()
|
|||
// Test LOAD_CACHE
|
||||
|
||||
#ifndef CACHE_TEST_VAR1
|
||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR1 is not defined.");
|
||||
#else
|
||||
if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||
cmPassed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef CACHE_TEST_VAR2
|
||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR2 is not defined.");
|
||||
#else
|
||||
if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||
cmPassed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef CACHE_TEST_VAR3
|
||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR3 is not defined.");
|
||||
#else
|
||||
if(strcmp(CACHE_TEST_VAR3, "1") != 0)
|
||||
{
|
||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||
}
|
||||
else
|
||||
{
|
||||
Passed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||
cmPassed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CACHE_TEST_VAR_EXCLUDED
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, "
|
||||
"CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded).");
|
||||
#else
|
||||
cmPassed("CACHE_TEST_VAR_EXCLUDED is not defined.");
|
||||
#endif
|
||||
|
||||
#ifndef CACHE_TEST_VAR_INTERNAL
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR_INTERNAL is not defined.");
|
||||
#else
|
||||
if(strcmp(CACHE_TEST_VAR_INTERNAL, "bar") != 0)
|
||||
{
|
||||
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||
"CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmPassed("CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -369,14 +403,21 @@ int main()
|
|||
|
||||
TestDir(BINARY_DIR "/make_dir");
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test OUTPUT_REQUIRED_FILES
|
||||
// The files required by 'complex' have been output to a file.
|
||||
// The contents of this file is not tested (absolute paths).
|
||||
|
||||
TestAndRemoveFile(BINARY_DIR "/Executable/complex-required.txt");
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Summary
|
||||
|
||||
std::cout << "Passed: " << passed << "\n";
|
||||
if(failed)
|
||||
std::cout << "Passed: " << cm_passed << "\n";
|
||||
if(cm_failed)
|
||||
{
|
||||
std::cout << "Failed: " << failed << "\n";
|
||||
return failed;
|
||||
std::cout << "Failed: " << cm_failed << "\n";
|
||||
return cm_failed;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -54,4 +54,5 @@ ABSTRACT_FILES(
|
|||
)
|
||||
|
||||
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
||||
INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
||||
|
||||
|
|
|
@ -40,6 +40,12 @@ ELSE(STRING_VAR MATCHES "^CMake")
|
|||
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
|
||||
ENDIF(STRING_VAR MATCHES "^CMake")
|
||||
|
||||
IF(COMMAND "IF")
|
||||
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND)
|
||||
ELSE(COMMAND "IF")
|
||||
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND)
|
||||
ENDIF(COMMAND "IF")
|
||||
|
||||
#
|
||||
# Test FOREACH
|
||||
#
|
||||
|
@ -58,5 +64,5 @@ 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 CACHE)
|
||||
|
||||
FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
|
||||
FIND_PATH(PATH_VAR "cmTestConfigure.h.in" ${Complex_SOURCE_DIR})
|
||||
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
|
||||
#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
|
||||
#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
|
||||
#cmakedefine CACHE_TEST_VAR_EXCLUDED
|
||||
#define CACHE_TEST_VAR_INTERNAL "${CACHE_TEST_VAR_INTERNAL}"
|
||||
|
||||
// Test internal CMake vars from C++ flags
|
||||
|
||||
|
|
Loading…
Reference in New Issue