1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! Test-only helpers shared across unit-test modules.
//!
//! Compiled only under `cfg(test)`, so nothing here reaches a release binary.
use Write;
use ;
use MakeWriter;
/// A `tracing` writer that appends everything to a shared buffer.
;
/// Runs `body` with `tracing` output captured, returning its value alongside the
/// captured log text.
///
/// Used to assert that a diagnostic actually names the file (or note) it is
/// about — the whole point of several warnings in this crate is *which* file is
/// broken, and only reading the emitted line can prove that.
///
/// The subscriber is installed for the calling thread only
/// (`tracing::subscriber::with_default`), so tests running in parallel do not
/// capture each other's output. `body` must therefore do its logging on this
/// thread: synchronous code, or an async block driven to completion here.
///
/// # The interest cache
///
/// `tracing` caches, per callsite and process-wide, whether any subscriber is
/// interested in it. A test running in parallel on a thread with no subscriber
/// can register a callsite while this one is being installed and leave it
/// cached as "never", after which this thread's subscriber silently misses it
/// (seen in CI: a capped-warnings test captured its summary line but none of
/// the 20 individual lines from the other callsite). Rebuilding the cache once
/// the subscriber is in place makes every already-registered callsite ask again.
pub