Mailing List Archive

r3768 - in branches/maint_0.1x: lib/KinoSearch/Search t
Author: creamyg
Date: 2008-08-27 09:23:50 -0700 (Wed, 27 Aug 2008)
New Revision: 3768

Modified:
branches/maint_0.1x/lib/KinoSearch/Search/SearchServer.pm
branches/maint_0.1x/t/510-remote_search.t
Log:
Skip remote tests if we can't get a socket. [maint]


Modified: branches/maint_0.1x/lib/KinoSearch/Search/SearchServer.pm
===================================================================
--- branches/maint_0.1x/lib/KinoSearch/Search/SearchServer.pm 2008-08-27 04:36:54 UTC (rev 3767)
+++ branches/maint_0.1x/lib/KinoSearch/Search/SearchServer.pm 2008-08-27 16:23:50 UTC (rev 3768)
@@ -61,8 +61,9 @@
my $client_sock = $main_sock->accept;

# verify password
- chomp( my $pass = <$client_sock> );
- if ( $pass eq $self->{password} ) {
+ my $pass = <$client_sock>;
+ chomp($pass) if defined $pass;
+ if ( defined($pass) && $pass eq $self->{password} ) {
$read_set->add($client_sock);
print $client_sock "accepted\n";
}

Modified: branches/maint_0.1x/t/510-remote_search.t
===================================================================
--- branches/maint_0.1x/t/510-remote_search.t 2008-08-27 04:36:54 UTC (rev 3767)
+++ branches/maint_0.1x/t/510-remote_search.t 2008-08-27 16:23:50 UTC (rev 3768)
@@ -1,23 +1,20 @@
-#!/usr/bin/perl
use strict;
use warnings;

use Test::More;
use Time::HiRes qw( sleep );
+use IO::Socket::INET;
use lib 't';

+my $PORT_NUM = 7890;
BEGIN {
- if ($^O =~ /mswin/i) {
- plan( 'skip_all', "fork on Windows not supported by KS");
+ if ( $^O =~ /mswin/i ) {
+ plan( 'skip_all', "fork on Windows not supported by KS" );
}
- else {
- plan( tests => 6 );
- }
- use_ok('KinoSearch::Search::SearchServer');
- use_ok('KinoSearch::Search::SearchClient');
}

-
+use KinoSearch::Search::SearchServer;
+use KinoSearch::Search::SearchClient;
use KinoSearch::Searcher;
use KinoSearch::Analysis::Tokenizer;
use KinoSearch::Search::MultiSearcher;
@@ -40,7 +37,7 @@
);

my $server = KinoSearch::Search::SearchServer->new(
- port => 7890,
+ port => $PORT_NUM,
searchable => $searcher,
password => 'foo',
);
@@ -49,10 +46,22 @@
exit(0);
}

+my $test_client_sock = IO::Socket::INET->new(
+ PeerAddr => "localhost:$PORT_NUM",
+ Proto => 'tcp',
+);
+if ($test_client_sock) {
+ plan( tests => 4 );
+ undef $test_client_sock;
+}
+else {
+ plan( 'skip_all', "Can't get a socket: $!" );
+}
+
my $tokenizer2 = KinoSearch::Analysis::Tokenizer->new;
my $searchclient = KinoSearch::Search::SearchClient->new(
analyzer => $tokenizer2,
- peer_address => 'localhost:7890',
+ peer_address => "localhost:$PORT_NUM",
password => 'foo',
);

@@ -89,6 +98,3 @@
kill( TERM => $kid ) if $kid;
}

-
-
-


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch-commits