user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 0/4] some minor test updates
@ 2019-11-14  6:41 Eric Wong
  2019-11-14  6:41 ` [PATCH 1/4] t/common: inline stream_to_string into t/feed.t Eric Wong
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Eric Wong @ 2019-11-14  6:41 UTC (permalink / raw)
  To: meta

A few minor, low impact improvements to avoid loading
and running redundant code while I'm ironing out some
major test improvements.

Eric Wong (4):
  t/common: inline stream_to_string into t/feed.t
  t/common: move unix_server to t/httpd-corner.t
  t/psgi_mount: require SearchIdx before using
  doc: check-man: save the result of successful runs

 .gitignore               |  1 +
 Documentation/include.mk | 13 +++++++------
 t/common.perl            | 21 ---------------------
 t/feed.t                 |  9 ++++++++-
 t/httpd-corner.t         | 10 ++++++++++
 t/psgi_mount.t           |  3 ++-
 6 files changed, 28 insertions(+), 29 deletions(-)


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

* [PATCH 1/4] t/common: inline stream_to_string into t/feed.t
  2019-11-14  6:41 [PATCH 0/4] some minor test updates Eric Wong
@ 2019-11-14  6:41 ` Eric Wong
  2019-11-14  6:41 ` [PATCH 2/4] t/common: move unix_server to t/httpd-corner.t Eric Wong
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2019-11-14  6:41 UTC (permalink / raw)
  To: meta

We only use it in one place and have favored test_psgi
in newer tests, so move it out-of-the-way to reduce startup
overhead of other *.t files.
---
 t/common.perl | 11 -----------
 t/feed.t      |  9 ++++++++-
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/t/common.perl b/t/common.perl
index ccc7be46..053a935a 100644
--- a/t/common.perl
+++ b/t/common.perl
@@ -7,17 +7,6 @@ use strict;
 use warnings;
 use IO::Socket::INET;
 
-sub stream_to_string {
-	my ($res) = @_;
-	my $body = $res->[2];
-	my $str = '';
-	while (defined(my $chunk = $body->getline)) {
-		$str .= $chunk;
-	}
-	$body->close;
-	$str;
-}
-
 sub tcp_server () {
 	IO::Socket::INET->new(
 		LocalAddr => '127.0.0.1',
diff --git a/t/feed.t b/t/feed.t
index eb1f35fb..93da3717 100644
--- a/t/feed.t
+++ b/t/feed.t
@@ -14,7 +14,14 @@ my $have_xml_feed = eval { require XML::Feed; 1 };
 require './t/common.perl';
 
 sub string_feed {
-	stream_to_string(PublicInbox::Feed::generate($_[0]));
+	my $res = PublicInbox::Feed::generate($_[0]);
+	my $body = $res->[2];
+	my $str = '';
+	while (defined(my $chunk = $body->getline)) {
+		$str .= $chunk;
+	}
+	$body->close;
+	$str;
 }
 
 my $tmpdir = tempdir('pi-feed-XXXXXX', TMPDIR => 1, CLEANUP => 1);

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

* [PATCH 2/4] t/common: move unix_server to t/httpd-corner.t
  2019-11-14  6:41 [PATCH 0/4] some minor test updates Eric Wong
  2019-11-14  6:41 ` [PATCH 1/4] t/common: inline stream_to_string into t/feed.t Eric Wong
@ 2019-11-14  6:41 ` Eric Wong
  2019-11-14  6:41 ` [PATCH 3/4] t/psgi_mount: require SearchIdx before using Eric Wong
  2019-11-14  6:41 ` [PATCH 4/4] doc: check-man: save the result of successful runs Eric Wong
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2019-11-14  6:41 UTC (permalink / raw)
  To: meta

unix_server() is not commonly used, only t/httpd-corner.t uses
it and most HTTP tests use TCP since most HTTP libraries only
support TCP.
---
 t/common.perl    | 10 ----------
 t/httpd-corner.t | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/t/common.perl b/t/common.perl
index 053a935a..d4a0fcd2 100644
--- a/t/common.perl
+++ b/t/common.perl
@@ -18,16 +18,6 @@ sub tcp_server () {
 	)
 }
 
-sub unix_server ($) {
-	my $s = IO::Socket::UNIX->new(
-		Listen => 1024,
-		Type => Socket::SOCK_STREAM(),
-		Local => $_[0],
-	);
-	$s->blocking(0);
-	$s;
-}
-
 sub tcp_connect {
 	my ($dest, %opt) = @_;
 	my $s = IO::Socket::INET->new(
diff --git a/t/httpd-corner.t b/t/httpd-corner.t
index 75573c3e..b063d9fa 100644
--- a/t/httpd-corner.t
+++ b/t/httpd-corner.t
@@ -51,6 +51,16 @@ if ($^O eq 'linux') {
 	setsockopt($sock, SOL_SOCKET, $var, $accf_arg) or die "setsockopt: $!";
 }
 
+sub unix_server ($) {
+	my $s = IO::Socket::UNIX->new(
+		Listen => 1024,
+		Type => Socket::SOCK_STREAM(),
+		Local => $_[0],
+	);
+	$s->blocking(0);
+	$s;
+}
+
 my $upath = "$tmpdir/s";
 my $unix = unix_server($upath);
 ok($unix, 'UNIX socket created');

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

* [PATCH 3/4] t/psgi_mount: require SearchIdx before using
  2019-11-14  6:41 [PATCH 0/4] some minor test updates Eric Wong
  2019-11-14  6:41 ` [PATCH 1/4] t/common: inline stream_to_string into t/feed.t Eric Wong
  2019-11-14  6:41 ` [PATCH 2/4] t/common: move unix_server to t/httpd-corner.t Eric Wong
@ 2019-11-14  6:41 ` Eric Wong
  2019-11-14  6:41 ` [PATCH 4/4] doc: check-man: save the result of successful runs Eric Wong
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2019-11-14  6:41 UTC (permalink / raw)
  To: meta

We may not implicitly load it via other means in the future.
---
 t/psgi_mount.t | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/t/psgi_mount.t b/t/psgi_mount.t
index aa7c863f..7de2bc0e 100644
--- a/t/psgi_mount.t
+++ b/t/psgi_mount.t
@@ -90,9 +90,10 @@ test_psgi($app, sub {
 SKIP: {
 	my @mods = qw(DBI DBD::SQLite Search::Xapian IO::Uncompress::Gunzip);
 	foreach my $mod (@mods) {
-		eval "require $mod" or skip "$mod not available: $@", 2;
+		eval "require $mod" or skip "$mod not available: $@", 3;
 	}
 	my $ibx = $config->lookup_name('test');
+	require_ok 'PublicInbox::SearchIdx';
 	PublicInbox::SearchIdx->new($ibx, 1)->index_sync;
 	test_psgi($app, sub {
 		my ($cb) = @_;

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

* [PATCH 4/4] doc: check-man: save the result of successful runs
  2019-11-14  6:41 [PATCH 0/4] some minor test updates Eric Wong
                   ` (2 preceding siblings ...)
  2019-11-14  6:41 ` [PATCH 3/4] t/psgi_mount: require SearchIdx before using Eric Wong
@ 2019-11-14  6:41 ` Eric Wong
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2019-11-14  6:41 UTC (permalink / raw)
  To: meta

We can keep a stamp around if the corresponding manpage hasn't
changed to avoid re-running man(1) and awk(1).
---
 .gitignore               |  1 +
 Documentation/include.mk | 13 +++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index 66f165e2..167d08bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@
 *.8
 *.html
 *.gz
+.*.cols
 /NEWS.html
 /NEWS.atom
 /NEWS
diff --git a/Documentation/include.mk b/Documentation/include.mk
index ea0498c1..651fdf30 100644
--- a/Documentation/include.mk
+++ b/Documentation/include.mk
@@ -93,14 +93,15 @@ doc_install :: install-man
 
 check :: check-man
 check_man = @echo CHECK80 $<;COLUMNS=80 $(MAN) ./$^ | \
-	$(AWK) '{gsub(/\b./,"")}length>80{print;err=1}END{exit(err)}' >&2
+	$(AWK) '{gsub(/\b./,"")}length>80{print;err=1}END{exit(err)}' >&2 \
+	&& >$@
 
-%.1.cols : %.1; $(check_man)
-%.5.cols : %.5; $(check_man)
-%.7.cols : %.7; $(check_man)
-%.8.cols : %.8; $(check_man)
+.%.1.cols : %.1; $(check_man)
+.%.5.cols : %.5; $(check_man)
+.%.7.cols : %.7; $(check_man)
+.%.8.cols : %.8; $(check_man)
 
-check-man :: $(addsuffix .cols, $(manpages))
+check-man :: $(addprefix .,$(addsuffix .cols, $(manpages)))
 
 manuals :=
 manuals += $(m1)

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

end of thread, other threads:[~2019-11-14  6:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-14  6:41 [PATCH 0/4] some minor test updates Eric Wong
2019-11-14  6:41 ` [PATCH 1/4] t/common: inline stream_to_string into t/feed.t Eric Wong
2019-11-14  6:41 ` [PATCH 2/4] t/common: move unix_server to t/httpd-corner.t Eric Wong
2019-11-14  6:41 ` [PATCH 3/4] t/psgi_mount: require SearchIdx before using Eric Wong
2019-11-14  6:41 ` [PATCH 4/4] doc: check-man: save the result of successful runs Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).