start at 0.3.1 instead of 0.3.0
[scpubgit/Object-Remote.git] / t / watchdog.t
1 use strictures 1;
2 use Test::More;
3
4 require 't/logsetup.pl';
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
11 my $conn = Object::Remote::Connection->conn_from_spec("-", watchdog_timeout => 1)->connect;
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 {
33   return 1; 
34 }
35
36 sub hang {
37   while(1) {
38     sleep(1); 
39   }
40 }
41
42
43
44
45