Debian Codegraph @

t/integration/smoke.t

raw
1 use Test2::V0;
2
3 use File::Temp qw/tempdir/;
4 use File::Spec;
5
6 use App::Yath::Tester qw/yath/;
7 use Test2::Harness::Util::File::JSONL;
8
9 use Test2::Harness::Util::JSON qw/decode_json/;
10
11 my $dir = __FILE__;
12 $dir =~ s{\.t$}{}g;
13 $dir =~ s{^\./}{};
14
15 yath(
16 command => 'test',
17 pre => ['-p+SmokePlugin'],
18 args => [$dir, '--ext=tx'],
19 log => 1,
20 exit => 0,
21 test => \&the_test,
22 );
23
24 yath(
25 command => 'test',
26 pre => ['-p+SmokePlugin'],
27 args => [$dir, '-j3', '--ext=tx'],
28 log => 1,
29 exit => 0,
30 test => \&the_test,
31 );
32
33 sub the_test {
34 my $out = shift;
35 my $log = $out->{log};
36
37 my @order;
38 my @events = $log->poll();
39 while (@events) {
40 if (my $event = shift @events) {
41 my $f = $event->{facet_data};
42
43 if (my $l = $f->{harness_job_start}) {
44 push @order => $l;
45 }
46 }
47
48 # Check for additional events, probably should not have any, but we may hit
49 # a buffering limit in the log reader and need additional polls.
50 push @events => $log->poll;
51 }
52
53 # We care about the order in which events happened based on time stamp, not the
54 # order in which they were collected, which may be different. Here we will sort
55 # based on stamp.
56 @order = sort { $a->{stamp} <=> $b->{stamp} } @order;
57
58 is(
59 [map { $_->{rel_file} } @order[0 .. 3]],
60 bag {
61 item match qr/a\.tx$/;
62 item match qr/c\.tx$/;
63 item match qr/e\.tx$/;
64 item match qr/g\.tx$/;
65 end;
66 },
67 "The 4 smoke tests ran first"
68 );
69
70 is(
71 [map { $_->{rel_file} } @order[4 .. 7]],
72 bag {
73 item match qr/b\.tx$/;
74 item match qr/d\.tx$/;
75 item match qr/f\.tx$/;
76 item match qr/h\.tx$/;
77 end;
78 },
79 "The 4 non-smoke tests ran later"
80 );
81 }
82
83 done_testing;