user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 3/5] t/httpd-corner.t: get rid of IPC::Run for running curl
  2019-11-04  3:01  6% [PATCH 0/5] tiny test overhead reductions Eric Wong
@ 2019-11-04  3:01  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2019-11-04  3:01 UTC (permalink / raw)
  To: meta

We already load PublicInbox::Spawn, so there's no need to
add another dependency to make life difficult for potential
contributors.
---
 t/httpd-corner.t | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/t/httpd-corner.t b/t/httpd-corner.t
index 50aa28e3..13c0c2db 100644
--- a/t/httpd-corner.t
+++ b/t/httpd-corner.t
@@ -6,10 +6,9 @@ use strict;
 use warnings;
 use Test::More;
 use Time::HiRes qw(gettimeofday tv_interval);
-use PublicInbox::Spawn qw(which);
+use PublicInbox::Spawn qw(which spawn);
 
-foreach my $mod (qw(Plack::Util Plack::Builder
-			HTTP::Date HTTP::Status IPC::Run)) {
+foreach my $mod (qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status)) {
 	eval "require $mod";
 	plan skip_all => "$mod missing for httpd-corner.t" if $@;
 }
@@ -250,19 +249,21 @@ SKIP: {
 	my ($r, $w);
 	pipe($r, $w) or die "pipe: $!";
 	my $cmd = [qw(curl --tcp-nodelay --no-buffer -T- -HExpect: -sS), $url];
-	my ($out, $err) = ('', '');
-	my $h = IPC::Run::start($cmd, $r, \$out, \$err);
-	$w->autoflush(1);
+	open my $cout, '+>', undef or die;
+	open my $cerr, '>', undef or die;
+	my $rdr = { 0 => fileno($r), 1 => fileno($cout), 2 => fileno($cerr) };
+	my $pid = spawn($cmd, undef, $rdr);
+	close $r or die "close read pipe: $!";
 	foreach my $c ('a'..'z') {
 		print $w $c or die "failed to write to curl: $!";
 		delay();
 	}
 	close $w or die "close write pipe: $!";
-	close $r or die "close read pipe: $!";
-	IPC::Run::finish($h);
+	waitpid($pid, 0);
 	is($?, 0, 'curl exited successfully');
-	is($err, '', 'no errors from curl');
-	is($out, sha1_hex($str), 'read expected body');
+	is(-s $cerr, 0, 'no errors from curl');
+	$cout->seek(0, SEEK_SET);
+	is(<$cout>, sha1_hex($str), 'read expected body');
 
 	open my $fh, '-|', qw(curl -sS), "$base/async-big" or die $!;
 	my $n = 0;

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/5] tiny test overhead reductions
@ 2019-11-04  3:01  6% Eric Wong
  2019-11-04  3:01  7% ` [PATCH 3/5] t/httpd-corner.t: get rid of IPC::Run for running curl Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2019-11-04  3:01 UTC (permalink / raw)
  To: meta

Getting rid of IPC::Run for running 3rd party programs is a tiny
stope towards improving ease-of-testing for new contributors.

Next step might be be enabling mod_perl-like functionality for
our own short-lived scripts to speed up startup time...

Finally, we can eliminate daemon worker processes from most
tests (and explicitly test it in one place) since we don't
need to repeat ourselves.

Eric Wong (5):
  t/*.t: remove IPC::Run dependency for git commands
  t/httpd-corner.t: drop unnecessary bytes:: for length()
  t/httpd-corner.t: get rid of IPC::Run for running curl
  t/hl_mod.t: remove IPC::Run (and File::Temp) dependency
  t/*.t: disable nntpd/httpd worker processes in most tests

 t/git.t             | 12 ++++++------
 t/hl_mod.t          | 24 ++++++++++++++++--------
 t/httpd-corner.psgi |  3 +++
 t/httpd-corner.t    | 44 +++++++++++++++++++++++++++++---------------
 t/httpd.t           |  2 +-
 t/v2mirror.t        |  3 ++-
 t/v2writable.t      |  2 +-
 t/www_listing.t     | 13 +++++++------
 8 files changed, 65 insertions(+), 38 deletions(-)


^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2019-11-04  3:01  6% [PATCH 0/5] tiny test overhead reductions Eric Wong
2019-11-04  3:01  7% ` [PATCH 3/5] t/httpd-corner.t: get rid of IPC::Run for running curl 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).