File: async_trace.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (55 lines) | stat: -rw-r--r-- 1,957 bytes parent folder | download | duplicates (8)
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
use Test2::Tools::Tiny qw/ok done_testing tests/;
use Test2::Tools::AsyncSubtest;
use Test2::API qw/intercept test2_add_uuid_via/;

our %CNT;
test2_add_uuid_via(sub {
    my $type = shift;
    $CNT{$type} ||= 1;
    $type . '-' . $CNT{$type}++;
});

my $events = intercept {
    local %CNT = ();
    tests foo => sub {
        ok(1, "pass");
    };

    local %CNT = ();
    my $ast = async_subtest foo => sub {
        ok(1, "pass");
    };
    $ast->finish;
};

tests regular => sub {
    ok($events->[0]->subtest_uuid, "subtest got a subtest uuid");

    ok($events->[0]->trace->{cid},   "subtest trace got a cid");
    ok($events->[0]->trace->{hid},   "subtest trace got a hid");
    ok($events->[0]->trace->{uuid},  "subtest trace got a uuid");
    ok($events->[0]->trace->{huuid}, "subtest trace got a huuid");

    ok($events->[0]->subevents->[-1]->trace->{cid},   "subtest plan trace got a cid");
    ok($events->[0]->subevents->[-1]->trace->{hid},   "subtest plan trace got a hid");
    ok($events->[0]->subevents->[-1]->trace->{uuid},  "subtest plan trace got a uuid");
    ok($events->[0]->subevents->[-1]->trace->{huuid}, "subtest plan trace got a huuid");
};

tests async => sub {
    ok($events->[1]->subtest_uuid, "async subtest got a subtest uuid");

    ok($events->[1]->trace->{cid},   "async subtest trace got a cid");
    ok($events->[1]->trace->{hid},   "async subtest trace got a hid");
    ok($events->[1]->trace->{uuid},  "async subtest trace got a uuid");
    ok($events->[1]->trace->{huuid}, "async subtest trace got a huuid");

    ok($events->[1]->subevents->[-1]->trace->{cid},   "async subtest plan trace got a cid");
    ok($events->[1]->subevents->[-1]->trace->{hid},   "async subtest plan trace got a hid");
    ok($events->[1]->subevents->[-1]->trace->{uuid},  "async subtest plan trace got a uuid");
    ok($events->[1]->subevents->[-1]->trace->{huuid}, "async subtest plan trace got a huuid");
};

done_testing;

__END__