Sha256: d594266818a3461886da33bfcc76937d89a433ed6980226fc428706b216c093c

Contents?: true

Size: 1.92 KB

Versions: 15

Compression:

Stored size: 1.92 KB

Contents

#![cfg(feature = "std")]

use tracing_mock::*;

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn spans_dont_leak() {
    fn do_span() {
        let span = tracing::debug_span!("alice");
        let _e = span.enter();
    }

    let (subscriber, handle) = subscriber::mock()
        .named("spans/subscriber1")
        .with_filter(|_| false)
        .done()
        .run_with_handle();

    let _guard = tracing::subscriber::set_default(subscriber);

    do_span();

    let alice = span::mock().named("alice");
    let (subscriber2, handle2) = subscriber::mock()
        .named("spans/subscriber2")
        .with_filter(|_| true)
        .new_span(alice.clone())
        .enter(alice.clone())
        .exit(alice.clone())
        .drop_span(alice)
        .done()
        .run_with_handle();

    tracing::subscriber::with_default(subscriber2, || {
        println!("--- subscriber 2 is default ---");
        do_span()
    });

    println!("--- subscriber 1 is default ---");
    do_span();

    handle.assert_finished();
    handle2.assert_finished();
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn events_dont_leak() {
    fn do_event() {
        tracing::debug!("alice");
    }

    let (subscriber, handle) = subscriber::mock()
        .named("events/subscriber1")
        .with_filter(|_| false)
        .done()
        .run_with_handle();

    let _guard = tracing::subscriber::set_default(subscriber);

    do_event();

    let (subscriber2, handle2) = subscriber::mock()
        .named("events/subscriber2")
        .with_filter(|_| true)
        .event(event::mock())
        .done()
        .run_with_handle();

    tracing::subscriber::with_default(subscriber2, || {
        println!("--- subscriber 2 is default ---");
        do_event()
    });

    println!("--- subscriber 1 is default ---");

    do_event();

    handle.assert_finished();
    handle2.assert_finished();
}

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
wasmtime-13.0.0 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-12.0.1 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-12.0.0 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-11.0.0 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-10.0.1 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-10.0.0 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-9.0.4 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-9.0.1 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-8.0.0 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-7.0.0 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-6.0.1 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-6.0.0 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-5.0.0 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-0.4.1 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs
wasmtime-0.4.0 ./ext/cargo-vendor/tracing-0.1.37/tests/filters_dont_leak.rs