Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix nightly ci #416

Merged
merged 2 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions tracing-attributes/test_async_await/tests/async_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use test_std_future::{
support::*,
};

use tokio_test::task::MockTask;
use tracing::subscriber::with_default;

#[tracing_attributes::instrument]
Expand All @@ -28,9 +27,8 @@ fn async_fn_only_enters_for_polls() {
.drop_span(span::mock().named("test_async_fn"))
.done()
.run_with_handle();
let mut task = MockTask::new();
with_default(subscriber, || {
block_on_future(&mut task, async { test_async_fn(2).await }).unwrap();
block_on_future(async { test_async_fn(2).await }).unwrap();
});
handle.assert_finished();
}
9 changes: 4 additions & 5 deletions tracing-futures/test_std_future/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
pin::Pin,
task::{Context, Poll},
};
use tokio_test::task::MockTask;
use tokio_test::task;

pub struct PollN<T, E> {
and_return: Option<Result<T, E>>,
Expand Down Expand Up @@ -53,14 +53,13 @@ impl PollN<(), ()> {
}
}

pub fn block_on_future<F>(task: &mut MockTask, future: F) -> F::Output
pub fn block_on_future<F>(future: F) -> F::Output
where
F: Future,
{
let mut future = Box::pin(future);

let mut task = task::spawn(future);
loop {
match task.poll(&mut future) {
match task.poll() {
Poll::Ready(v) => break v,
_ => {}
}
Expand Down
7 changes: 2 additions & 5 deletions tracing-futures/test_std_future/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ extern crate tracing_core;

use test_std_future::{block_on_future, support::*, PollN};

use tokio_test::task::MockTask;
use tracing::{subscriber::with_default, Level};
use tracing_futures::Instrument;

Expand All @@ -18,10 +17,9 @@ fn enter_exit_is_reasonable() {
.drop_span(span::mock().named("foo"))
.done()
.run_with_handle();
let mut task = MockTask::new();
with_default(subscriber, || {
let future = PollN::new_ok(2).instrument(span!(Level::TRACE, "foo"));
block_on_future(&mut task, future).unwrap();
block_on_future(future).unwrap();
});
handle.assert_finished();
}
Expand All @@ -36,10 +34,9 @@ fn error_ends_span() {
.drop_span(span::mock().named("foo"))
.done()
.run_with_handle();
let mut task = MockTask::new();
with_default(subscriber, || {
let future = PollN::new_err(2).instrument(span!(Level::TRACE, "foo"));
block_on_future(&mut task, future).unwrap_err();
block_on_future(future).unwrap_err();
});
handle.assert_finished();
}