Neil Conway created MESOS-3812:
----------------------------------
Summary: gmock: IgnoreResult of FutureResult doesn't compile
Key: MESOS-3812
URL: https://issues.apache.org/jira/browse/MESOS-3812
Project: Mesos
Issue Type: Bug
Components: test
Reporter: Neil Conway
Priority: Minor
{code}
class MockReplica : public Replica
{
public:
explicit MockReplica(const string& path) :
Replica(path)
{
EXPECT_CALL(*this, update(_))
.WillRepeatedly(Invoke(this, &MockReplica::_update));
}
virtual ~MockReplica() {}
MOCK_METHOD1(update, process::Future<bool>(const Metadata::Status& status));
process::Future<bool> _update(const Metadata::Status& status)
{
return Replica::update(status);
}
};
TEST_F(CoordinatorTest, RecoveryRaceDummy)
{
const string path1 = os::getcwd() + "/.log1";
MockReplica* replica1 = new MockReplica(path1);
Future<bool> r1Ready;
Promise<bool> r1Continue;
EXPECT_CALL(*replica1, update(_))
.WillOnce(DoAll(IgnoreResult(FutureResult(&r1Ready,
Invoke(replica1,
&MockReplica::_update))),
Return(r1Continue.future())));
}
{code}
The intent here is to say: when replica1->update() is invoked, first call
replica1->_update(), then stash the return value of that call into the future
"r1Ready". Then use "r1Continue.future()" as the return value for the original
call to replica1->update(). [ Motivation: the test code wants to block replica1
until immediately after update() is invoked; we then want to examine the return
value of update(), do some other stuff, and then allow replica1 to continue. ]
This seems like it should work. However, it does not compile:
{noformat}
In file included from ../../mesos/src/tests/log_tests.cpp:28:
../../mesos/3rdparty/libprocess/include/process/future.hpp:863:7: error: no
viable conversion from 'const testing::internal::IgnoredValue' to 'const bool'
set(u);
^
../../mesos/3rdparty/libprocess/include/process/gmock.hpp:180:19: note: in
instantiation of function template specialization
'process::Future::Futuretesting::internal::IgnoredValue' requested here
promise.set(result);
^
../../mesos/3rdparty/libprocess/include/process/gmock.hpp:169:14: note: in
instantiation of member function 'FutureResultAction
(mesos::internal::tests::MockReplica::)(const
mesos::internal::log::Metadata_Status &)> > >::Implementation::Perform'
requested here
explicit Implementation(process::Future future, const A& action)
^
../../mesos/3rdparty/libprocess/include/process/gmock.hpp:161:37: note: in
instantiation of member function 'FutureResultAction
(mesos::internal::tests::MockReplica::)(const
mesos::internal::log::Metadata_Status &)> > >::Implementation::Implementation'
requested here
return ::testing::Action(new Implementation(future, action));
^
../3rdparty/libprocess/3rdparty/gmock-1.7.0/include/gmock/gmock-actions.h:801:46:
note: in instantiation of function template specialization 'FutureResultAction
(mesos::internal::tests::MockReplica::)(const
mesos::internal::log::Metadata_Status &)> > >::operator Action' requested here
explicit Impl(const A& action) : action_(action) {}
^
../3rdparty/libprocess/3rdparty/gmock-1.7.0/include/gmock/gmock-actions.h:791:26:
note: in instantiation of member function
'testing::internal::IgnoreResultAction
(mesos::internal::tests::MockReplica::)(const
mesos::internal::log::Metadata_Status &)> > > >::Impl::Impl' requested here
return Action(new Impl(action_));
^
../3rdparty/libprocess/3rdparty/gmock-1.7.0/include/gmock/gmock-actions.h:863:34:
note: in instantiation of function template specialization
'testing::internal::IgnoreResultAction
(mesos::internal::tests::MockReplica::)(const
mesos::internal::log::Metadata_Status &)> > > >::operator Action' requested here
return Action(new Impl(action1_, action2_));
^
../../mesos/src/tests/log_tests.cpp:680:15: note: in instantiation of function
template specialization 'testing::internal::DoBothAction
(mesos::internal::tests::MockReplica::*)(const
mesos::internal::log::Metadata_Status &)> > > >,
testing::internal::ReturnActionprocess::Future<bool > >::operator
Actionprocess::Future<bool (const mesos::internal::log::Metadata_Status &)>'
requested here
.WillOnce(DoAll(IgnoreResult(FutureResult(&r1Ready,
^
../../mesos/3rdparty/libprocess/include/process/future.hpp:426:21: note:
passing argument to parameter '_t' here
bool set(const T& _t);
^
1 error generated.
{noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)