You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2016/09/30 15:45:18 UTC

[1/2] lucy git commit: Regenerate charmonizer.c for pattern rules fix

Repository: lucy
Updated Branches:
  refs/heads/master 8576b7418 -> 0959ad9d3


Regenerate charmonizer.c for pattern rules fix

Fixes LUCY-309.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/26d3c773
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/26d3c773
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/26d3c773

Branch: refs/heads/master
Commit: 26d3c773fc2784ef6f45eac622e4d99af63a5476
Parents: 8576b74
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Sep 29 16:29:11 2016 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Thu Sep 29 16:29:11 2016 +0200

----------------------------------------------------------------------
 common/charmonizer.c | 39 +++++++++++++++++++++++++++++++--------
 1 file changed, 31 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/26d3c773/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/common/charmonizer.c b/common/charmonizer.c
index 652f3f3..f74a45f 100644
--- a/common/charmonizer.c
+++ b/common/charmonizer.c
@@ -4567,9 +4567,10 @@ typedef struct {
 static struct {
     char *make_command;
     int   shell_type;
+    int   supports_pattern_rules;
 } chaz_Make = {
     NULL,
-    0
+    0, 0
 };
 
 /* Detect make command.
@@ -4695,7 +4696,12 @@ S_chaz_Make_detect(const char *make1, ...) {
     va_list args;
     const char *candidate;
     int found = 0;
-    const char makefile_content[] = "foo:\n\t@echo 643490c943525d19\n";
+    const char makefile_content[] =
+        "foo:\n"
+        "\t@echo 643490c943525d19\n"
+        "\n"
+        "%.ext:\n"
+        "\t@echo 8f4ef20576b070d5\n";
     chaz_Util_write_file("_charm_Makefile", makefile_content);
 
     /* Audition candidates. */
@@ -4727,12 +4733,28 @@ S_chaz_Make_audition(const char *make) {
         free(content);
     }
     chaz_Util_remove_and_verify("_charm_foo");
+    free(command);
 
     if (succeeded) {
         chaz_Make.make_command = chaz_Util_strdup(make);
+
+        command = chaz_Util_join(" ", make, "-f", "_charm_Makefile", "foo.ext",
+                                 NULL);
+        chaz_OS_run_redirected(command, "_charm_foo");
+        if (chaz_Util_can_open_file("_charm_foo")) {
+            size_t len;
+            char *content = chaz_Util_slurp_file("_charm_foo", &len);
+            if (content != NULL
+                && strstr(content, "8f4ef20576b070d5") != NULL
+               ) {
+                chaz_Make.supports_pattern_rules = 1;
+            }
+            free(content);
+        }
+        chaz_Util_remove_and_verify("_charm_foo");
+        free(command);
     }
 
-    free(command);
     return succeeded;
 }
 
@@ -5186,11 +5208,12 @@ S_chaz_MakeFile_write_binary_rules(chaz_MakeFile *self,
 
     /* Write rules to compile with custom flags. */
     if (cflags[0] != '\0') {
-        if (chaz_Make.shell_type == CHAZ_OS_CMD_EXE) {
-            /* Write a rule for each object file. This is needed for nmake
-             * which doesn't support pattern rules but also for mingw32-make
-             * which has problems with pattern rules and backslash directory
-             * separators.
+        if (!chaz_Make.supports_pattern_rules
+            || chaz_Make.shell_type == CHAZ_OS_CMD_EXE) {
+            /* Write a rule for each object file. This is needed for make
+             * utilities that don't support pattern rules but also for
+             * mingw32-make which has problems with pattern rules and
+             * backslash directory separators.
              */
             S_chaz_MakeFile_write_object_rules(binary->sources, cflags, out);
         }


[2/2] lucy git commit: Try several ports in remote searcher tests

Posted by nw...@apache.org.
Try several ports in remote searcher tests

Fixes LUCY-312.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/0959ad9d
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/0959ad9d
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/0959ad9d

Branch: refs/heads/master
Commit: 0959ad9d3ffa474396059268e431fa43daa9a1c4
Parents: 26d3c77
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Sep 30 17:16:58 2016 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Fri Sep 30 17:32:56 2016 +0200

----------------------------------------------------------------------
 perl/lib/LucyX/Remote/SearchServer.pm |  6 +++++
 perl/t/510-remote_search.t            | 33 ++++++++++++++++-------
 perl/t/550-cluster_searcher.t         | 42 +++++++++++++++++++++---------
 3 files changed, 59 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/0959ad9d/perl/lib/LucyX/Remote/SearchServer.pm
----------------------------------------------------------------------
diff --git a/perl/lib/LucyX/Remote/SearchServer.pm b/perl/lib/LucyX/Remote/SearchServer.pm
index 6950c24..dc3f0aa 100644
--- a/perl/lib/LucyX/Remote/SearchServer.pm
+++ b/perl/lib/LucyX/Remote/SearchServer.pm
@@ -67,6 +67,12 @@ sub serve {
         Reuse     => 1,
     );
     confess("No socket: $!") unless $main_sock;
+    $self->serve_sock($main_sock);
+}
+
+sub serve_sock {
+    my ( $self, $main_sock ) = @_;
+
     my $read_set = IO::Select->new($main_sock);
 
     while ( my @ready = $read_set->can_read ) {

http://git-wip-us.apache.org/repos/asf/lucy/blob/0959ad9d/perl/t/510-remote_search.t
----------------------------------------------------------------------
diff --git a/perl/t/510-remote_search.t b/perl/t/510-remote_search.t
index 574e9ab..a71763d 100644
--- a/perl/t/510-remote_search.t
+++ b/perl/t/510-remote_search.t
@@ -20,7 +20,9 @@ use Test::More;
 use Time::HiRes qw( sleep );
 use IO::Socket::INET;
 
-my $PORT_NUM = 7890;
+my $min_port = 7900;
+my $max_port = 7919;
+
 BEGIN {
     if ( $^O =~ /(mswin|cygwin)/i ) {
         plan( 'skip_all', "fork on Windows not supported by Lucy" );
@@ -50,13 +52,22 @@ use Lucy::Test;
 use LucyX::Remote::SearchServer;
 use LucyX::Remote::SearchClient;
 
-my $kid;
-$kid = fork;
-if ($kid) {
-    sleep .25;    # allow time for the server to set up the socket
-    die "Failed fork: $!" unless defined $kid;
+my ( $port, $sock );
+for ( $port = $min_port; $port <= $max_port; $port++ ) {
+    $sock = IO::Socket::INET->new(
+        LocalPort => $port,
+        Proto     => 'tcp',
+        Listen    => SOMAXCONN,
+        Reuse     => 1,
+    );
+    last if $sock;
 }
-else {
+die "No socket: $!" unless $sock;
+
+my $kid = fork;
+die "Failed fork: $!" unless defined $kid;
+
+if ( $kid == 0 ) {
     my $folder  = Lucy::Store::RAMFolder->new;
     my $indexer = Lucy::Index::Indexer->new(
         index  => $folder,
@@ -73,12 +84,14 @@ else {
     my $server = LucyX::Remote::SearchServer->new(
         searcher => $searcher,
     );
-    $server->serve( port => $PORT_NUM );
+    $server->serve_sock($sock);
     exit(0);
 }
 
+$sock->close;
+
 my $test_client_sock = IO::Socket::INET->new(
-    PeerAddr => "localhost:$PORT_NUM",
+    PeerAddr => "localhost:$port",
     Proto    => 'tcp',
 );
 if ($test_client_sock) {
@@ -91,7 +104,7 @@ else {
 
 my $searchclient = LucyX::Remote::SearchClient->new(
     schema       => SortSchema->new,
-    peer_address => "localhost:$PORT_NUM",
+    peer_address => "localhost:$port",
 );
 
 is( $searchclient->doc_freq( field => 'content', term => 'x' ),

http://git-wip-us.apache.org/repos/asf/lucy/blob/0959ad9d/perl/t/550-cluster_searcher.t
----------------------------------------------------------------------
diff --git a/perl/t/550-cluster_searcher.t b/perl/t/550-cluster_searcher.t
index bc19e0c..a96cbbb 100644
--- a/perl/t/550-cluster_searcher.t
+++ b/perl/t/550-cluster_searcher.t
@@ -20,7 +20,10 @@ use Test::More;
 use Time::HiRes qw( sleep );
 use IO::Socket::INET;
 
-my @ports = 7890 .. 7895;
+my $num_servers = 6;
+my $min_port = 7000;
+my $max_port = 7099;
+
 BEGIN {
     if ( $^O =~ /(mswin|cygwin)/i ) {
         plan( 'skip_all', "fork on Windows not supported by Lucy" );
@@ -55,15 +58,29 @@ use Lucy::Test;
 use LucyX::Remote::SearchServer;
 use LucyX::Remote::ClusterSearcher;
 
+my @ports;
+my $port = $min_port;
 my @kids;
 my $number = 7;
-for my $port (@ports) {
-    my $kid = fork;
-    if ($kid) {
-        die "Failed fork: $!" unless defined $kid;
-        push @kids, $kid;
+for ( my $i = 0; $i < $num_servers; $i++ ) {
+    my $sock;
+    while ( $port <= $max_port ) {
+        $sock = IO::Socket::INET->new(
+            LocalPort => $port,
+            Proto     => 'tcp',
+            Listen    => SOMAXCONN,
+            Reuse     => 1,
+        );
+        last if $sock;
+        $port++;
     }
-    else {
+    die "No socket: $!" unless $sock;
+    push @ports, $port;
+
+    my $kid = fork;
+    die "Failed fork: $!" unless defined $kid;
+
+    if ( $kid == 0 ) {
         my $folder  = Lucy::Store::RAMFolder->new;
         my $indexer = Lucy::Index::Indexer->new(
             index  => $folder,
@@ -85,13 +102,14 @@ for my $port (@ports) {
         my $server = LucyX::Remote::SearchServer->new(
             searcher => $searcher,
         );
-        $server->serve( port => $port );
+        $server->serve_sock($sock);
         exit(0);
     }
-}
 
-# Allow time for the servers to set up their sockets.
-sleep .5;
+    $sock->close;
+    push @kids, $kid;
+    $port++;
+}
 
 my $test_client_sock = IO::Socket::INET->new(
     PeerAddr => "localhost:$ports[0]",
@@ -130,7 +148,7 @@ my $cluster_searcher = LucyX::Remote::ClusterSearcher->new(
 );
 
 $hits = $cluster_searcher->hits( query => 'b' );
-is( $hits->total_hits, scalar @ports, "matched hits across multiple shards" );
+is( $hits->total_hits, $num_servers, "matched hits across multiple shards" );
 
 my $highlighter = Lucy::Highlight::Highlighter->new(
     searcher => $cluster_searcher,