File: consolidate.rs

package info (click to toggle)
rust-async-backtrace 0.2.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 252 kB
  • sloc: makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download
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
/// A test that taskdump_tree() consolidates adjacent identical subframes.
mod util;

#[test]
fn consolidate() {
    util::model(|| util::run(selecting()));
}

#[async_backtrace::framed]
async fn selecting() {
    tokio::select! {
        biased;
        _ = yielding_outer() => {}
        _ = yielding_outer() => {}
        _ = ready() => {}
    };
}

#[async_backtrace::framed]
async fn yielding_outer() {
    yielding_inner().await;
}

#[async_backtrace::framed]
async fn yielding_inner() {
    tokio::task::yield_now().await;
}

#[async_backtrace::framed]
async fn ready() {
    let dump = async_backtrace::taskdump_tree(true);

    pretty_assertions::assert_str_eq!(
        util::strip(dump),
        "\
╼ consolidate::selecting::{{closure}} at tests/consolidate.rs:LINE:COL
  ├╼ consolidate::ready::{{closure}} at tests/consolidate.rs:LINE:COL
  └╼ 2x consolidate::yielding_outer::{{closure}} at tests/consolidate.rs:LINE:COL
     └╼ consolidate::yielding_inner::{{closure}} at tests/consolidate.rs:LINE:COL"
    );
}