[Rt-commit] rt branch, 4.0/restore-principal-in-validator, updated. rt-4.0.10-96-g547af3b

Alex Vandiver alexmv at bestpractical.com
Fri Apr 12 16:48:51 EDT 2013


The branch, 4.0/restore-principal-in-validator has been updated
       via  547af3b40d401d9d4dc56cd76717b3bfdedb7cb7 (commit)
      from  a39f5fac6465f3e892d2e02723f030cbf36646f4 (commit)

Summary of changes:
 lib/RT/Test.pm              | 11 +++++++++--
 t/validator/group_members.t |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit 547af3b40d401d9d4dc56cd76717b3bfdedb7cb7
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Apr 12 16:48:48 2013 -0400

    Add a timeout to prevent failing inifite loop tests from hanging forever

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index efd856a..25e7c5a 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -1028,13 +1028,15 @@ sub run_mailgate {
 
 sub run_validator {
     my $self = shift;
-    my %args = (check => 1, resolve => 0, force => 1, @_ );
+    my %args = (check => 1, resolve => 0, force => 1, timeout => 0, @_ );
 
     my $validator_path = "$RT::SbinPath/rt-validator";
 
     my $cmd = $validator_path;
     die "Couldn't find $cmd command" unless -f $cmd;
 
+    my $timeout = delete $args{timeout};
+
     while( my ($k,$v) = each %args ) {
         next unless $v;
         $cmd .= " --$k '$v'";
@@ -1046,9 +1048,14 @@ sub run_validator {
     my $pid = IPC::Open2::open2($child_out, $child_in, $cmd);
     close $child_in;
 
-    my $result = do { local $/; <$child_out> };
+    local $SIG{ALRM} = sub { kill KILL => $pid; die "Timeout!" };
+
+    alarm $timeout if $timeout;
+    my $result = eval { local $/; <$child_out> };
+    warn $@ if $@;
     close $child_out;
     waitpid $pid, 0;
+    alarm 0;
 
     DBIx::SearchBuilder::Record::Cachable->FlushCache
         if $args{'resolve'};
diff --git a/t/validator/group_members.t b/t/validator/group_members.t
index bc46f37..af93c51 100644
--- a/t/validator/group_members.t
+++ b/t/validator/group_members.t
@@ -127,7 +127,7 @@ use RT::Test tests => 63;
     $dbh->do('DELETE FROM CachedGroupMembers WHERE GroupId = ?', {RaiseError => 1}, $group->id);
     DBIx::SearchBuilder::Record::Cachable->FlushCache;
 
-    my ($ecode, $res) = RT::Test->run_validator(resolve => 1);
+    my ($ecode, $res) = RT::Test->run_validator(resolve => 1, timeout => 30);
     ok $res;
 
     ($ecode, $res) = RT::Test->run_validator();

-----------------------------------------------------------------------


More information about the Rt-commit mailing list