about summary refs log tree commit homepage
path: root/lib/PublicInbox/TestCommon.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-02-18 23:22:22 +0300
committerEric Wong <e@80x24.org>2021-02-18 20:02:17 -0400
commit63283ae1b51203c930332e6887296cb123e5db6c (patch)
tree47a269e817e4b674ee41c50c1085df9850137c59 /lib/PublicInbox/TestCommon.pm
parenta2415fec470dad7d9848b55af7c156f96dde13e5 (diff)
downloadpublic-inbox-63283ae1b51203c930332e6887296cb123e5db6c.tar.gz
This will make testing IMAP support for other commands easier, as
it doesn't write to lei/store at all.  Like the pager and MUA,
"git credential" is always spawned by script/lei (and not
lei-daemon) so it has a controlling terminal for password
prompts.

v2: fix missing requires, correct test ordering
v3: ensure config exists for IMAP auth
Diffstat (limited to 'lib/PublicInbox/TestCommon.pm')
-rw-r--r--lib/PublicInbox/TestCommon.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index c5070cfd..3eb08e9f 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -462,10 +462,15 @@ our $lei = sub {
 sub lei (@) { $lei->(@_) }
 
 sub lei_ok (@) {
-        my $msg = ref($_[-1]) ? pop(@_) : undef;
+        my $msg = ref($_[-1]) eq 'SCALAR' ? pop(@_) : undef;
+        my $tmpdir = quotemeta(File::Spec->tmpdir);
         # filter out anything that looks like a path name for consistent logs
-        my @msg = grep(!m!\A/!, @_);
-        ok($lei->(@_), "lei @msg". ($msg ? " ($$msg)" : ''));
+        my @msg = ref($_[0]) eq 'ARRAY' ? @{$_[0]} : @_;
+        for (@msg) {
+                s!\A([a-z0-9]+://)[^/]+/!$1\$HOST_PORT/! ||
+                        s!$tmpdir\b/(?:[^/]+/)?!\$TMPDIR/!;
+        }
+        ok(lei(@_), "lei @msg". ($msg ? " ($$msg)" : '')) or diag $lei_err;
 }
 
 sub json_utf8 () {