Provide TestHarness to make testing future / combinator implementations easier. #598
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on #597
This PR adds a new type:
executor::TestHarness
. This type is very similar toSpawn
but is intended to be used from the context of tests. As such, it provides a slightly different API. While this functionality could be provided directly bySpawn
,Spawn
already has a fairly busy API surface and some of the capabilities ofTestHarness
doen't make as much sense when used in "real code".This PR only provides the ability to wrap a
Future
for now, but at a later time, support forStream
andSink
can be added.The idea would be for
TestHarness<impl Stream>
to provide:impl Iterator
poll_next(&mut self) -> Poll<Option<Self::Item>, Self::Error>
wait_next_timeout(&mut self) -> Result<Option<Self::Item>, TimeoutError<Self::Error>>
And for
TestHarness<impl Sink>
:try_send(&mut self, item: T::SinkItem) -> StartSend<T::SinkItem, T::SinkError>
send_timeout(&mut self, item: T::SinkItem) -> Result<(), SendTimeoutError<T::SinkItem, T::SinkError>>