Debian Codegraph @

t/integration/persist.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 skip_all "This test is not run under automated testing"
12 if $ENV{AUTOMATED_TESTING};
13
14 my $dir = __FILE__;
15 $dir =~ s{\.t$}{}g;
16 $dir =~ s{^\./}{};
17
18 yath(command => 'start', exit => 0);
19
20 yath(
21 command => 'run',
22 args => [$dir, '--ext=tx', '--ext=txx'],
23 exit => T(),
24 test => sub {
25 my $out = shift;
26 like($out->{output}, qr{FAILED.*fail\.tx}, "'fail.tx' was seen as a failure when reading the output");
27 like($out->{output}, qr{PASSED.*pass\.tx}, "'pass.tx' was not seen as a failure when reading the output");
28 },
29 );
30
31
32 yath(
33 command => 'run',
34 args => [$dir, '--ext=tx'],
35 exit => 0,
36 test => sub {
37 my $out = shift;
38 unlike($out->{output}, qr{fail\.tx}, "'fail.tx' was not seen when reading the output");
39 like($out->{output}, qr{PASSED.*pass\.tx}, "'pass.tx' was not seen as a failure when reading the output");
40 },
41 );
42
43 yath(
44 command => 'which',
45 exit => 0,
46 test => sub {
47 my $out = shift;
48 like($out->{output}, qr/^\s*Found: .*yath-persist\.json$/m, "Found the persist file");
49 like($out->{output}, qr/^\s*PID: /m, "Found the PID");
50 like($out->{output}, qr/^\s*Dir: /m, "Found the Dir");
51 },
52 );
53
54 yath(command => 'reload', exit => 0);
55
56 yath(
57 command => 'watch',
58 args => ['STOP'],
59 exit => 0,
60 test => sub {
61 my $out = shift;
62 like($out->{output}, qr{yath-nested-runner \(default\) Runner caught SIGHUP, reloading}, "Reloaded runner");
63 },
64 );
65
66 yath(
67 command => 'run',
68 args => [$dir, '--ext=txx'],
69 exit => T(),
70 test => sub {
71 my $out = shift;
72
73 like($out->{output}, qr{FAILED.*fail\.tx}, "'fail.tx' was seen as a failure when reading the output");
74 unlike($out->{output}, qr{pass\.tx}, "'pass.tx' was not seen when reading the output");
75 },
76 );
77
78 yath(
79 command => 'run',
80 args => [$dir, '-vvv'],
81 exit => T(),
82 test => sub {
83 my $out = shift;
84
85 like($out->{output}, qr/No tests were seen!/, "Got error message");
86 },
87 );
88
89 yath(command => 'stop', exit => 0);
90
91 yath(
92 command => 'which',
93 exit => 0,
94 test => sub {
95 my $out = shift;
96 like($out->{output}, qr/No persistent harness was found for the current path\./, "No active runner");
97 },
98 );
99
100 done_testing;