unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] t/nntpd: avoid fork+exec for search indexing
@ 2016-05-14  1:26 Eric Wong
  2016-05-14  1:47 ` [PATCH] t/nntpd: test for wide characters and UTF-8 mangling Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2016-05-14  1:26 UTC (permalink / raw)
  To: meta

The Xapian search index is required for the NNTP server, so
there's no point in calling system() for it like we do in
other tests.  This should speed up the test a small amount.
---
 t/nntpd.t | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/nntpd.t b/t/nntpd.t
index a389a3e..a9df36d 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -27,7 +27,6 @@ my $addr = $group . '@example.com';
 my $cfgpfx = "publicinbox.$group";
 my $nntpd = 'blib/script/public-inbox-nntpd';
 my $init = 'blib/script/public-inbox-init';
-my $index = 'blib/script/public-inbox-index';
 use_ok 'PublicInbox::Import';
 use_ok 'PublicInbox::Git';
 
@@ -65,7 +64,8 @@ EOF
 		my $im = PublicInbox::Import->new($git, 'test', $addr);
 		$im->add($mime);
 		$im->done;
-		is(0, system($index, $maindir), 'indexed git dir');
+		my $s = PublicInbox::SearchIdx->new($maindir, 1);
+		$s->index_sync;
 	}
 
 	ok($sock, 'sock created');

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] t/nntpd: test for wide characters and UTF-8 mangling
  2016-05-14  1:26 [PATCH] t/nntpd: avoid fork+exec for search indexing Eric Wong
@ 2016-05-14  1:47 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2016-05-14  1:47 UTC (permalink / raw)
  To: meta

We'll need to test non-UTF-8 messages at some point, too.
There are lots of legacy-encoded messages in old archives
and I would not bet we behave sanely w.r.t. those.
---
 t/nntpd.t | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/t/nntpd.t b/t/nntpd.t
index a9df36d..60cf893 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -49,14 +49,16 @@ END { kill 'TERM', $pid if defined $pid };
 	# ensure successful message delivery
 	{
 		my $mime = Email::MIME->new(<<EOF);
-From: Me <me\@example.com>
-To: You <you\@example.com>
+To: =?utf-8?Q?El=C3=A9anor?= <you\@example.com>
+From: =?utf-8?Q?El=C3=A9anor?= <me\@example.com>
 Cc: $addr
 Message-Id: <nntp\@example.com>
-Subject: hihi
+Content-Type: text/plain; charset=utf-8
+Subject: Testing for =?utf-8?Q?El=C3=A9anor?=
 Date: Thu, 01 Jan 1970 06:06:06 +0000
+Content-Transfer-Encoding: 8bit
 
-nntp
+This is a test message for El\xc3\xa9anor
 EOF
 		$mime->header_set('List-Id', "<$addr>");
 		$len = length($mime->as_string);
@@ -103,10 +105,10 @@ EOF
 	my $mid = '<nntp@example.com>';
 	my %xhdr = (
 		'message-id' => $mid,
-		'subject' => 'hihi',
+		subject => "Testing for El\xc3\xa9anor",
 		'date' => 'Thu, 01 Jan 1970 06:06:06 +0000',
-		'from' => 'Me <me@example.com>',
-		'to' => 'You <you@example.com>',
+		'from' => "El\xc3\xa9anor <me\@example.com>",
+		'to' => "El\xc3\xa9anor <you\@example.com>",
 		'cc' => $addr,
 		'xref' => "example.com $group:1"
 	);
@@ -123,14 +125,13 @@ EOF
 			  "$k by article number works");
 		is_deeply($n->xhdr("$k 1-"), { 1 => $v },
 			  "$k by article range works");
-		next;
 		$buf = '';
 		syswrite($s, "HDR $k $mid\r\n");
 		do {
 			sysread($s, $buf, 4096, length($buf));
 		} until ($buf =~ /\r\n\.\r\n\z/);
 		my @r = split("\r\n", $buf);
-		like($r[0], qr/\A224 /, '224 response for HDR');
+		like($r[0], qr/\A225 /, '225 response for HDR');
 		is($r[1], "0 $v", 'got expected response for HDR');
 	}
 
@@ -143,8 +144,8 @@ EOF
 	}
 
 	is_deeply($n->xover('1-'), {
-		'1' => ['hihi',
-			'Me <me@example.com>',
+		'1' => ["Testing for El\xc3\xa9anor",
+			"El\xc3\xa9anor <me\@example.com>",
 			'Thu, 01 Jan 1970 06:06:06 +0000',
 			'<nntp@example.com>',
 			'',
@@ -152,8 +153,8 @@ EOF
 			'1' ] }, "XOVER range works");
 
 	is_deeply($n->xover('1'), {
-		'1' => ['hihi',
-			'Me <me@example.com>',
+		'1' => ["Testing for El\xc3\xa9anor",
+			"El\xc3\xa9anor <me\@example.com>",
 			'Thu, 01 Jan 1970 06:06:06 +0000',
 			'<nntp@example.com>',
 			'',
@@ -168,7 +169,8 @@ EOF
 		} until ($buf =~ /\r\n\.\r\n\z/);
 		my @r = split("\r\n", $buf);
 		like($r[0], qr/^224 /, 'got 224 response for OVER');
-		is($r[1], "0\thihi\tMe <me\@example.com>\t" .
+		is($r[1], "0\tTesting for El\xc3\xa9anor\t" .
+			"El\xc3\xa9anor <me\@example.com>\t" .
 			"Thu, 01 Jan 1970 06:06:06 +0000\t" .
 			"$mid\t\t$len\t1", 'OVER by Message-ID works');
 		is($r[2], '.', 'correctly terminated response');
@@ -199,7 +201,13 @@ EOF
 	}
 
 	is($pid, waitpid($pid, 0), 'nntpd exited successfully');
+	my $eout = eval {
+		local $/;
+		open my $fh, '<', $err or die "open $err failed: $!";
+		<$fh>;
+	};
 	is($?, 0, 'no error in exited process');
+	unlike($eout, qr/wide/i, 'no Wide character warnings');
 }
 
 done_testing();

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-14  1:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-14  1:26 [PATCH] t/nntpd: avoid fork+exec for search indexing Eric Wong
2016-05-14  1:47 ` [PATCH] t/nntpd: test for wide characters and UTF-8 mangling Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).