[Cmake-commits] CMake branch, next, updated. v2.8.12-4774-g4b1ab8e

Nils Gladitz nilsgladitz at gmail.com
Sat Nov 2 08:06:23 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  4b1ab8eff9821de54fbba18913a30d6494ff5db9 (commit)
       via  35fbc10079fcbce51f542347cf74c57e3164b85e (commit)
      from  cc7cd7388b07d6d311a7db9efe632f66e68ccaff (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=4b1ab8eff9821de54fbba18913a30d6494ff5db9
commit 4b1ab8eff9821de54fbba18913a30d6494ff5db9
Merge: cc7cd73 35fbc10
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Sat Nov 2 08:06:21 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sat Nov 2 08:06:21 2013 -0400

    Merge topic 'robust-ctest_empty_binary_directory' into next
    
    35fbc10 CTest: more aggressive implementation of ctest_empty_binary_directory()


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=35fbc10079fcbce51f542347cf74c57e3164b85e
commit 35fbc10079fcbce51f542347cf74c57e3164b85e
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Fri Nov 1 21:55:45 2013 +0100
Commit:     Nils Gladitz <nilsgladitz at gmail.com>
CommitDate: Sat Nov 2 13:05:38 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..7d33cf3 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
@@ -1056,15 +1057,71 @@ bool cmCTestScriptHandler::EmptyBinaryDirectory(const char *sname)
     return false;
     }
 
+  // consider non existing target directory a success
+  if(!cmSystemTools::FileExists(sname))
+    {
+    return true;
+    }
+
   // 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;
 

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

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list