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; | |
55c0d020 | 7 | use Object::Remote::FromData; |
f129bfaf | 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 | ||
00de75a1 | 22 | like($@, qr/^Object::Remote connection lost: (?:eof|.*Broken pipe)/, "Correct error message"); |
f129bfaf | 23 | |
55c0d020 | 24 | done_testing; |
f129bfaf | 25 | |
26 | __DATA__ | |
27 | ||
28 | package HangClass; | |
29 | ||
30 | use Moo; | |
31 | ||
32 | sub alive { | |
55c0d020 | 33 | return 1; |
f129bfaf | 34 | } |
35 | ||
36 | sub hang { | |
09130cd0 | 37 | while(1) { |
55c0d020 | 38 | sleep(1); |
09130cd0 | 39 | } |
f129bfaf | 40 | } |
41 | ||
42 | ||
43 | ||
44 | ||
45 |