You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/04/19 16:24:39 UTC
[3/7] mesos git commit: Windows: Fixed `rmdir.hpp` build.
Windows: Fixed `rmdir.hpp` build.
Review: https://reviews.apache.org/r/45987/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/22da1564
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/22da1564
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/22da1564
Branch: refs/heads/master
Commit: 22da1564f87b840619ee8d17ed60dbf0a44d01f1
Parents: d891e0f
Author: Alex Clemmer <cl...@gmail.com>
Authored: Mon Apr 18 14:29:27 2016 -0400
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Tue Apr 19 10:24:14 2016 -0400
----------------------------------------------------------------------
.../stout/include/stout/os/windows/rmdir.hpp | 3 +-
.../3rdparty/stout/tests/os/rmdir_tests.cpp | 45 +++++++++++---------
2 files changed, 27 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/22da1564/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/rmdir.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/rmdir.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/rmdir.hpp
index dd5cc69..772b86d 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/rmdir.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/rmdir.hpp
@@ -76,7 +76,8 @@ inline Try<Nothing> recursive_remove_directory(
// Delete current path, whether it's a directory, file, or symlink.
if (is_directory) {
- Try<Nothing> removed = recursive_remove_directory(current_absolute_path);
+ Try<Nothing> removed =
+ recursive_remove_directory(current_absolute_path, removeRoot);
if (removed.isError()) {
return Error(removed.error());
http://git-wip-us.apache.org/repos/asf/mesos/blob/22da1564/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp
index cc92953..a11bfc9 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp
@@ -22,6 +22,7 @@
#include <stout/os/getcwd.hpp>
#include <stout/os/ls.hpp>
#include <stout/os/mkdir.hpp>
+#include <stout/os/stat.hpp>
#include <stout/os/touch.hpp>
#include <stout/tests/utils.hpp>
@@ -31,9 +32,6 @@ using std::set;
using std::string;
-const hashset<string>& EMPTY = hashset<string>::EMPTY;
-
-
static hashset<string> listfiles(const string& directory)
{
hashset<string> fileset;
@@ -56,7 +54,7 @@ class RmdirTest : public TemporaryDirectoryTest {};
TEST_F(RmdirTest, TrivialRemoveEmptyDirectoryAbsolutePath)
{
const string tmpdir = os::getcwd();
- hashset<string> expectedListing = EMPTY;
+ hashset<string> expectedListing = hashset<string>::EMPTY;
// Directory is initially empty.
EXPECT_EQ(expectedListing, listfiles(tmpdir));
@@ -67,18 +65,18 @@ TEST_F(RmdirTest, TrivialRemoveEmptyDirectoryAbsolutePath)
expectedListing.insert(newDirectoryName);
EXPECT_SOME(os::mkdir(newDirectoryAbsolutePath));
EXPECT_EQ(expectedListing, listfiles(tmpdir));
- EXPECT_EQ(EMPTY, listfiles(newDirectoryAbsolutePath));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(newDirectoryAbsolutePath));
// Successfully remove.
EXPECT_SOME(os::rmdir(newDirectoryAbsolutePath));
- EXPECT_EQ(EMPTY, listfiles(tmpdir));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(tmpdir));
}
TEST_F(RmdirTest, TrivialRemoveEmptyDirectoryRelativePath)
{
const string tmpdir = os::getcwd();
- hashset<string> expectedListing = EMPTY;
+ hashset<string> expectedListing = hashset<string>::EMPTY;
// Directory is initially empty.
EXPECT_EQ(expectedListing, listfiles(tmpdir));
@@ -88,19 +86,19 @@ TEST_F(RmdirTest, TrivialRemoveEmptyDirectoryRelativePath)
expectedListing.insert(newDirectoryName);
EXPECT_SOME(os::mkdir(newDirectoryName));
EXPECT_EQ(expectedListing, listfiles(tmpdir));
- EXPECT_EQ(EMPTY, listfiles(newDirectoryName));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(newDirectoryName));
// Successfully remove.
EXPECT_SOME(os::rmdir(newDirectoryName));
- EXPECT_EQ(EMPTY, listfiles(tmpdir));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(tmpdir));
}
TEST_F(RmdirTest, RemoveRecursiveByDefault)
{
const string tmpdir = os::getcwd();
- hashset<string> expectedRootListing = EMPTY;
- hashset<string> expectedSubListing = EMPTY;
+ hashset<string> expectedRootListing = hashset<string>::EMPTY;
+ hashset<string> expectedSubListing = hashset<string>::EMPTY;
// Directory is initially empty.
EXPECT_EQ(expectedRootListing, listfiles(tmpdir));
@@ -124,29 +122,29 @@ TEST_F(RmdirTest, RemoveRecursiveByDefault)
// Successfully remove.
EXPECT_SOME(os::rmdir(newDirectoryAbsolutePath));
- EXPECT_EQ(EMPTY, listfiles(tmpdir));
- EXPECT_EQ(EMPTY, listfiles(newDirectoryAbsolutePath));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(tmpdir));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(newDirectoryAbsolutePath));
}
TEST_F(RmdirTest, TrivialFailToRemoveInvalidPath)
{
// Directory is initially empty.
- EXPECT_EQ(EMPTY, listfiles(os::getcwd()));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(os::getcwd()));
// Removing fake relative paths should error out.
EXPECT_ERROR(os::rmdir("fakeRelativePath", false));
EXPECT_ERROR(os::rmdir("fakeRelativePath", true));
// Directory still empty.
- EXPECT_EQ(EMPTY, listfiles(os::getcwd()));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(os::getcwd()));
}
TEST_F(RmdirTest, FailToRemoveNestedInvalidPath)
{
const string tmpdir = os::getcwd();
- hashset<string> expectedRootListing = EMPTY;
+ hashset<string> expectedRootListing = hashset<string>::EMPTY;
// Directory is initially empty.
EXPECT_EQ(expectedRootListing, listfiles(tmpdir));
@@ -159,24 +157,30 @@ TEST_F(RmdirTest, FailToRemoveNestedInvalidPath)
EXPECT_SOME(os::mkdir(newDirectoryAbsolutePath));
EXPECT_EQ(expectedRootListing, listfiles(tmpdir));
- EXPECT_EQ(EMPTY, listfiles(newDirectoryAbsolutePath));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(newDirectoryAbsolutePath));
// Fail to remove a path to an invalid folder inside the
// `newDirectoryAbsolutePath`.
const string fakeAbsolutePath = path::join(newDirectoryAbsolutePath, "fake");
EXPECT_ERROR(os::rmdir(fakeAbsolutePath, false));
EXPECT_EQ(expectedRootListing, listfiles(tmpdir));
- EXPECT_EQ(EMPTY, listfiles(newDirectoryAbsolutePath));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(newDirectoryAbsolutePath));
// Test the same thing, but using the `recursive` flag.
EXPECT_ERROR(os::rmdir(fakeAbsolutePath, true));
EXPECT_EQ(expectedRootListing, listfiles(tmpdir));
- EXPECT_EQ(EMPTY, listfiles(newDirectoryAbsolutePath));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(newDirectoryAbsolutePath));
}
+#ifndef __WINDOWS__
// This test verifies that `rmdir` can remove a directory with a
// device file.
+// TODO(hausdorff): Port this test to Windows. It is not clear that `rdev` and
+// `mknod` will implement the functionality expressed in this test, and as the
+// need for these capabilities arise elsewhere in the codebase, we should
+// rethink abstractions we need here, and subsequently, what this test should
+// look like.
TEST_F(RmdirTest, RemoveDirectoryWithDeviceFile)
{
// mknod requires root permission.
@@ -211,6 +215,7 @@ TEST_F(RmdirTest, RemoveDirectoryWithDeviceFile)
EXPECT_SOME(os::rmdir(deviceDirectory));
}
+#endif // __WINDOWS__
// This test verifies that `rmdir` can remove a directory with a
@@ -294,5 +299,5 @@ TEST_F(RmdirTest, RemoveDirectoryButPreserveRoot)
EXPECT_SOME(os::rmdir(newDirectory, true, false));
EXPECT_TRUE(os::exists(newDirectory));
- EXPECT_EQ(EMPTY, listfiles(newDirectory));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(newDirectory));
}