[Cmake-commits] CMake branch, next, updated. v3.4.1-1603-g92f8b11

Brad King brad.king at kitware.com
Fri Dec 4 10:03:13 EST 2015


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  92f8b11450f00cf4e71a1bd42e55cc46a1dfb398 (commit)
       via  306e2016bb3e285fcfb58e0f17657dc228b67812 (commit)
       via  d5d90f5ec8792fafbe754e2c943825267f7aaff1 (commit)
      from  64adca56d7c4657c1aa20b11adee703ea9a003a6 (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 -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=92f8b11450f00cf4e71a1bd42e55cc46a1dfb398
commit 92f8b11450f00cf4e71a1bd42e55cc46a1dfb398
Merge: 64adca5 306e201
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Dec 4 10:03:12 2015 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Dec 4 10:03:12 2015 -0500

    Merge topic 'update-kwsys' into next
    
    306e2016 Merge branch 'upstream-kwsys' into update-kwsys
    d5d90f5e KWSys 2015-12-03 (6bfc1aef)


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=306e2016bb3e285fcfb58e0f17657dc228b67812
commit 306e2016bb3e285fcfb58e0f17657dc228b67812
Merge: e069aa0 d5d90f5
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Dec 4 09:59:04 2015 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Dec 4 09:59:04 2015 -0500

    Merge branch 'upstream-kwsys' into update-kwsys


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d5d90f5ec8792fafbe754e2c943825267f7aaff1
commit d5d90f5ec8792fafbe754e2c943825267f7aaff1
Author:     KWSys Robot <kwrobot at kitware.com>
AuthorDate: Thu Dec 3 19:19:37 2015 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Dec 4 09:58:59 2015 -0500

    KWSys 2015-12-03 (6bfc1aef)
    
    Extract upstream KWSys using the following shell commands.
    
    $ git archive --prefix=upstream-kwsys/ 6bfc1aef | tar x
    $ git shortlog --no-merges --abbrev=8 --format='%h %s' 9596e98d..6bfc1aef
    Rolf Eike Beer (6):
          9e9c8ae3 SystemTools: extend test coverage of SystemTools::MakeDirectory()
          3f3d9eb5 SystemTools: add basic tests for SystemTools::FindFile()
          9ca5f108 SystemTools: entirely remove the extension code on non-Windows platforms
          29f82f78 SystemTools: avoid needless copy of std::string
          ac667cdc SystemTools: remove 2 more explicit calls to FileIsDirectory()
          6bfc1aef SystemTools: do not call FileExists() before calling FileIsDirectory()

diff --git a/SystemTools.cxx b/SystemTools.cxx
index 37fe421..82087f0 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -2402,8 +2402,7 @@ bool SystemTools::CopyFileAlways(const std::string& source, const std::string& d
     // name as the source in that directory.
 
     std::string destination_dir;
-    if(SystemTools::FileExists(destination) &&
-       SystemTools::FileIsDirectory(destination))
+    if(SystemTools::FileIsDirectory(destination))
       {
       destination_dir = real_destination;
       SystemTools::ConvertToUnixSlashes(real_destination);
@@ -2969,19 +2968,14 @@ std::string SystemTools::FindProgram(
   const std::vector<std::string>& userPaths,
   bool no_system_path)
 {
-  std::vector<std::string> extensions;
   std::string tryPath;
 
 #if defined (_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
-  bool hasExtension = false;
+  std::vector<std::string> extensions;
   // check to see if the name already has a .xxx at
   // the end of it
-  if(name.size() > 3 && name[name.size()-4] == '.')
-    {
-    hasExtension = true;
-    }
   // on windows try .com then .exe
-  if(!hasExtension)
+  if(name.size() <= 3 || name[name.size()-4] != '.')
     {
     extensions.push_back(".com");
     extensions.push_back(".exe");
@@ -2992,8 +2986,7 @@ std::string SystemTools::FindProgram(
       {
       tryPath = name;
       tryPath += *i;
-      if(SystemTools::FileExists(tryPath) &&
-          !SystemTools::FileIsDirectory(tryPath))
+      if(SystemTools::FileExists(tryPath, true))
         {
         return SystemTools::CollapseFullPath(tryPath);
         }
@@ -3002,11 +2995,9 @@ std::string SystemTools::FindProgram(
 #endif
 
   // now try just the name
-  tryPath = name;
-  if(SystemTools::FileExists(tryPath) &&
-     !SystemTools::FileIsDirectory(tryPath))
+  if(SystemTools::FileExists(name, true))
     {
-    return SystemTools::CollapseFullPath(tryPath);
+    return SystemTools::CollapseFullPath(name);
     }
   // now construct the path
   std::vector<std::string> path;
@@ -3043,6 +3034,7 @@ std::string SystemTools::FindProgram(
     // Remove double quotes from the path on windows
     SystemTools::ReplaceString(*p, "\"", "");
 #endif
+#if defined (_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
     // first try with extensions
     for(std::vector<std::string>::iterator ext
           = extensions.begin(); ext != extensions.end(); ++ext)
@@ -3055,6 +3047,7 @@ std::string SystemTools::FindProgram(
         return SystemTools::CollapseFullPath(tryPath);
         }
       }
+#endif
     // now try it without them
     tryPath = *p;
     tryPath += name;
@@ -3133,8 +3126,7 @@ std::string SystemTools
     tryPath = *p;
     tryPath += name;
     tryPath += ".framework";
-    if(SystemTools::FileExists(tryPath)
-       && SystemTools::FileIsDirectory(tryPath))
+    if(SystemTools::FileIsDirectory(tryPath))
       {
       return SystemTools::CollapseFullPath(tryPath);
       }
diff --git a/testSystemTools.cxx b/testSystemTools.cxx
index a0f904f..4d97688 100644
--- a/testSystemTools.cxx
+++ b/testSystemTools.cxx
@@ -172,6 +172,63 @@ static bool CheckFileOperations()
       << testNewDir << std::endl;
     res = false;
     }
+  // calling it again should just return true
+  if (!kwsys::SystemTools::MakeDirectory(testNewDir))
+    {
+    std::cerr
+      << "Problem with second call to MakeDirectory for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
+  // calling with 0 pointer should return false
+  if (kwsys::SystemTools::MakeDirectory(0))
+    {
+    std::cerr
+      << "Problem with MakeDirectory(0)"
+      << std::endl;
+    res = false;
+    }
+  // calling with an empty string should return false
+  if (kwsys::SystemTools::MakeDirectory(std::string()))
+    {
+    std::cerr
+      << "Problem with MakeDirectory(std::string())"
+      << std::endl;
+    res = false;
+    }
+  // check existence
+  if (!kwsys::SystemTools::FileExists(testNewDir.c_str(), false))
+    {
+    std::cerr
+      << "Problem with FileExists as C string and not file for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
+  // remove it
+  if (!kwsys::SystemTools::RemoveADirectory(testNewDir))
+    {
+    std::cerr
+      << "Problem with RemoveADirectory for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
+  // check existence
+  if (kwsys::SystemTools::FileExists(testNewDir.c_str(), false))
+    {
+    std::cerr
+      << "After RemoveADirectory: "
+      << "Problem with FileExists as C string and not file for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
+  // create it using the char* version
+  if (!kwsys::SystemTools::MakeDirectory(testNewDir.c_str()))
+    {
+    std::cerr
+      << "Problem with second call to MakeDirectory as C string for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
 
   if (!kwsys::SystemTools::Touch(testNewFile.c_str(), true))
     {
@@ -180,6 +237,97 @@ static bool CheckFileOperations()
       << testNewFile << std::endl;
     res = false;
     }
+  // calling MakeDirectory with something that is no file should fail
+  if (kwsys::SystemTools::MakeDirectory(testNewFile))
+    {
+    std::cerr
+      << "Problem with to MakeDirectory for: "
+      << testNewFile << std::endl;
+    res = false;
+    }
+
+  // calling with 0 pointer should return false
+  if (kwsys::SystemTools::FileExists(0))
+    {
+    std::cerr
+      << "Problem with FileExists(0)"
+      << std::endl;
+    res = false;
+    }
+  if (kwsys::SystemTools::FileExists(0, true))
+    {
+    std::cerr
+      << "Problem with FileExists(0) as file"
+      << std::endl;
+    res = false;
+    }
+  // calling with an empty string should return false
+  if (kwsys::SystemTools::FileExists(std::string()))
+    {
+    std::cerr
+      << "Problem with FileExists(std::string())"
+      << std::endl;
+    res = false;
+    }
+  // FileExists(x, true) should return false on a directory
+  if (kwsys::SystemTools::FileExists(testNewDir, true))
+    {
+    std::cerr
+      << "Problem with FileExists as file for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
+  if (kwsys::SystemTools::FileExists(testNewDir.c_str(), true))
+    {
+    std::cerr
+      << "Problem with FileExists as C string and file for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
+  // FileExists(x, false) should return true even on a directory
+  if (!kwsys::SystemTools::FileExists(testNewDir, false))
+    {
+    std::cerr
+      << "Problem with FileExists as not file for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
+  if (!kwsys::SystemTools::FileExists(testNewDir.c_str(), false))
+    {
+    std::cerr
+      << "Problem with FileExists as C string and not file for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
+  // should work, was created as new file before
+  if (!kwsys::SystemTools::FileExists(testNewFile))
+    {
+    std::cerr
+      << "Problem with FileExists for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
+  if (!kwsys::SystemTools::FileExists(testNewFile.c_str()))
+    {
+    std::cerr
+      << "Problem with FileExists as C string for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
+  if (!kwsys::SystemTools::FileExists(testNewFile, true))
+    {
+    std::cerr
+      << "Problem with FileExists as file for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
+  if (!kwsys::SystemTools::FileExists(testNewFile.c_str(), true))
+    {
+    std::cerr
+      << "Problem with FileExists as C string and file for: "
+      << testNewDir << std::endl;
+    res = false;
+    }
 
   // Reset umask
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -851,6 +999,44 @@ static bool CheckGetPath()
   return res;
 }
 
+static bool CheckFind()
+{
+  bool res = true;
+  const std::string testFindFileName("testFindFile.txt");
+  const std::string testFindFile(TEST_SYSTEMTOOLS_BINARY_DIR "/"
+                                 + testFindFileName);
+
+  if (!kwsys::SystemTools::Touch(testFindFile.c_str(), true))
+    {
+    std::cerr
+      << "Problem with Touch for: "
+      << testFindFile << std::endl;
+    // abort here as the existence of the file only makes the test meaningful
+    return false;
+    }
+
+  std::vector<std::string> searchPaths;
+  searchPaths.push_back(TEST_SYSTEMTOOLS_BINARY_DIR);
+  if (kwsys::SystemTools::FindFile(testFindFileName,
+                                    searchPaths, true).empty())
+    {
+    std::cerr
+      << "Problem with FindFile without system paths for: "
+      << testFindFileName << std::endl;
+    res = false;
+    }
+  if (kwsys::SystemTools::FindFile(testFindFileName,
+                                    searchPaths, false).empty())
+    {
+    std::cerr
+      << "Problem with FindFile with system paths for: "
+      << testFindFileName << std::endl;
+    res = false;
+    }
+
+  return res;
+}
+
 //----------------------------------------------------------------------------
 int testSystemTools(int, char*[])
 {
@@ -888,5 +1074,7 @@ int testSystemTools(int, char*[])
 
   res &= CheckGetPath();
 
+  res &= CheckFind();
+
   return res ? 0 : 1;
 }

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

Summary of changes:
 Source/kwsys/SystemTools.cxx     |   26 ++----
 Source/kwsys/testSystemTools.cxx |  188 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 197 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list