You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2018/11/13 00:26:20 UTC

[mesos] branch master updated (77b088b -> 01f596a)

This is an automated email from the ASF dual-hosted git repository.

benh pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git.


    from 77b088b  Always used absolute executable paths in parallel runner.
     new 9751364  Added some new generic flag parsers.
     new 6ce9ad9  Removed some generic flag parsers that are now in stout.
     new 01f596a  Refactored TemporaryDirectoryTest to be a mixin.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 3rdparty/stout/include/stout/flags/parse.hpp | 47 ++++++++++++++++++++
 3rdparty/stout/include/stout/tests/utils.hpp | 65 +++++++++++++++++++++++-----
 src/common/parse.hpp                         | 47 --------------------
 3 files changed, 101 insertions(+), 58 deletions(-)


[mesos] 01/03: Added some new generic flag parsers.

Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

benh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 975136403457f94b5890271f9d8b3f1bcf75a416
Author: Benjamin Hindman <be...@gmail.com>
AuthorDate: Sun Jul 15 09:54:30 2018 -0700

    Added some new generic flag parsers.
    
    Review: https://reviews.apache.org/r/67955
---
 3rdparty/stout/include/stout/flags/parse.hpp | 47 ++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/3rdparty/stout/include/stout/flags/parse.hpp b/3rdparty/stout/include/stout/flags/parse.hpp
index 4566b79..f69c81a 100644
--- a/3rdparty/stout/include/stout/flags/parse.hpp
+++ b/3rdparty/stout/include/stout/flags/parse.hpp
@@ -218,6 +218,53 @@ inline Try<int_fd> parse(const std::string& value)
 }
 #endif // __WINDOWS__
 
+
+// TODO(klueska): Generalize this parser to take any comma separated
+// list and convert it to its appropriate type (i.e., not just for
+// unsigned ints). Issues could arise when the generic type is a
+// string that contains commas though, so generalizing this is not as
+// straightforward as it looks at first glance.
+template <>
+inline Try<std::vector<unsigned int>> parse(const std::string& value)
+{
+  std::vector<unsigned int> result;
+
+  foreach (const std::string& token, strings::tokenize(value, ",")) {
+    Try<unsigned int> number = numify<unsigned int>(token);
+
+    if (number.isError()) {
+      return Error("Failed to numify '" + token + "': " + number.error());
+    }
+
+    result.push_back(number.get());
+  }
+
+  return result;
+}
+
+
+// NOTE: Strings in the set cannot contain commas, since that
+// is the delimiter and we provide no way to escape it.
+//
+// TODO(klueska): Generalize this parser to take any comma separated
+// list and convert it to its appropriate type (i.e., not just for
+// strings).
+template <>
+inline Try<std::set<std::string>> parse(const std::string& value)
+{
+  std::set<std::string> result;
+
+  foreach (const std::string& token, strings::tokenize(value, ",")) {
+    if (result.count(token) > 0) {
+      return Error("Duplicate token '" + token + "'");
+    }
+
+    result.insert(token);
+  }
+
+  return result;
+}
+
 } // namespace flags {
 
 #endif // __STOUT_FLAGS_PARSE_HPP__


[mesos] 02/03: Removed some generic flag parsers that are now in stout.

Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

benh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 6ce9ad94b1ab32cdfc071b86dbca3d980817d991
Author: Benjamin Hindman <be...@gmail.com>
AuthorDate: Sun Jul 15 09:54:54 2018 -0700

    Removed some generic flag parsers that are now in stout.
    
    Review: https://reviews.apache.org/r/67956
---
 src/common/parse.hpp | 47 -----------------------------------------------
 1 file changed, 47 deletions(-)

diff --git a/src/common/parse.hpp b/src/common/parse.hpp
index 03814e3..cb55eab 100644
--- a/src/common/parse.hpp
+++ b/src/common/parse.hpp
@@ -130,53 +130,6 @@ inline Try<hashmap<std::string, std::string>> parse(const std::string& value)
 }
 
 
-// TODO(klueska): Generalize this parser to take any comma separated
-// list and convert it to its appropriate type (i.e., not just for
-// unsigned ints). Issues could arise when the generic type is a
-// string that contains commas though, so generalizing this is not as
-// straightforward as it looks at first glance.
-template <>
-inline Try<std::vector<unsigned int>> parse(const std::string& value)
-{
-  std::vector<unsigned int> result;
-
-  foreach (const std::string& token, strings::tokenize(value, ",")) {
-    Try<unsigned int> number = numify<unsigned int>(token);
-
-    if (number.isError()) {
-      return Error("Failed to numify '" + token + "': " + number.error());
-    }
-
-    result.push_back(number.get());
-  }
-
-  return result;
-}
-
-
-// NOTE: Strings in the set cannot contain commas, since that
-// is the delimiter and we provide no way to escape it.
-//
-// TODO(klueska): Generalize this parser to take any comma separated
-// list and convert it to its appropriate type (i.e., not just for
-// unsigned ints).
-template <>
-inline Try<std::set<std::string>> parse(const std::string& value)
-{
-  std::set<std::string> result;
-
-  foreach (const std::string& token, strings::tokenize(value, ",")) {
-    if (result.count(token) > 0) {
-      return Error("Duplicate token '" + token + "'");
-    }
-
-    result.insert(token);
-  }
-
-  return result;
-}
-
-
 template <>
 inline Try<mesos::CapabilityInfo> parse(const std::string& value)
 {


[mesos] 03/03: Refactored TemporaryDirectoryTest to be a mixin.

Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

benh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 01f596ab256e02a981985fc803508ae8d7f1efc0
Author: Benjamin Hindman <be...@gmail.com>
AuthorDate: Sun Jul 15 18:54:48 2018 -0700

    Refactored TemporaryDirectoryTest to be a mixin.
    
    Currently you can't easily "mixin" the functionality of the
    TemporaryDirectoryTest which makes for tests that might have a weird
    inheritance structure. This refactor makes it easy for you to get the
    functionality of the TemporaryDirectoryTest while easily composing it
    with other test classes.
    
    Review: https://reviews.apache.org/r/67957
---
 3rdparty/stout/include/stout/tests/utils.hpp | 65 +++++++++++++++++++++++-----
 1 file changed, 54 insertions(+), 11 deletions(-)

diff --git a/3rdparty/stout/include/stout/tests/utils.hpp b/3rdparty/stout/include/stout/tests/utils.hpp
index eb13cce..b8e96c5 100644
--- a/3rdparty/stout/include/stout/tests/utils.hpp
+++ b/3rdparty/stout/include/stout/tests/utils.hpp
@@ -30,17 +30,35 @@
 #include <stout/os/sysctl.hpp>
 #endif
 
-class TemporaryDirectoryTest : public ::testing::Test
+template <typename T>
+class MixinTemporaryDirectoryTest : public T
 {
 protected:
   void SetUp() override
   {
+    T::SetUp();
+
+    ASSERT_SOME(SetUpMixin());
+  }
+
+  void TearDown() override
+  {
+    ASSERT_SOME(TearDownMixin());
+
+    T::TearDown();
+  }
+
+  Try<Nothing> SetUpMixin()
+  {
     // Save the current working directory.
     cwd = os::getcwd();
 
     // Create a temporary directory for the test.
     Try<std::string> directory = os::mkdtemp();
-    ASSERT_SOME(directory) << "Failed to mkdtemp";
+
+    if (directory.isError()) {
+      return Error("Failed to mkdtemp: " + directory.error());
+    }
 
     // We get the `realpath` of the temporary directory because some
     // platforms, like macOS, symlink `/tmp` to `/private/var`, but
@@ -48,25 +66,46 @@ protected:
     // This is problematic because a lot of tests compare the
     // `realpath` of a temporary file.
     Result<std::string> realpath = os::realpath(directory.get());
-    ASSERT_SOME(realpath) << "Failed to get realpath of '" << directory.get()
-                          << "': "
-                          << (realpath.isError() ? realpath.error()
-                                                 : "No such directory");
+
+    if (realpath.isError()) {
+      return Error("Failed to get realpath of '" + directory.get() + "'"
+                   ": " + realpath.error());
+    } else if (realpath.isNone()) {
+      return Error("Failed to get realpath of '" + directory.get() + "'"
+                   ": No such directory");
+    }
+
     sandbox = realpath.get();
 
     // Run the test out of the temporary directory we created.
-    ASSERT_SOME(os::chdir(sandbox.get()))
-      << "Failed to chdir into '" << sandbox.get() << "'";
+    Try<Nothing> chdir = os::chdir(sandbox.get());
+
+    if (chdir.isError()) {
+      return Error("Failed to chdir into '" + sandbox.get() + "'"
+                   ": " + chdir.error());
+    }
+
+    return Nothing();
   }
 
-  void TearDown() override
+  Try<Nothing> TearDownMixin()
   {
     // Return to previous working directory and cleanup the sandbox.
-    ASSERT_SOME(os::chdir(cwd));
+    Try<Nothing> chdir = os::chdir(cwd);
+
+    if (chdir.isError()) {
+      return Error("Failed to chdir into '" + cwd + "': " + chdir.error());
+    }
 
     if (sandbox.isSome()) {
-      ASSERT_SOME(os::rmdir(sandbox.get()));
+      Try<Nothing> rmdir = os::rmdir(sandbox.get());
+      if (rmdir.isError()) {
+        return Error("Failed to rmdir '" + sandbox.get() + "'"
+                     ": " + rmdir.error());
+      }
     }
+
+    return Nothing();
   }
 
   // A temporary directory for test purposes.
@@ -78,6 +117,10 @@ private:
 };
 
 
+class TemporaryDirectoryTest
+  : public MixinTemporaryDirectoryTest<::testing::Test> {};
+
+
 #ifdef __FreeBSD__
 inline bool isJailed() {
   int mib[4];