Repository: mesos Updated Branches: refs/heads/master 059b8de2e -> 977b80ae5
Added an AWAIT macro for testing that futures transition out of pending. Review: https://reviews.apache.org/r/30352/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/aa9da626 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/aa9da626 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/aa9da626 Branch: refs/heads/master Commit: aa9da626a165cccab990f3300c0d7a14bfb437bf Parents: 059b8de Author: Benjamin Mahler <[email protected]> Authored: Tue Jan 27 18:46:52 2015 -0800 Committer: Benjamin Mahler <[email protected]> Committed: Tue Jan 27 19:03:55 2015 -0800 ---------------------------------------------------------------------- 3rdparty/libprocess/include/process/gtest.hpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/aa9da626/3rdparty/libprocess/include/process/gtest.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/include/process/gtest.hpp b/3rdparty/libprocess/include/process/gtest.hpp index b77e2fc..10f991d 100644 --- a/3rdparty/libprocess/include/process/gtest.hpp +++ b/3rdparty/libprocess/include/process/gtest.hpp @@ -82,6 +82,22 @@ bool await(const process::Future<T>& future, const Duration& duration) template <typename T> +::testing::AssertionResult Await( + const char* expr, + const char*, // Unused string representation of 'duration'. + const process::Future<T>& actual, + const Duration& duration) +{ + if (!process::internal::await(actual, duration)) { + return ::testing::AssertionFailure() + << "Failed to wait " << duration << " for " << expr; + } + + return ::testing::AssertionSuccess(); +} + + +template <typename T> ::testing::AssertionResult AwaitAssertReady( const char* expr, const char*, // Unused string representation of 'duration'. @@ -175,6 +191,15 @@ template <typename T1, typename T2> } +// TODO(bmahler): Differentiate EXPECT and ASSERT here. +#define AWAIT_FOR(actual, duration) \ + ASSERT_PRED_FORMAT2(Await, actual, duration) + + +#define AWAIT(actual) \ + AWAIT_FOR(actual, Seconds(10)) + + #define AWAIT_ASSERT_READY_FOR(actual, duration) \ ASSERT_PRED_FORMAT2(AwaitAssertReady, actual, duration)
