Commit | Line | Data |
f129bfaf |
1 | use strictures 1; |
2 | use Test::More; |
3 | |
2d7fe21c |
4 | $ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; |
f129bfaf |
5 | |
6 | use Object::Remote::Connection; |
7 | use Object::Remote::FromData; |
8 | |
9 | $SIG{ALRM} = sub { fail("Watchdog killed remote process in time"); die "test failed" }; |
10 | |
71087610 |
11 | my $conn = Object::Remote->connect("-", watchdog_timeout => 1); |
f129bfaf |
12 | |
13 | my $remote = HangClass->new::on($conn); |
14 | |
15 | isa_ok($remote, 'Object::Remote::Proxy'); |
16 | is($remote->alive, 1, "Hanging test object is running"); |
17 | |
18 | alarm(3); |
19 | |
20 | eval { $remote->hang }; |
21 | |
22 | like($@, qr/^Object::Remote connection lost: eof/, "Correct error message"); |
23 | |
24 | done_testing; |
25 | |
26 | __DATA__ |
27 | |
28 | package HangClass; |
29 | |
30 | use Moo; |
31 | |
32 | sub alive { |
09130cd0 |
33 | return 1; |
f129bfaf |
34 | } |
35 | |
36 | sub hang { |
09130cd0 |
37 | while(1) { |
38 | sleep(1); |
39 | } |
f129bfaf |
40 | } |
41 | |
42 | |
43 | |
44 | |
45 | |