Skip to content

mock: MockCollector can't differentiate between contextual and explicit roots #2440

Closed
@hds

Description

@hds

Bug Report

Version

master branch, tracing-mock isn't released yet.

Probably also happens on v0.1.x branch, I haven't checked, but that code is the same.

Crates

tracing-mock

Description

Expecting an explicit root or a contextual root will accept either indescriminately. The following test should panic, but it doesn't.

#[test]
fn explicit_vs_contextual_root() {
    use tracing_mock::{collector, expect};

    let (collector, handle) = collector::mock()
        .new_span(expect::span().with_contextual_parent(None))
        .new_span(expect::span().with_explicit_parent(None))
        .new_span(expect::span().with_contextual_parent(None))
        .new_span(expect::span().with_explicit_parent(None))
        .run_with_handle();

    tracing::collect::with_default(collector, || {
        tracing::info_span!("contextual_root");
        tracing::info_span!(parent: None, "explicit_root");
        tracing::info_span!(parent: None, "explicit_root");
        tracing::info_span!("contextual_root");
    });

    handle.assert_finished();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions