From 1e0a2e93775c8d3b6b81b82d285986ad2f9d1cf1 Mon Sep 17 00:00:00 2001 From: KWSys Upstream Date: Tue, 15 May 2018 08:52:52 -0400 Subject: KWSys 2018-05-15 (5f757898) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit 5f757898119974aa30f700d5c38928ee48407320 (master). Upstream Shortlog ----------------- Marian Klymov (1): d06fcab7 SystemTools: Check source directory in CopyADirectory --- SystemTools.cxx | 4 +++- testDirectory.cxx | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/SystemTools.cxx b/SystemTools.cxx index 52f509a..7167527 100644 --- a/SystemTools.cxx +++ b/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/testDirectory.cxx b/testDirectory.cxx index 983f2c6..62a0986 100644 --- a/testDirectory.cxx +++ b/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(); } -- cgit v0.12 From 3333e2791b2f1684daf4c05a46e7506f52d38aff Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 May 2018 09:54:27 -0400 Subject: Help: Add release note about 'copy_directory' behavior change Issue: #16001 --- Help/release/dev/copy_directory.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Help/release/dev/copy_directory.rst 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. -- cgit v0.12