mirror of
https://github.com/tokio-rs/tracing.git
synced 2025-10-02 23:34:40 +00:00

## Motivation Currently, `tracing-futures` and `tracing-attributes` both have separate crates for tests that require `std::future` and async/await syntax. These date back to before these features were stable, and the tests were separated because they could only be run on nighly Rust. This has not been the case for a long while, and `tracing` now supports `std::future` as the default, requiring opt-in support for `futures` 0.1. I think we had forgotten to remove the special-cased tests when we made that transition. ## Solution This branch removes the special-cased test crates, and moves all `std::future` and async/await tests into the main test dirs for these crates. I've also removed the separate CI steps that ran these. This should simplify things significantly! Signed-off-by: Eliza Weisman <eliza@buoyant.io>
33 lines
1.1 KiB
Rust
33 lines
1.1 KiB
Rust
#[path = "../../tracing-futures/tests/support.rs"]
|
|
// we don't use some of the test support functions, but `tracing-futures` does.
|
|
#[allow(dead_code)]
|
|
mod support;
|
|
use support::*;
|
|
|
|
use tracing::subscriber::with_default;
|
|
|
|
#[tracing_attributes::instrument]
|
|
async fn test_async_fn(polls: usize) -> Result<(), ()> {
|
|
let future = PollN::new_ok(polls);
|
|
tracing::trace!(awaiting = true);
|
|
future.await
|
|
}
|
|
|
|
#[test]
|
|
fn async_fn_only_enters_for_polls() {
|
|
let (subscriber, handle) = subscriber::mock()
|
|
.new_span(span::mock().named("test_async_fn"))
|
|
.enter(span::mock().named("test_async_fn"))
|
|
.event(event::mock().with_fields(field::mock("awaiting").with_value(&true)))
|
|
.exit(span::mock().named("test_async_fn"))
|
|
.enter(span::mock().named("test_async_fn"))
|
|
.exit(span::mock().named("test_async_fn"))
|
|
.drop_span(span::mock().named("test_async_fn"))
|
|
.done()
|
|
.run_with_handle();
|
|
with_default(subscriber, || {
|
|
block_on_future(async { test_async_fn(2).await }).unwrap();
|
|
});
|
|
handle.assert_finished();
|
|
}
|