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 1/5] t/*.t: remove IPC::Run dependency for git commands
  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

One small step towards making tests easier-to-run.  We can rely
on "local $ENV{GIT_DIR}" for potentially shell-unsafe path
names, and the rest of our path names are relative and don't
contain characters which require escaping.
---
 t/git.t         | 12 ++++++------
 t/www_listing.t | 11 ++++++-----
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/t/git.t b/t/git.t
index 445ef248..a496f851 100644
--- a/t/git.t
+++ b/t/git.t
@@ -7,16 +7,14 @@ use File::Temp qw/tempdir/;
 my $dir = tempdir('pi-git-XXXXXX', TMPDIR => 1, CLEANUP => 1);
 use PublicInbox::Spawn qw(popen_rd);
 
-eval { require IPC::Run } or plan skip_all => 'IPC::Run missing';
 use_ok 'PublicInbox::Git';
 
 {
 	is(system(qw(git init -q --bare), $dir), 0, 'created git directory');
-	my $cmd = [ 'git', "--git-dir=$dir", 'fast-import', '--quiet' ];
-
 	my $fi_data = './t/git.fast-import-data';
 	ok(-r $fi_data, "fast-import data readable (or run test at top level)");
-	IPC::Run::run($cmd, '<', $fi_data);
+	local $ENV{GIT_DIR} = $dir;
+	system("git fast-import --quiet <$fi_data");
 	is($?, 0, 'fast-import succeeded');
 }
 
@@ -46,8 +44,10 @@ if (1) {
 	my $size = -s $big_data;
 	ok($size > 8192, 'file is big enough');
 
-	my $buf = '';
-	IPC::Run::run($cmd, '<', $big_data, '>', \$buf);
+	my $buf = do {
+		local $ENV{GIT_DIR} = $dir;
+		`git hash-object -w --stdin <$big_data`;
+	};
 	is(0, $?, 'hashed object successfully');
 	chomp $buf;
 
diff --git a/t/www_listing.t b/t/www_listing.t
index 9f71257d..3d1b64ad 100644
--- a/t/www_listing.t
+++ b/t/www_listing.t
@@ -7,7 +7,7 @@ use Test::More;
 use PublicInbox::Spawn qw(which);
 use File::Temp qw/tempdir/;
 require './t/common.perl';
-my @mods = qw(URI::Escape Plack::Builder IPC::Run Digest::SHA
+my @mods = qw(URI::Escape Plack::Builder Digest::SHA
 		IO::Compress::Gzip IO::Uncompress::Gunzip HTTP::Tiny);
 foreach my $mod (@mods) {
 	eval("require $mod") or plan skip_all => "$mod missing for $0";
@@ -19,15 +19,16 @@ plan skip_all => "JSON module missing: $@" if $@;
 
 use_ok 'PublicInbox::Git';
 
-my $fi_data = './t/git.fast-import-data';
 my $tmpdir = tempdir('www_listing-tmp-XXXXXX', TMPDIR => 1, CLEANUP => 1);
 my $bare = PublicInbox::Git->new("$tmpdir/bare.git");
 is(system(qw(git init -q --bare), $bare->{git_dir}), 0, 'git init --bare');
 is(PublicInbox::WwwListing::fingerprint($bare), undef,
 	'empty repo has no fingerprint');
-
-my $cmd = [ 'git', "--git-dir=$bare->{git_dir}", qw(fast-import --quiet) ];
-ok(IPC::Run::run($cmd, '<', $fi_data), 'fast-import');
+{
+	my $fi_data = './t/git.fast-import-data';
+	local $ENV{GIT_DIR} = $bare->{git_dir};
+	is(system("git fast-import --quiet <$fi_data"), 0, 'fast-import');
+}
 
 like(PublicInbox::WwwListing::fingerprint($bare), qr/\A[a-f0-9]{40}\z/,
 	'got fingerprint with non-empty repo');

^ 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 1/5] t/*.t: remove IPC::Run dependency for git commands 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 1/5] t/*.t: remove IPC::Run dependency for git commands 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).