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: prepare tracing-mock 0.1.0-beta.1 #3167

Merged
merged 1 commit into from
Nov 29, 2024
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
11 changes: 11 additions & 0 deletions tracing-mock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 0.1.0-beta.1 (November 29, 2024)

[ [crates.io][crate-0.1.0-beta.1] ] | [ [docs.rs][docs-0.1.0-beta.1] ]

`tracing-mock` provides tools for making assertions about what `tracing`
diagnostics are emitted by code under test.

- Initial beta release

[docs-0.1.0-beta.1]: https://docs.rs/tracing-mock/0.1.0-beta.1
[crate-0.1.0-beta.1]: https://crates.io/crates/tracing-mock/0.1.0-beta.1
15 changes: 13 additions & 2 deletions tracing-mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,29 @@

[package]
name = "tracing-mock"
version = "0.1.0"
version = "0.1.0-beta.1"
authors = [
"Eliza Weisman <[email protected]>",
"Hayden Stainsby <[email protected]>",
"Tokio Contributors <[email protected]>",
]
license = "MIT"
readme = "README.md"
repository = "https://github.com/tokio-rs/tracing"
homepage = "https://tokio.rs"
description = """
Utilities for testing `tracing` and crates that uses it.
"""
categories = [
"development-tools::testing"
]
keywords = [
"tracing",
"mock",
"testing"
]
edition = "2018"
rust-version = "1.63.0"
publish = false

[dependencies]
tracing = { path = "../tracing", version = "0.1.41", features = ["std", "attributes"], default-features = false }
Expand Down
52 changes: 26 additions & 26 deletions tracing-mock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@

Utilities for testing [`tracing`] and crates that uses it.

[![Crates.io][crates-badge]][crates-url]
[![Documentation][docs-badge]][docs-url]
[![Documentation (master)][docs-master-badge]][docs-master-url]
[![MIT licensed][mit-badge]][mit-url]
[![Build Status][actions-badge]][actions-url]
[![Discord chat][discord-badge]][discord-url]

[Documentation][docs-master-url] | [Chat][discord-url]

[crates-badge]: https://img.shields.io/crates/v/tracing-mock.svg
[crates-url]: https://crates.io/crates/tracing-mock
[docs-badge]: https://docs.rs/tracing-mock/badge.svg
[docs-url]: https://docs.rs/tracing-mock/latest
[docs-master-badge]: https://img.shields.io/badge/docs-master-blue
[docs-master-url]: https://tracing-rs.netlify.com/tracing_mock
[docs-master-url]: https://tracing.rs/tracing_mock
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
[mit-url]: https://github.com/tokio-rs/tracing/blob/master/tracing-mock/LICENSE
[actions-badge]: https://github.com/tokio-rs/tracing/workflows/CI/badge.svg
Expand All @@ -32,40 +38,35 @@ by code under test.
*Compiler support: [requires `rustc` 1.63+][msrv]*

[msrv]: #supported-rust-versions
[`tracing`]: https://github.com/tokio-rs/tracing

## Usage

`tracing-mock` crate provides a mock
[`Collector`](https://tracing-rs.netlify.app/tracing/#collectors)
that allows asserting on the order and contents of
[spans](https://tracing-rs.netlify.app/tracing/#spans) and
[events](https://tracing-rs.netlify.app/tracing/#events).
The `tracing-mock` crate provides a mock [`Subscriber`][tracing-subscriber] that
allows asserting on the order and contents of [spans][tracing-spans] and
[events][tracing-events].

As `tracing-mock` isn't available on [crates.io](https://crates.io/)
yet, you must import it via git. When using `tracing-mock` with the
`tracing` `0.1` ecosystem, it is important that you also override the
source of any `tracing` crates that are transient dependencies. For
example, the `Cargo.toml` for your test crate could contain:
To get started with `tracing-mock`, check the documentation in the
[`subscriber`][mock-subscriber-mod] module and [`MockSubscriber`] struct.

```toml
[dependencies]
lib-under-test = "1.0" # depends on `tracing`
While `tracing-mock` is in beta, it is recommended that an exact version is
specified in the cargo manifest. Otherwise, `cargo update` will take the latest
beta version, which may contain breaking changes compared to previous betas.

[dev-dependencies]
tracing-mock = { git = "https://github.com/tokio-rs/tracing", branch = "v0.1.x", version = "0.1" }
tracing = { git = "https://github.com/tokio-rs/tracing", branch = "v0.1.x", version = "0.1" }
To do so, add the following to `Cargo.toml`:

[patch.crates-io]
tracing = { git = "https://github.com/tokio-rs/tracing", branch = "v0.1.x" }
tracing-core = { git = "https://github.com/tokio-rs/tracing", branch = "v0.1.x" }
```toml
[dependencies]
tracing-mock = "= 0.1.0-beta.1"
```

## Examples
[tracing-spans]: https://docs.rs/tracing/0.1/tracing/#spans
[tracing-events]: https://docs.rs/tracing/0.1/tracing/#events
[tracing-subscriber]: https://docs.rs/tracing/0.1/tracing/trait.Subscriber.html
[mock-subscriber-mod]: https://docs.rs/tracing-mock/0.1.0-beta.1/tracing_mock/subscriber/index.html
[`MockSubscriber`]: https://docs.rs/tracing-mock/0.1.0-beta.1/tracing_mock/subscriber/struct.MockSubscriber.html

The following examples are for the `master` branch. For examples that
will work with `tracing` from [crates.io], please check the
[v0.1.x](https://github.com/tokio-rs/tracing/tree/v0.1.x/tracing-mock)
branch.
## Examples

Below is an example that checks that an event contains a message:

Expand All @@ -87,7 +88,6 @@ with_default(subscriber, || {
});

handle.assert_finished();

```

Below is a slightly more complex example. `tracing-mock` asserts that, in order:
Expand Down