diff options
author | Brad King <brad.king@kitware.com> | 2020-05-18 12:51:33 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-05-18 12:51:33 (GMT) |
commit | ef4d992b5483403ea63df33fef1787b2c84f9b7e (patch) | |
tree | fcbbfb350206ed3a0c88c4180d834fee85fc0f4a /Source/kwsys/testDirectory.cxx | |
parent | 6c4bfb6e7f4998d2a163f78bde1dd1b982947c0a (diff) | |
parent | 8fd4c19e1b39efa6912321a72ac12a1c0121264e (diff) | |
download | CMake-ef4d992b5483403ea63df33fef1787b2c84f9b7e.zip CMake-ef4d992b5483403ea63df33fef1787b2c84f9b7e.tar.gz CMake-ef4d992b5483403ea63df33fef1787b2c84f9b7e.tar.bz2 |
Merge branch 'upstream-KWSys' into update-kwsys
# By KWSys Upstream
* upstream-KWSys:
KWSys 2020-05-18 (146f6b36)
Diffstat (limited to 'Source/kwsys/testDirectory.cxx')
-rw-r--r-- | Source/kwsys/testDirectory.cxx | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/Source/kwsys/testDirectory.cxx b/Source/kwsys/testDirectory.cxx index b1ab0c8..eb3ca32 100644 --- a/Source/kwsys/testDirectory.cxx +++ b/Source/kwsys/testDirectory.cxx @@ -57,7 +57,11 @@ int _doLongPathTest() Directory testdir; // Set res to failure if the directory doesn't load - res += !testdir.Load(testdirpath); + std::string errorMessage = ""; + res += !testdir.Load(testdirpath, &errorMessage); + if (errorMessage != "") { + std::cerr << "Failed to list directory: " << errorMessage << std::endl; + } // Increment res failure if the directory appears empty res += testdir.GetNumberOfFiles() == 0; // Increment res failures if the path has changed from @@ -73,6 +77,34 @@ int _doLongPathTest() return res; } +int _nonExistentDirectoryTest() +{ + using namespace kwsys; + int res = 0; + std::string testdirpath(TEST_SYSTEMTOOLS_BINARY_DIR + "/directory_testing/doesnt_exist/"); + std::string errorMessage; + Directory testdir; + + errorMessage = "foo"; + // Increment res failure if directory lists + res += testdir.Load(testdirpath, &errorMessage); +#if !defined(_WIN32) || defined(__CYGWIN__) + // Increment res failure if errorMessage is unmodified + res += (errorMessage == "foo"); +#endif + + errorMessage = "foo"; + // Increment res failure if directory has files + res += (testdir.GetNumberOfFilesInDirectory(testdirpath, &errorMessage) > 0); +#if !defined(_WIN32) || defined(__CYGWIN__) + // Increment res failure if errorMessage is unmodified + res += (errorMessage == "foo"); +#endif + + return res; +} + int _copyDirectoryTest() { using namespace kwsys; @@ -106,5 +138,6 @@ int _copyDirectoryTest() int testDirectory(int, char* []) { - return _doLongPathTest() + _copyDirectoryTest(); + return _doLongPathTest() + _nonExistentDirectoryTest() + + _copyDirectoryTest(); } |