Browse Source

ENH: Increase test + coverage

Sebastien Barre 24 years ago
parent
commit
b6bdbc54fc

+ 25 - 1
Tests/Complex/CMakeLists.txt

@@ -1,5 +1,5 @@
 #
 #
-# A simple test case
+# A more complex test case
 #
 #
 PROJECT (Complex)
 PROJECT (Complex)
 
 
@@ -14,6 +14,8 @@ ADD_DEFINITIONS(-DCMAKE_IS_FUN)
 
 
 INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
 INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
 
 
+LOAD_CACHE(${Complex_SOURCE_DIR})
+
 CONFIGURE_FILE(
 CONFIGURE_FILE(
   ${Complex_SOURCE_DIR}/cmTestConfigure.h.in
   ${Complex_SOURCE_DIR}/cmTestConfigure.h.in
   ${Complex_BINARY_DIR}/cmTestConfigure.h)
   ${Complex_BINARY_DIR}/cmTestConfigure.h)
@@ -59,3 +61,25 @@ IF (EXEC_PROGRAM)
   EXEC_PROGRAM("echo EXEC_PROGRAM")
   EXEC_PROGRAM("echo EXEC_PROGRAM")
 ENDIF (EXEC_PROGRAM) 
 ENDIF (EXEC_PROGRAM) 
 
 
+#
+# More coverage
+#
+ABSTRACT_FILES(
+  ExtraSources/file1.cxx
+)
+
+INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
+
+#
+# Create directory.
+# The 'complex' executable will then test if this dir exists,
+# sadly it won't be able to remove it.
+#
+MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
+
+#
+# Test Cable
+#
+CABLE_CLASS_SET(Float float)
+CABLE_CLASS_SET(Mesh "itk::Mesh<$Float>")
+

+ 16 - 0
Tests/Complex/Executable/CMakeLists.txt

@@ -1,4 +1,20 @@
 ADD_EXECUTABLE(complex complex)
 ADD_EXECUTABLE(complex complex)
+
 TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
 TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
 TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
 TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
 
 
+FIND_LIBRARY(CMAKE_LIB
+             CMakeLib 
+             ${Complex_BINARY_DIR}/../../Source
+             ${Complex_BINARY_DIR}/../../Source/Debug
+             ${Complex_BINARY_DIR}/../../Source/Release
+             ${Complex_BINARY_DIR}/../../Source/MinSizeRel
+             ${Complex_BINARY_DIR}/../../Source/RelWithDebInfo)
+
+TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
+LINK_LIBRARIES(${CMAKE_LIB})
+
+# More coverage
+
+INSTALL_TARGETS(/tmp complex)
+INSTALL_PROGRAMS(/tmp complex)

+ 78 - 19
Tests/Complex/Executable/complex.cxx

@@ -3,16 +3,7 @@
 #include "file2.h"
 #include "file2.h"
 #include "sharedFile.h"
 #include "sharedFile.h"
 #include "cmStandardIncludes.h"
 #include "cmStandardIncludes.h"
-#include <sys/stat.h>
-#include <stdio.h>
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-#define _unlink unlink
-#else
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#endif
+#include "cmSystemTools.h"
 
 
 int passed = 0;
 int passed = 0;
 int failed = 0;
 int failed = 0;
@@ -31,14 +22,13 @@ void Passed(const char* Message, const char* m2="")
 
 
 void TestAndRemoveFile(const char* filename) 
 void TestAndRemoveFile(const char* filename) 
 {
 {
-  struct stat fs;
-  if (stat(filename, &fs) != 0)
+  if (!cmSystemTools::FileExists(filename))
     {
     {
     Failed("Could not find file: ", filename);
     Failed("Could not find file: ", filename);
     }
     }
   else
   else
     {
     {
-    if (unlink(filename) != 0)
+    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);
       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);
       }
       }
@@ -49,6 +39,26 @@ void TestAndRemoveFile(const char* filename)
     }
     }
 }
 }
 
 
+void TestDir(const char* filename) 
+{
+  if (!cmSystemTools::FileExists(filename))
+    {
+    Failed("Could not find dir: ", filename);
+    }
+  else
+    {
+    if (!cmSystemTools::FileIsDirectory(filename))
+      {
+      Failed("Unable to check if file is a directory: ", filename);
+      }
+    else
+      {
+      Passed("Find dir: ", filename);
+      }
+    }
+}
+
+
 int main()
 int main()
 {
 {
   if(sharedFunction() != 1)
   if(sharedFunction() != 1)
@@ -234,17 +244,66 @@ int main()
     }
     }
 #endif
 #endif
 
 
-  // A post-build custom-command has been attached to the lib.
+#ifndef CACHE_TEST_VAR1
+  Failed("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, "
+           "CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
+    }
+  else
+    {
+    Passed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
+    }
+#endif
+
+#ifndef CACHE_TEST_VAR2
+  Failed("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, "
+           "CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
+    }
+  else
+    {
+    Passed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
+    }
+#endif
+
+#ifndef CACHE_TEST_VAR3
+  Failed("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, "
+           "CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
+    }
+  else
+    {
+    Passed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
+    }
+#endif
+
+  // A post-build custom-command has been attached to the lib (see Library/).
   // It run ${CREATE_FILE_EXE} which will create the file
   // It run ${CREATE_FILE_EXE} which will create the file
-  // ${Complex_BINARY_DIR}/postbuild.txt.
+  // ${Complex_BINARY_DIR}/Library/postbuild.txt.
 
 
-  TestAndRemoveFile(BINARY_DIR "/postbuild.txt");
+  TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt");
 
 
-  // A custom target has been created.
+  // A custom target has been created (see Library/).
   // It run ${CREATE_FILE_EXE} which will create the file
   // It run ${CREATE_FILE_EXE} which will create the file
-  // ${Complex_BINARY_DIR}/custom_target1.txt.
+  // ${Complex_BINARY_DIR}/Library/custom_target1.txt.
+
+  TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt");
+
+  // A directory has been created.
 
 
-  TestAndRemoveFile(BINARY_DIR "/custom_target1.txt");
+  TestDir(BINARY_DIR "/make_dir");
 
 
   std::cout << "Passed: " << passed << "\n";
   std::cout << "Passed: " << passed << "\n";
   if(failed)
   if(failed)

+ 7 - 4
Tests/Complex/Library/CMakeLists.txt

@@ -17,7 +17,7 @@ ADD_EXECUTABLE(create_file create_file.cxx)
 #
 #
 # Attach a post-build custom-command to the lib.
 # Attach a post-build custom-command to the lib.
 # It run ${CREATE_FILE_EXE} which will create the file
 # It run ${CREATE_FILE_EXE} which will create the file
-# ${Complex_BINARY_DIR}/postbuild.txt.
+# ${Complex_BINARY_DIR}/Library/postbuild.txt.
 # The 'complex' executable will then test if this file exists,
 # The 'complex' executable will then test if this file exists,
 # and remove it.
 # and remove it.
 #
 #
@@ -25,20 +25,23 @@ ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
 
 
 ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
 ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
                    COMMAND ${CREATE_FILE_EXE}
                    COMMAND ${CREATE_FILE_EXE}
-                   ARGS "${Complex_BINARY_DIR}/postbuild.txt"
+                   ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt"
                    TARGET CMakeTestLibraryShared)
                    TARGET CMakeTestLibraryShared)
 
 
 #
 #
 # Add custom target
 # Add custom target
 # It run ${CREATE_FILE_EXE} which will create the file
 # It run ${CREATE_FILE_EXE} which will create the file
-# ${Complex_BINARY_DIR}/custom_target1.txt.
+# ${Complex_BINARY_DIR}/Library/custom_target1.txt.
 # The 'complex' executable will then test if this file exists,
 # The 'complex' executable will then test if this file exists,
 # and remove it.
 # and remove it.
 #
 #
 ADD_CUSTOM_TARGET(custom_target1
 ADD_CUSTOM_TARGET(custom_target1
                   ALL
                   ALL
                   ${CREATE_FILE_EXE} 
                   ${CREATE_FILE_EXE} 
-                  "${Complex_BINARY_DIR}/custom_target1.txt")
+                  "${Complex_BINARY_DIR}/Library/custom_target1.txt")
 
 
 ADD_DEPENDENCIES(custom_target1 create_file)
 ADD_DEPENDENCIES(custom_target1 create_file)
 
 
+# More coverage
+
+SOURCE_GROUP(A_GROUP ".cxx")

+ 4 - 1
Tests/Complex/cmTestConfigure.h.in

@@ -18,6 +18,10 @@
 #cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
 #cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
 #cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
 #cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
 
 
+#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
+#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
+#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
+
 // Needed to check for files
 // Needed to check for files
 
 
 #define BINARY_DIR "${Complex_BINARY_DIR}"
 #define BINARY_DIR "${Complex_BINARY_DIR}"
@@ -27,4 +31,3 @@
 #define BUILD_COMMAND_VAR "${BUILD_COMMAND_VAR}"
 #define BUILD_COMMAND_VAR "${BUILD_COMMAND_VAR}"
 #define BUILD_NAME_VAR "${BUILD_NAME_VAR}"
 #define BUILD_NAME_VAR "${BUILD_NAME_VAR}"
 #define SITE_NAME_VAR "${SITE_NAME_VAR}"
 #define SITE_NAME_VAR "${SITE_NAME_VAR}"
-

+ 25 - 1
Tests/ComplexOneConfig/CMakeLists.txt

@@ -1,5 +1,5 @@
 #
 #
-# A simple test case
+# A more complex test case
 #
 #
 PROJECT (Complex)
 PROJECT (Complex)
 
 
@@ -14,6 +14,8 @@ ADD_DEFINITIONS(-DCMAKE_IS_FUN)
 
 
 INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
 INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
 
 
+LOAD_CACHE(${Complex_SOURCE_DIR})
+
 CONFIGURE_FILE(
 CONFIGURE_FILE(
   ${Complex_SOURCE_DIR}/cmTestConfigure.h.in
   ${Complex_SOURCE_DIR}/cmTestConfigure.h.in
   ${Complex_BINARY_DIR}/cmTestConfigure.h)
   ${Complex_BINARY_DIR}/cmTestConfigure.h)
@@ -59,3 +61,25 @@ IF (EXEC_PROGRAM)
   EXEC_PROGRAM("echo EXEC_PROGRAM")
   EXEC_PROGRAM("echo EXEC_PROGRAM")
 ENDIF (EXEC_PROGRAM) 
 ENDIF (EXEC_PROGRAM) 
 
 
+#
+# More coverage
+#
+ABSTRACT_FILES(
+  ExtraSources/file1.cxx
+)
+
+INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
+
+#
+# Create directory.
+# The 'complex' executable will then test if this dir exists,
+# sadly it won't be able to remove it.
+#
+MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
+
+#
+# Test Cable
+#
+CABLE_CLASS_SET(Float float)
+CABLE_CLASS_SET(Mesh "itk::Mesh<$Float>")
+

+ 16 - 0
Tests/ComplexOneConfig/Executable/CMakeLists.txt

@@ -1,4 +1,20 @@
 ADD_EXECUTABLE(complex complex)
 ADD_EXECUTABLE(complex complex)
+
 TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
 TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
 TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
 TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
 
 
+FIND_LIBRARY(CMAKE_LIB
+             CMakeLib 
+             ${Complex_BINARY_DIR}/../../Source
+             ${Complex_BINARY_DIR}/../../Source/Debug
+             ${Complex_BINARY_DIR}/../../Source/Release
+             ${Complex_BINARY_DIR}/../../Source/MinSizeRel
+             ${Complex_BINARY_DIR}/../../Source/RelWithDebInfo)
+
+TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
+LINK_LIBRARIES(${CMAKE_LIB})
+
+# More coverage
+
+INSTALL_TARGETS(/tmp complex)
+INSTALL_PROGRAMS(/tmp complex)

+ 78 - 19
Tests/ComplexOneConfig/Executable/complex.cxx

@@ -3,16 +3,7 @@
 #include "file2.h"
 #include "file2.h"
 #include "sharedFile.h"
 #include "sharedFile.h"
 #include "cmStandardIncludes.h"
 #include "cmStandardIncludes.h"
-#include <sys/stat.h>
-#include <stdio.h>
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-#define _unlink unlink
-#else
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#endif
+#include "cmSystemTools.h"
 
 
 int passed = 0;
 int passed = 0;
 int failed = 0;
 int failed = 0;
@@ -31,14 +22,13 @@ void Passed(const char* Message, const char* m2="")
 
 
 void TestAndRemoveFile(const char* filename) 
 void TestAndRemoveFile(const char* filename) 
 {
 {
-  struct stat fs;
-  if (stat(filename, &fs) != 0)
+  if (!cmSystemTools::FileExists(filename))
     {
     {
     Failed("Could not find file: ", filename);
     Failed("Could not find file: ", filename);
     }
     }
   else
   else
     {
     {
-    if (unlink(filename) != 0)
+    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);
       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);
       }
       }
@@ -49,6 +39,26 @@ void TestAndRemoveFile(const char* filename)
     }
     }
 }
 }
 
 
+void TestDir(const char* filename) 
+{
+  if (!cmSystemTools::FileExists(filename))
+    {
+    Failed("Could not find dir: ", filename);
+    }
+  else
+    {
+    if (!cmSystemTools::FileIsDirectory(filename))
+      {
+      Failed("Unable to check if file is a directory: ", filename);
+      }
+    else
+      {
+      Passed("Find dir: ", filename);
+      }
+    }
+}
+
+
 int main()
 int main()
 {
 {
   if(sharedFunction() != 1)
   if(sharedFunction() != 1)
@@ -234,17 +244,66 @@ int main()
     }
     }
 #endif
 #endif
 
 
-  // A post-build custom-command has been attached to the lib.
+#ifndef CACHE_TEST_VAR1
+  Failed("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, "
+           "CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
+    }
+  else
+    {
+    Passed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
+    }
+#endif
+
+#ifndef CACHE_TEST_VAR2
+  Failed("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, "
+           "CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
+    }
+  else
+    {
+    Passed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
+    }
+#endif
+
+#ifndef CACHE_TEST_VAR3
+  Failed("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, "
+           "CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
+    }
+  else
+    {
+    Passed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
+    }
+#endif
+
+  // A post-build custom-command has been attached to the lib (see Library/).
   // It run ${CREATE_FILE_EXE} which will create the file
   // It run ${CREATE_FILE_EXE} which will create the file
-  // ${Complex_BINARY_DIR}/postbuild.txt.
+  // ${Complex_BINARY_DIR}/Library/postbuild.txt.
 
 
-  TestAndRemoveFile(BINARY_DIR "/postbuild.txt");
+  TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt");
 
 
-  // A custom target has been created.
+  // A custom target has been created (see Library/).
   // It run ${CREATE_FILE_EXE} which will create the file
   // It run ${CREATE_FILE_EXE} which will create the file
-  // ${Complex_BINARY_DIR}/custom_target1.txt.
+  // ${Complex_BINARY_DIR}/Library/custom_target1.txt.
+
+  TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt");
+
+  // A directory has been created.
 
 
-  TestAndRemoveFile(BINARY_DIR "/custom_target1.txt");
+  TestDir(BINARY_DIR "/make_dir");
 
 
   std::cout << "Passed: " << passed << "\n";
   std::cout << "Passed: " << passed << "\n";
   if(failed)
   if(failed)

+ 7 - 4
Tests/ComplexOneConfig/Library/CMakeLists.txt

@@ -17,7 +17,7 @@ ADD_EXECUTABLE(create_file create_file.cxx)
 #
 #
 # Attach a post-build custom-command to the lib.
 # Attach a post-build custom-command to the lib.
 # It run ${CREATE_FILE_EXE} which will create the file
 # It run ${CREATE_FILE_EXE} which will create the file
-# ${Complex_BINARY_DIR}/postbuild.txt.
+# ${Complex_BINARY_DIR}/Library/postbuild.txt.
 # The 'complex' executable will then test if this file exists,
 # The 'complex' executable will then test if this file exists,
 # and remove it.
 # and remove it.
 #
 #
@@ -25,20 +25,23 @@ ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
 
 
 ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
 ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
                    COMMAND ${CREATE_FILE_EXE}
                    COMMAND ${CREATE_FILE_EXE}
-                   ARGS "${Complex_BINARY_DIR}/postbuild.txt"
+                   ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt"
                    TARGET CMakeTestLibraryShared)
                    TARGET CMakeTestLibraryShared)
 
 
 #
 #
 # Add custom target
 # Add custom target
 # It run ${CREATE_FILE_EXE} which will create the file
 # It run ${CREATE_FILE_EXE} which will create the file
-# ${Complex_BINARY_DIR}/custom_target1.txt.
+# ${Complex_BINARY_DIR}/Library/custom_target1.txt.
 # The 'complex' executable will then test if this file exists,
 # The 'complex' executable will then test if this file exists,
 # and remove it.
 # and remove it.
 #
 #
 ADD_CUSTOM_TARGET(custom_target1
 ADD_CUSTOM_TARGET(custom_target1
                   ALL
                   ALL
                   ${CREATE_FILE_EXE} 
                   ${CREATE_FILE_EXE} 
-                  "${Complex_BINARY_DIR}/custom_target1.txt")
+                  "${Complex_BINARY_DIR}/Library/custom_target1.txt")
 
 
 ADD_DEPENDENCIES(custom_target1 create_file)
 ADD_DEPENDENCIES(custom_target1 create_file)
 
 
+# More coverage
+
+SOURCE_GROUP(A_GROUP ".cxx")

+ 4 - 1
Tests/ComplexOneConfig/cmTestConfigure.h.in

@@ -18,6 +18,10 @@
 #cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
 #cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
 #cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
 #cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
 
 
+#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
+#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
+#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
+
 // Needed to check for files
 // Needed to check for files
 
 
 #define BINARY_DIR "${Complex_BINARY_DIR}"
 #define BINARY_DIR "${Complex_BINARY_DIR}"
@@ -27,4 +31,3 @@
 #define BUILD_COMMAND_VAR "${BUILD_COMMAND_VAR}"
 #define BUILD_COMMAND_VAR "${BUILD_COMMAND_VAR}"
 #define BUILD_NAME_VAR "${BUILD_NAME_VAR}"
 #define BUILD_NAME_VAR "${BUILD_NAME_VAR}"
 #define SITE_NAME_VAR "${SITE_NAME_VAR}"
 #define SITE_NAME_VAR "${SITE_NAME_VAR}"
-

+ 25 - 1
Tests/ComplexRelativePaths/CMakeLists.txt

@@ -1,5 +1,5 @@
 #
 #
-# A simple test case
+# A more complex test case
 #
 #
 PROJECT (Complex)
 PROJECT (Complex)
 
 
@@ -14,6 +14,8 @@ ADD_DEFINITIONS(-DCMAKE_IS_FUN)
 
 
 INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
 INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
 
 
+LOAD_CACHE(${Complex_SOURCE_DIR})
+
 CONFIGURE_FILE(
 CONFIGURE_FILE(
   ${Complex_SOURCE_DIR}/cmTestConfigure.h.in
   ${Complex_SOURCE_DIR}/cmTestConfigure.h.in
   ${Complex_BINARY_DIR}/cmTestConfigure.h)
   ${Complex_BINARY_DIR}/cmTestConfigure.h)
@@ -59,3 +61,25 @@ IF (EXEC_PROGRAM)
   EXEC_PROGRAM("echo EXEC_PROGRAM")
   EXEC_PROGRAM("echo EXEC_PROGRAM")
 ENDIF (EXEC_PROGRAM) 
 ENDIF (EXEC_PROGRAM) 
 
 
+#
+# More coverage
+#
+ABSTRACT_FILES(
+  ExtraSources/file1.cxx
+)
+
+INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
+
+#
+# Create directory.
+# The 'complex' executable will then test if this dir exists,
+# sadly it won't be able to remove it.
+#
+MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
+
+#
+# Test Cable
+#
+CABLE_CLASS_SET(Float float)
+CABLE_CLASS_SET(Mesh "itk::Mesh<$Float>")
+

+ 16 - 0
Tests/ComplexRelativePaths/Executable/CMakeLists.txt

@@ -1,4 +1,20 @@
 ADD_EXECUTABLE(complex complex)
 ADD_EXECUTABLE(complex complex)
+
 TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
 TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
 TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
 TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
 
 
+FIND_LIBRARY(CMAKE_LIB
+             CMakeLib 
+             ${Complex_BINARY_DIR}/../../Source
+             ${Complex_BINARY_DIR}/../../Source/Debug
+             ${Complex_BINARY_DIR}/../../Source/Release
+             ${Complex_BINARY_DIR}/../../Source/MinSizeRel
+             ${Complex_BINARY_DIR}/../../Source/RelWithDebInfo)
+
+TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
+LINK_LIBRARIES(${CMAKE_LIB})
+
+# More coverage
+
+INSTALL_TARGETS(/tmp complex)
+INSTALL_PROGRAMS(/tmp complex)

+ 78 - 19
Tests/ComplexRelativePaths/Executable/complex.cxx

@@ -3,16 +3,7 @@
 #include "file2.h"
 #include "file2.h"
 #include "sharedFile.h"
 #include "sharedFile.h"
 #include "cmStandardIncludes.h"
 #include "cmStandardIncludes.h"
-#include <sys/stat.h>
-#include <stdio.h>
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-#define _unlink unlink
-#else
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#endif
+#include "cmSystemTools.h"
 
 
 int passed = 0;
 int passed = 0;
 int failed = 0;
 int failed = 0;
@@ -31,14 +22,13 @@ void Passed(const char* Message, const char* m2="")
 
 
 void TestAndRemoveFile(const char* filename) 
 void TestAndRemoveFile(const char* filename) 
 {
 {
-  struct stat fs;
-  if (stat(filename, &fs) != 0)
+  if (!cmSystemTools::FileExists(filename))
     {
     {
     Failed("Could not find file: ", filename);
     Failed("Could not find file: ", filename);
     }
     }
   else
   else
     {
     {
-    if (unlink(filename) != 0)
+    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);
       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);
       }
       }
@@ -49,6 +39,26 @@ void TestAndRemoveFile(const char* filename)
     }
     }
 }
 }
 
 
+void TestDir(const char* filename) 
+{
+  if (!cmSystemTools::FileExists(filename))
+    {
+    Failed("Could not find dir: ", filename);
+    }
+  else
+    {
+    if (!cmSystemTools::FileIsDirectory(filename))
+      {
+      Failed("Unable to check if file is a directory: ", filename);
+      }
+    else
+      {
+      Passed("Find dir: ", filename);
+      }
+    }
+}
+
+
 int main()
 int main()
 {
 {
   if(sharedFunction() != 1)
   if(sharedFunction() != 1)
@@ -234,17 +244,66 @@ int main()
     }
     }
 #endif
 #endif
 
 
-  // A post-build custom-command has been attached to the lib.
+#ifndef CACHE_TEST_VAR1
+  Failed("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, "
+           "CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
+    }
+  else
+    {
+    Passed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
+    }
+#endif
+
+#ifndef CACHE_TEST_VAR2
+  Failed("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, "
+           "CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
+    }
+  else
+    {
+    Passed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
+    }
+#endif
+
+#ifndef CACHE_TEST_VAR3
+  Failed("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, "
+           "CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
+    }
+  else
+    {
+    Passed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
+    }
+#endif
+
+  // A post-build custom-command has been attached to the lib (see Library/).
   // It run ${CREATE_FILE_EXE} which will create the file
   // It run ${CREATE_FILE_EXE} which will create the file
-  // ${Complex_BINARY_DIR}/postbuild.txt.
+  // ${Complex_BINARY_DIR}/Library/postbuild.txt.
 
 
-  TestAndRemoveFile(BINARY_DIR "/postbuild.txt");
+  TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt");
 
 
-  // A custom target has been created.
+  // A custom target has been created (see Library/).
   // It run ${CREATE_FILE_EXE} which will create the file
   // It run ${CREATE_FILE_EXE} which will create the file
-  // ${Complex_BINARY_DIR}/custom_target1.txt.
+  // ${Complex_BINARY_DIR}/Library/custom_target1.txt.
+
+  TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt");
+
+  // A directory has been created.
 
 
-  TestAndRemoveFile(BINARY_DIR "/custom_target1.txt");
+  TestDir(BINARY_DIR "/make_dir");
 
 
   std::cout << "Passed: " << passed << "\n";
   std::cout << "Passed: " << passed << "\n";
   if(failed)
   if(failed)

+ 7 - 4
Tests/ComplexRelativePaths/Library/CMakeLists.txt

@@ -17,7 +17,7 @@ ADD_EXECUTABLE(create_file create_file.cxx)
 #
 #
 # Attach a post-build custom-command to the lib.
 # Attach a post-build custom-command to the lib.
 # It run ${CREATE_FILE_EXE} which will create the file
 # It run ${CREATE_FILE_EXE} which will create the file
-# ${Complex_BINARY_DIR}/postbuild.txt.
+# ${Complex_BINARY_DIR}/Library/postbuild.txt.
 # The 'complex' executable will then test if this file exists,
 # The 'complex' executable will then test if this file exists,
 # and remove it.
 # and remove it.
 #
 #
@@ -25,20 +25,23 @@ ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
 
 
 ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
 ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
                    COMMAND ${CREATE_FILE_EXE}
                    COMMAND ${CREATE_FILE_EXE}
-                   ARGS "${Complex_BINARY_DIR}/postbuild.txt"
+                   ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt"
                    TARGET CMakeTestLibraryShared)
                    TARGET CMakeTestLibraryShared)
 
 
 #
 #
 # Add custom target
 # Add custom target
 # It run ${CREATE_FILE_EXE} which will create the file
 # It run ${CREATE_FILE_EXE} which will create the file
-# ${Complex_BINARY_DIR}/custom_target1.txt.
+# ${Complex_BINARY_DIR}/Library/custom_target1.txt.
 # The 'complex' executable will then test if this file exists,
 # The 'complex' executable will then test if this file exists,
 # and remove it.
 # and remove it.
 #
 #
 ADD_CUSTOM_TARGET(custom_target1
 ADD_CUSTOM_TARGET(custom_target1
                   ALL
                   ALL
                   ${CREATE_FILE_EXE} 
                   ${CREATE_FILE_EXE} 
-                  "${Complex_BINARY_DIR}/custom_target1.txt")
+                  "${Complex_BINARY_DIR}/Library/custom_target1.txt")
 
 
 ADD_DEPENDENCIES(custom_target1 create_file)
 ADD_DEPENDENCIES(custom_target1 create_file)
 
 
+# More coverage
+
+SOURCE_GROUP(A_GROUP ".cxx")

+ 4 - 1
Tests/ComplexRelativePaths/cmTestConfigure.h.in

@@ -18,6 +18,10 @@
 #cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
 #cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
 #cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
 #cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
 
 
+#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
+#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
+#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
+
 // Needed to check for files
 // Needed to check for files
 
 
 #define BINARY_DIR "${Complex_BINARY_DIR}"
 #define BINARY_DIR "${Complex_BINARY_DIR}"
@@ -27,4 +31,3 @@
 #define BUILD_COMMAND_VAR "${BUILD_COMMAND_VAR}"
 #define BUILD_COMMAND_VAR "${BUILD_COMMAND_VAR}"
 #define BUILD_NAME_VAR "${BUILD_NAME_VAR}"
 #define BUILD_NAME_VAR "${BUILD_NAME_VAR}"
 #define SITE_NAME_VAR "${SITE_NAME_VAR}"
 #define SITE_NAME_VAR "${SITE_NAME_VAR}"
-