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 0/3] lei import fix, other fixes
@ 2021-03-21  9:50  7% Eric Wong
  2021-03-21  9:50  6% ` [PATCH 3/3] lei: fix some warnings in tests Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-03-21  9:50 UTC (permalink / raw)
  To: meta

Things are finally coming together...

Eric Wong (3):
  lei import: vivify external-only messages
  lei q: fix warning on remote imports
  lei: fix some warnings in tests

 lib/PublicInbox/ContentHash.pm | 15 ++++++++---
 lib/PublicInbox/Import.pm      | 14 ++++++++++-
 lib/PublicInbox/LEI.pm         |  8 +++---
 lib/PublicInbox/LeiDedupe.pm   |  9 ++-----
 lib/PublicInbox/LeiExternal.pm |  2 +-
 lib/PublicInbox/LeiImport.pm   | 22 ++++++++++------
 lib/PublicInbox/LeiP2q.pm      |  2 +-
 lib/PublicInbox/LeiSearch.pm   |  5 +++-
 lib/PublicInbox/LeiStore.pm    | 46 +++++++++++++++++++++++++++++-----
 lib/PublicInbox/LeiXSearch.pm  |  6 ++++-
 lib/PublicInbox/MboxLock.pm    |  8 +++---
 lib/PublicInbox/Over.pm        |  2 +-
 lib/PublicInbox/SearchIdx.pm   | 12 +++++++--
 lib/PublicInbox/TestCommon.pm  |  9 +++++++
 t/lei-q-kw.t                   | 44 ++++++++++++++++++++++++++++++++
 t/lei-q-remote-import.t        |  3 ++-
 16 files changed, 167 insertions(+), 40 deletions(-)

^ permalink raw reply	[relevance 7%]

* [PATCH 3/3] lei: fix some warnings in tests
  2021-03-21  9:50  7% [PATCH 0/3] lei import fix, other fixes Eric Wong
@ 2021-03-21  9:50  6% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-03-21  9:50 UTC (permalink / raw)
  To: meta

And then test the contents of $lei_err to ensure it doesn't
happen again.

We'll also make MboxLock emit nicer warnings without the line
number, since the line number is irrelevant to the user fixing
an mbox lock contention problem.

Finally, we'll also allow showing loud warnings via
TEST_LEI_ERR_LOUD=1
---
 lib/PublicInbox/LEI.pm         | 8 ++++----
 lib/PublicInbox/LeiExternal.pm | 2 +-
 lib/PublicInbox/LeiP2q.pm      | 2 +-
 lib/PublicInbox/MboxLock.pm    | 8 ++++----
 lib/PublicInbox/TestCommon.pm  | 9 +++++++++
 5 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 72a0e52c..bf97a680 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -757,7 +757,7 @@ sub lei__complete {
 	my ($proto, undef, @spec) = @$info;
 	my $cur = pop @argv;
 	my $re = defined($cur) ? qr/\A\Q$cur\E/ : qr/./;
-	if (substr($cur // '-', 0, 1) eq '-') { # --switches
+	if (substr(my $_cur = $cur // '-', 0, 1) eq '-') { # --switches
 		# gross special case since the only git-config options
 		# Consider moving to a table if we need more special cases
 		# we use Getopt::Long for are the ones we reject, so these
@@ -781,7 +781,7 @@ sub lei__complete {
 			}
 			map {
 				my $x = length > 1 ? "--$_" : "-$_";
-				$x eq $cur ? () : $x;
+				$x eq $_cur ? () : $x;
 			} grep(!/_/, split(/\|/, $_, -1)) # help|h
 		} grep { $OPTDESC{"$_\t$cmd"} || $OPTDESC{$_} } @spec);
 	} elsif ($cmd eq 'config' && !@argv && !$CONFIG_KEYS{$cur}) {
@@ -796,13 +796,13 @@ sub lei__complete {
 			my @v = ref($v) ? split(/\|/, $v->[0]) : ();
 			# get rid of ALL CAPS placeholder (e.g "OUT")
 			# (TODO: completion for external paths)
-			shift(@v) if uc($v[0]) eq $v[0];
+			shift(@v) if scalar(@v) && uc($v[0]) eq $v[0];
 			@v;
 		} grep(/\A(?:[\w-]+\|)*$opt\b.*?(?:\t$cmd)?\z/, keys %OPTDESC);
 	}
 	$cmd =~ tr/-/_/;
 	if (my $sub = $self->can("_complete_$cmd")) {
-		puts $self, $sub->($self, @argv, $cur);
+		puts $self, $sub->($self, @argv, $cur ? ($cur) : ());
 	}
 	# TODO: URLs, pathnames, OIDs, MIDs, etc...  See optparse() for
 	# proto parsing.
diff --git a/lib/PublicInbox/LeiExternal.pm b/lib/PublicInbox/LeiExternal.pm
index b5dd85e1..f4e24c2a 100644
--- a/lib/PublicInbox/LeiExternal.pm
+++ b/lib/PublicInbox/LeiExternal.pm
@@ -222,7 +222,7 @@ sub _complete_url_common ($) {
 	# Maybe there's a better way to go about this in
 	# contrib/completion/lei-completion.bash
 	my $re = '';
-	my $cur = pop @$argv;
+	my $cur = pop(@$argv) // '';
 	if (@$argv) {
 		my @x = @$argv;
 		if ($cur eq ':' && @x) {
diff --git a/lib/PublicInbox/LeiP2q.pm b/lib/PublicInbox/LeiP2q.pm
index e7ddc852..c5718603 100644
--- a/lib/PublicInbox/LeiP2q.pm
+++ b/lib/PublicInbox/LeiP2q.pm
@@ -144,7 +144,7 @@ sub do_p2q { # via wq_do
 			my $end = ($pfx =~ s/([0-9\*]+)\z//) ? $1 : '';
 			my $x = delete($lei->{qterms}->{$pfx}) or next;
 			my $star = $end =~ tr/*//d ? '*' : '';
-			my $min_len = ($end // 0) + 0;
+			my $min_len = ($end || 0) + 0;
 
 			# no wildcards for bool_pfx_external
 			$star = '' if $pfx =~ /\A(dfpre|dfpost|mid)\z/;
diff --git a/lib/PublicInbox/MboxLock.pm b/lib/PublicInbox/MboxLock.pm
index 4e2a2d9a..bea0e325 100644
--- a/lib/PublicInbox/MboxLock.pm
+++ b/lib/PublicInbox/MboxLock.pm
@@ -43,13 +43,13 @@ EOF
 		}
 		select(undef, undef, undef, $self->{delay});
 	} while (now < $end);
-	croak "fcntl lock $self->{f}: $!";
+	die "fcntl lock timeout $self->{f}: $!\n";
 }
 
 sub acq_dotlock {
 	my ($self) = @_;
 	my $dot_lock = "$self->{f}.lock";
-	my ($pfx, $base) = ($self->{f} =~ m!(\A.*?/)([^/]+)\z!);
+	my ($pfx, $base) = ($self->{f} =~ m!(\A.*?/)?([^/]+)\z!);
 	$pfx //= '';
 	my $pid = $$;
 	my $end = now + $self->{timeout};
@@ -68,7 +68,7 @@ sub acq_dotlock {
 			croak "open $tmp (for $dot_lock): $!" if !$!{EXIST};
 		}
 	} while (now < $end);
-	croak "dotlock $dot_lock";
+	die "dotlock timeout $dot_lock\n";
 }
 
 sub acq_flock {
@@ -80,7 +80,7 @@ sub acq_flock {
 		return if flock($self->{fh}, $op);
 		select(undef, undef, undef, $self->{delay});
 	} while (now < $end);
-	croak "flock $self->{f}: $!";
+	die "flock timeout $self->{f}: $!\n";
 }
 
 sub acq {
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 0d15514e..e67e94ea 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -457,6 +457,15 @@ sub lei (@) {
 	my $res = run_script(['lei', @$cmd], $env, $xopt // $lei_opt);
 	$err_skip and
 		$lei_err = join('', grep(!/$err_skip/, split(/^/m, $lei_err)));
+	if ($lei_err ne '') {
+		if ($lei_err =~ /Use of uninitialized/ ||
+			$lei_err =~ m!\bArgument .*? isn't numeric in !) {
+			fail "lei_err=$lei_err";
+		} else {
+			state $loud = $ENV{TEST_LEI_ERR_LOUD};
+			diag "lei_err=$lei_err" if $loud;
+		}
+	}
 	$res;
 };
 

^ permalink raw reply related	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-03-21  9:50  7% [PATCH 0/3] lei import fix, other fixes Eric Wong
2021-03-21  9:50  6% ` [PATCH 3/3] lei: fix some warnings in tests 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).