1use strict;
2use warnings;
3
4use Test2::IPC::Driver::Files;
5
6use Test2::Tools::Tiny;
7use Test2::API qw/context test2_ipc_drivers/;
8
9Test2::IPC::Driver::Files->import();
10Test2::IPC::Driver::Files->import();
11Test2::IPC::Driver::Files->import();
12
13is_deeply(
14    [test2_ipc_drivers()],
15    ['Test2::IPC::Driver::Files'],
16    "Driver not added multiple times"
17);
18
19for my $meth (qw/send cull add_hub drop_hub waiting is_viable/) {
20    my $one = Test2::IPC::Driver->new;
21    like(
22        exception { $one->$meth },
23        qr/'\Q$one\E' did not define the required method '$meth'/,
24        "Require override of method $meth"
25    );
26}
27
28SKIP: {
29    last SKIP if $] lt "5.008";
30tests abort => sub {
31    my $one = Test2::IPC::Driver->new(no_fatal => 1);
32    my ($err, $out) = ("", "");
33
34    {
35        local *STDERR;
36        local *STDOUT;
37        open(STDERR, '>', \$err);
38        open(STDOUT, '>', \$out);
39        $one->abort('foo');
40    }
41
42    is($err, "IPC Fatal Error: foo\n", "Got error");
43    is($out, "Bail out! IPC Fatal Error: foo\n", "got 'bail-out' on stdout");
44
45    ($err, $out) = ("", "");
46
47    {
48        local *STDERR;
49        local *STDOUT;
50        open(STDERR, '>', \$err);
51        open(STDOUT, '>', \$out);
52        $one->abort_trace('foo');
53    }
54
55    like($out, qr/Bail out! IPC Fatal Error: foo/, "got 'bail-out' on stdout");
56    like($err, qr/IPC Fatal Error: foo/, "Got error");
57};
58}
59
60done_testing;
61