summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-05-17 13:04:37 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-05-17 13:05:09 (GMT)
commit10a6c5a8422f95d5558763127601e72a4060d61e (patch)
treeac7a8ee7a49d89000869db0f92ebe91434cc99f4
parente81e024330c57b154a30f8c8af1a15a49d1614e5 (diff)
parent3333e2791b2f1684daf4c05a46e7506f52d38aff (diff)
downloadCMake-10a6c5a8422f95d5558763127601e72a4060d61e.zip
CMake-10a6c5a8422f95d5558763127601e72a4060d61e.tar.gz
CMake-10a6c5a8422f95d5558763127601e72a4060d61e.tar.bz2
Merge topic 'update-kwsys'
3333e2791b Help: Add release note about 'copy_directory' behavior change 24367563d7 Merge branch 'upstream-KWSys' into update-kwsys 1e0a2e9377 KWSys 2018-05-15 (5f757898) Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2080
-rw-r--r--Help/release/dev/copy_directory.rst6
-rw-r--r--Source/kwsys/SystemTools.cxx4
-rw-r--r--Source/kwsys/testDirectory.cxx33
3 files changed, 41 insertions, 2 deletions
diff --git a/Help/release/dev/copy_directory.rst b/Help/release/dev/copy_directory.rst
new file mode 100644
index 0000000..71b9fdf
--- /dev/null
+++ b/Help/release/dev/copy_directory.rst
@@ -0,0 +1,6 @@
+copy_directory
+--------------
+
+* The :manual:`cmake(1)` ``-E copy_directory`` tool now fails when the
+ source directory does not exist. Previously it succeeded by creating
+ an empty destination directory.
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 52f509a..7167527 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2282,7 +2282,9 @@ bool SystemTools::CopyADirectory(const std::string& source,
const std::string& destination, bool always)
{
Directory dir;
- dir.Load(source);
+ if (dir.Load(source) == 0) {
+ return false;
+ }
size_t fileNum;
if (!SystemTools::MakeDirectory(destination)) {
return false;
diff --git a/Source/kwsys/testDirectory.cxx b/Source/kwsys/testDirectory.cxx
index 983f2c6..62a0986 100644
--- a/Source/kwsys/testDirectory.cxx
+++ b/Source/kwsys/testDirectory.cxx
@@ -73,7 +73,38 @@ int _doLongPathTest()
return res;
}
+int _copyDirectoryTest()
+{
+ using namespace kwsys;
+ const std::string source(TEST_SYSTEMTOOLS_BINARY_DIR
+ "/directory_testing/copyDirectoryTestSrc");
+ if (SystemTools::PathExists(source)) {
+ std::cerr << source << " shouldn't exist before test" << std::endl;
+ return 1;
+ }
+ const std::string destination(TEST_SYSTEMTOOLS_BINARY_DIR
+ "/directory_testing/copyDirectoryTestDst");
+ if (SystemTools::PathExists(destination)) {
+ std::cerr << destination << " shouldn't exist before test" << std::endl;
+ return 2;
+ }
+ const bool copysuccess = SystemTools::CopyADirectory(source, destination);
+ const bool destinationexists = SystemTools::PathExists(destination);
+ if (copysuccess) {
+ std::cerr << "CopyADirectory should have returned false" << std::endl;
+ SystemTools::RemoveADirectory(destination);
+ return 3;
+ }
+ if (destinationexists) {
+ std::cerr << "CopyADirectory returned false, but destination directory"
+ << " has been created" << std::endl;
+ SystemTools::RemoveADirectory(destination);
+ return 4;
+ }
+ return 0;
+}
+
int testDirectory(int, char* [])
{
- return _doLongPathTest();
+ return _doLongPathTest() + _copyDirectoryTest();
}