[Cmake-commits] CMake branch, next, updated. v2.8.12-4763-g3c01fbc

Nils Gladitz nilsgladitz at gmail.com
Fri Nov 1 17:22:28 EDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  3c01fbc10bbff4582cf102d159a32c32ed43c8de (commit)
       via  8de0b2eaff8843bde00348a4a7f059deaa3e1e3d (commit)
       via  9d9f102f5371a19e45fff5034f97b2f9f6d523f9 (commit)
      from  63256e5e9aefd51d564bee417d355e7bad4f20d7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3c01fbc10bbff4582cf102d159a32c32ed43c8de
commit 3c01fbc10bbff4582cf102d159a32c32ed43c8de
Merge: 63256e5 8de0b2e
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Fri Nov 1 17:22:19 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Nov 1 17:22:19 2013 -0400

    Merge topic 'robust-ctest_empty_binary_directory' into next
    
    8de0b2e CTest: more aggressive implementation of ctest_empty_binary_directory()
    9d9f102 Tests: added test for ctest_empty_binary_directory()


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8de0b2eaff8843bde00348a4a7f059deaa3e1e3d
commit 8de0b2eaff8843bde00348a4a7f059deaa3e1e3d
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Fri Nov 1 21:55:45 2013 +0100
Commit:     Nils Gladitz <nilsgladitz at gmail.com>
CommitDate: Fri Nov 1 21:55:45 2013 +0100

    CTest: more aggressive implementation of ctest_empty_binary_directory()
    
    Make sure that CMakeCache.txt is the last file being removed since
    the binary directory may be left in a state that is no longer
    removable otherwise.
    
    Also retry removal a couple of times which makes this more robust
    on windows where file locks may temporarily prevent removal.

diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 64bcd59..bae3de7 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -22,6 +22,7 @@
 
 //#include <cmsys/RegularExpression.hxx>
 #include <cmsys/Process.h>
+#include <cmsys/Directory.hxx>
 
 // used for sleep
 #ifdef _WIN32
@@ -1059,12 +1060,62 @@ bool cmCTestScriptHandler::EmptyBinaryDirectory(const char *sname)
   // try to avoid deleting directories that we shouldn't
   std::string check = sname;
   check += "/CMakeCache.txt";
-  if(cmSystemTools::FileExists(check.c_str()) &&
-     !cmSystemTools::RemoveADirectory(sname))
+
+  if(!cmSystemTools::FileExists(check.c_str()))
     {
     return false;
     }
-  return true;
+
+  for(int i = 0; i < 5; ++i)
+    {
+    if(TryToRemoveBinaryDirectoryOnce(sname))
+      {
+      return true;
+      }
+    cmSystemTools::Delay(100);
+    }
+
+  return false;
+}
+
+//-------------------------------------------------------------------------
+bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce(
+  const std::string& directoryPath)
+{
+  cmsys::Directory directory;
+  directory.Load(directoryPath.c_str());
+
+  for(unsigned long i = 0; i < directory.GetNumberOfFiles(); ++i)
+    {
+    std::string path = directory.GetFile(i);
+
+    if(path == "." || path == ".." || path == "CMakeCache.txt")
+      {
+      continue;
+      }
+
+    std::string fullPath = directoryPath + std::string("/") + path;
+
+    bool isDirectory = cmSystemTools::FileIsDirectory(fullPath.c_str()) &&
+      !cmSystemTools::FileIsSymlink(fullPath.c_str());
+
+    if(isDirectory)
+      {
+      if(!cmSystemTools::RemoveADirectory(fullPath.c_str()))
+        {
+        return false;
+        }
+      }
+    else
+      {
+      if(!cmSystemTools::RemoveFile(fullPath.c_str()))
+        {
+        return false;
+        }
+      }
+  }
+
+  return cmSystemTools::RemoveADirectory(directoryPath.c_str());
 }
 
 //-------------------------------------------------------------------------
diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h
index 80d5831..44e9dd0 100644
--- a/Source/CTest/cmCTestScriptHandler.h
+++ b/Source/CTest/cmCTestScriptHandler.h
@@ -135,6 +135,9 @@ private:
   // Add ctest command
   void AddCTestCommand(cmCTestCommand* command);
 
+  // Try to remove the binary directory once
+  static bool TryToRemoveBinaryDirectoryOnce(const std::string& directoryPath);
+
   std::vector<cmStdString> ConfigurationScripts;
   std::vector<bool> ScriptProcessScope;
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9d9f102f5371a19e45fff5034f97b2f9f6d523f9
commit 9d9f102f5371a19e45fff5034f97b2f9f6d523f9
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Fri Nov 1 21:32:16 2013 +0100
Commit:     Nils Gladitz <nilsgladitz at gmail.com>
CommitDate: Fri Nov 1 21:32:16 2013 +0100

    Tests: added test for ctest_empty_binary_directory()

diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 7c939ed..d4a55fc 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1943,6 +1943,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
     PASS_REGULAR_EXPRESSION "Upload\\.xml")
 
   configure_file(
+    "${CMake_SOURCE_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in"
+    "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake"
+    @ONLY ESCAPE_QUOTES)
+  add_test(CTestTestEmptyBinaryDirectory ${CMAKE_CTEST_COMMAND}
+    -S "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake" -V
+    --output-log "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/testOut.log"
+    )
+  set_tests_properties(CTestTestEmptyBinaryDirectory PROPERTIES
+    PASS_REGULAR_EXPRESSION "TEST_SUCCESS")
+
+  configure_file(
     "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in"
     "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake"
     @ONLY ESCAPE_QUOTES)
diff --git a/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in b/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in
new file mode 100644
index 0000000..8eb808f
--- /dev/null
+++ b/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in
@@ -0,0 +1,66 @@
+cmake_minimum_required(VERSION 2.8.12)
+
+set(CTEST_RUN_CURRENT_SCRIPT 0)
+
+set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestEmptyBinaryDirectory")
+set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestEmptyBinaryDirectory")
+
+# make sure ctest does not remove directories without a CMakeCache.txt in it
+set(EMPTY_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/empty_binary_dir")
+file(MAKE_DIRECTORY "${EMPTY_BINARY_DIR}")
+
+if(NOT EXISTS "${EMPTY_BINARY_DIR}"
+  OR EXISTS "${EMPTY_BINARY_DIR}/CMakeCache.txt")
+    message(FATAL_ERROR "empty_binary_dir precondition failed")
+endif()
+
+ctest_empty_binary_directory("${EMPTY_BINARY_DIR}")
+
+if(NOT EXISTS "${EMPTY_BINARY_DIR}")
+  message(FATAL_ERROR "empty_binary_dir should not have been removed")
+endif()
+
+# make sure ctest does remove directories with a CMakeCache.txt
+set(VALID_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/valid_binary_dir")
+file(MAKE_DIRECTORY "${VALID_BINARY_DIR}")
+file(WRITE "${VALID_BINARY_DIR}/CMakeCache.txt")
+
+if(NOT EXISTS "${VALID_BINARY_DIR}"
+  OR NOT EXISTS "${VALID_BINARY_DIR}/CMakeCache.txt")
+    message(FATAL_ERROR "valid_binary_dir precondition failed")
+endif()
+
+ctest_empty_binary_directory("${VALID_BINARY_DIR}")
+
+if(EXISTS "${VALID_BINARY_DIR}")
+  message(FATAL_ERROR "valid_binary_dir should have been removed")
+endif()
+
+# make sure ctest removes build directories recursively
+set(DEEP_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/deep_binary_dir")
+file(MAKE_DIRECTORY "${DEEP_BINARY_DIR}")
+file(WRITE "${DEEP_BINARY_DIR}/CMakeCache.txt")
+
+foreach(SUBDIR A Z A/A A/Z Z/A Z/Z)
+  set(FULL_SUBDIR "${DEEP_BINARY_DIR}/${SUBDIR}")
+  file(MAKE_DIRECTORY "${FULL_SUBDIR}")
+
+  foreach(SUBFILE A.cpp Z.bat)
+    set(FULL_SUBFILE "${FULL_SUBDIR}/${SUBFILE}")
+    file(WRITE "${FULL_SUBFILE}" "I am '${FULL_SUBFILE}'")
+  endforeach()
+endforeach()
+
+if(NOT EXISTS "${DEEP_BINARY_DIR}"
+  OR NOT EXISTS "${DEEP_BINARY_DIR}/CMakeCache.txt"
+  OR NOT EXISTS "${DEEP_BINARY_DIR}/Z/A/Z.bat")
+    message(FATAL_ERROR "deep_binary_dir precondition failed")
+endif()
+
+ctest_empty_binary_directory("${DEEP_BINARY_DIR}")
+
+if(EXISTS "${DEEP_BINARY_DIR}")
+  message(FATAL_ERROR "deep_binary_dir should have been removed")
+endif()
+
+message("TEST_SUCCESS")

-----------------------------------------------------------------------

Summary of changes:
 Source/CTest/cmCTestScriptHandler.cxx             |   57 +++++++++++++++++-
 Source/CTest/cmCTestScriptHandler.h               |    3 +
 Tests/CMakeLists.txt                              |   11 ++++
 Tests/CTestTestEmptyBinaryDirectory/test.cmake.in |   66 +++++++++++++++++++++
 4 files changed, 134 insertions(+), 3 deletions(-)
 create mode 100644 Tests/CTestTestEmptyBinaryDirectory/test.cmake.in


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list