Skip to content

Commit cf94f91

Browse files
committed
mock: move subscriber mock from tracing-subscriber tests (#2369)
The `tracing-subscriber` module `tests::support` included functionality to mock a subscriber (via the `Subscribe` trait). This code depends on some items from `tracing_mock::collector` which should otherwise not be public. This change moves the mocking functionality inside `tracing-mock` behind a feature flag. Allowing the `Expect` enum and `MockHandle::new` from `tracing_mock::collector` to be made `pub(crate)` instead of `pub`. Since it's now used from two different modules, the `Expect` enum has been moved to its own module. This requires a lot of modifications to imports so that we're not doing wildcard imports from another crate (i.e. in `tracing-subscriber` importing wildcards from `tracing-mock`). Closes: #2359
1 parent 192921c commit cf94f91

21 files changed

+1126
-465
lines changed

tracing-mock/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ publish = false
2020
[dependencies]
2121
tracing = { path = "../tracing", version = "0.1.35", default-features = false }
2222
tracing-core = { path = "../tracing-core", version = "0.1.28", default-features = false }
23+
tracing-subscriber = { path = "../tracing-subscriber", version = "0.3", default-features = false, optional = true }
2324
tokio-test = { version = "0.4.2", optional = true }
2425

2526
# Fix minimal-versions; tokio-test fails with otherwise acceptable 0.1.0

tracing-mock/src/expectation.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use crate::{
2+
event::MockEvent,
3+
field,
4+
span::{MockSpan, NewSpan},
5+
};
6+
7+
#[derive(Debug, Eq, PartialEq)]
8+
pub(crate) enum Expect {
9+
Event(MockEvent),
10+
FollowsFrom {
11+
consequence: MockSpan,
12+
cause: MockSpan,
13+
},
14+
Enter(MockSpan),
15+
Exit(MockSpan),
16+
CloneSpan(MockSpan),
17+
DropSpan(MockSpan),
18+
Visit(MockSpan, field::Expect),
19+
NewSpan(NewSpan),
20+
Nothing,
21+
}

0 commit comments

Comments
 (0)