diff options
author | Eric Wong <e@80x24.org> | 2019-12-22 22:17:37 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-12-24 03:47:01 +0000 |
commit | a09f678d8254064af7ca6dcfb3c3f84b5ae37b51 (patch) | |
tree | c32233ae88dbaa3b914812a80f539054d7f086da /lib/PublicInbox | |
parent | f1259e56d75b8f06a40fb466bee51a399cc317c5 (diff) | |
download | public-inbox-a09f678d8254064af7ca6dcfb3c3f84b5ae37b51.tar.gz |
This cuts down on lines of code in individual test cases and fixes some misnamed error messages by using "$0" consistently. This will also provide us with a method of swapping out dependencies which provide equivalent functionality (e.g "Xapian" SWIG can replace "Search::Xapian" XS bindings).
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/TestCommon.pm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index 372cafa6..9680b94c 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -8,7 +8,7 @@ use parent qw(Exporter); use Fcntl qw(FD_CLOEXEC F_SETFD F_GETFD :seek); use POSIX qw(dup2); use IO::Socket::INET; -our @EXPORT = qw(tmpdir tcp_server tcp_connect require_git +our @EXPORT = qw(tmpdir tcp_server tcp_connect require_git require_mods run_script start_script key2sub); sub tmpdir (;$) { @@ -59,6 +59,20 @@ sub require_git ($;$) { 1; } +sub require_mods { + my @mods = @_; + my $maybe = pop @mods if $mods[-1] =~ /\A[0-9]+\z/; + my @need; + for my $mod (@mods) { + eval "require $mod"; + push @need, $mod if $@; + } + return unless @need; + my $m = join(', ', @need)." missing for $0"; + Test::More::skip($m, $maybe) if $maybe; + Test::More::plan(skip_all => $m) +} + sub key2script ($) { my ($key) = @_; return $key if (index($key, '/') >= 0); |