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