unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] t/lei*: drop $lei->(...) sub
@ 2021-02-21 19:59 Eric Wong
  2021-02-21 20:42 ` [SQUASH 2/1] t/lei-externals: squash fix Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2021-02-21 19:59 UTC (permalink / raw)
  To: meta

lei() and lei_ok() are superior since they offer prototype
checks and lei_ok() adds another check + description DRY-ness.

The $lei sub was only bound to a variable since it was in
t/lei.t and named subs don't work well with the key2sub()
wrapper.
---
 lib/PublicInbox/TestCommon.pm | 13 +++++----
 t/lei-daemon.t                | 14 +++++-----
 t/lei-externals.t             | 51 +++++++++++++++++------------------
 t/lei-import-maildir.t        |  8 +++---
 t/lei-import.t                | 26 +++++++++---------
 t/lei-mirror.t                | 16 +++++------
 t/lei.t                       | 50 +++++++++++++++++-----------------
 7 files changed, 88 insertions(+), 90 deletions(-)

diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 3eb08e9f..ca05fa21 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -16,7 +16,7 @@ BEGIN {
 		run_script start_script key2sub xsys xsys_e xqx eml_load tick
 		have_xapian_compact json_utf8 setup_public_inboxes
 		tcp_host_port test_lei lei lei_ok
-		$lei $lei_out $lei_err $lei_opt);
+		$lei_out $lei_err $lei_opt);
 	require Test::More;
 	my @methods = grep(!/\W/, @Test::More::EXPORT);
 	eval(join('', map { "*$_=\\&Test::More::$_;" } @methods));
@@ -446,7 +446,8 @@ sub have_xapian_compact () {
 }
 
 our ($err_skip, $lei_opt, $lei_out, $lei_err);
-our $lei = sub {
+# favor lei() or lei_ok() over $lei for new code
+sub lei (@) {
 	my ($cmd, $env, $xopt) = @_;
 	$lei_out = $lei_err = '';
 	if (!ref($cmd)) {
@@ -459,8 +460,6 @@ our $lei = sub {
 	$res;
 };
 
-sub lei (@) { $lei->(@_) }
-
 sub lei_ok (@) {
 	my $msg = ref($_[-1]) eq 'SCALAR' ? pop(@_) : undef;
 	my $tmpdir = quotemeta(File::Spec->tmpdir);
@@ -510,11 +509,11 @@ EOM
 		mkdir($xrd, 0700) or BAIL_OUT "mkdir: $!";
 		local $ENV{XDG_RUNTIME_DIR} = $xrd;
 		$cb->();
-		ok($lei->(qw(daemon-pid)), "daemon-pid after $t");
+		lei_ok(qw(daemon-pid), \"daemon-pid after $t");
 		chomp($daemon_pid = $lei_out);
 		if ($daemon_pid) {
 			ok(kill(0, $daemon_pid), "daemon running after $t");
-			ok($lei->(qw(daemon-kill)), "daemon-kill after $t");
+			lei_ok(qw(daemon-kill), \"daemon-kill after $t");
 		} else {
 			fail("daemon not running after $t");
 		}
@@ -528,7 +527,7 @@ EOM
 		local $ENV{HOME} = $home;
 		# force sun_path[108] overflow:
 		my $xrd = "$home/1shot-test".('.sun_path' x 108);
-		local $err_skip = qr!\Q$xrd!; # for $lei->() filtering
+		local $err_skip = qr!\Q$xrd!; # for lei() filtering
 		local $ENV{XDG_RUNTIME_DIR} = $xrd;
 		$cb->();
 	}
diff --git a/t/lei-daemon.t b/t/lei-daemon.t
index c55ba86c..c30e5ac1 100644
--- a/t/lei-daemon.t
+++ b/t/lei-daemon.t
@@ -6,7 +6,7 @@ use strict; use v5.10.1; use PublicInbox::TestCommon;
 test_lei({ daemon_only => 1 }, sub {
 	my $sock = "$ENV{XDG_RUNTIME_DIR}/lei/5.seq.sock";
 	my $err_log = "$ENV{XDG_RUNTIME_DIR}/lei/errors.log";
-	ok($lei->('daemon-pid'), 'daemon-pid');
+	lei_ok('daemon-pid');
 	is($lei_err, '', 'no error from daemon-pid');
 	like($lei_out, qr/\A[0-9]+\n\z/s, 'pid returned') or BAIL_OUT;
 	chomp(my $pid = $lei_out);
@@ -17,12 +17,12 @@ test_lei({ daemon_only => 1 }, sub {
 	print $efh "phail\n" or BAIL_OUT $!;
 	close $efh or BAIL_OUT $!;
 
-	ok($lei->('daemon-pid'), 'daemon-pid');
+	lei_ok('daemon-pid');
 	chomp(my $pid_again = $lei_out);
 	is($pid, $pid_again, 'daemon-pid idempotent');
 	like($lei_err, qr/phail/, 'got mock "phail" error previous run');
 
-	ok($lei->(qw(daemon-kill)), 'daemon-kill');
+	lei_ok(qw(daemon-kill));
 	is($lei_out, '', 'no output from daemon-kill');
 	is($lei_err, '', 'no error from daemon-kill');
 	for (0..100) {
@@ -32,22 +32,22 @@ test_lei({ daemon_only => 1 }, sub {
 	ok(-S $sock, 'sock still exists');
 	ok(!kill(0, $pid), 'pid gone after stop');
 
-	ok($lei->(qw(daemon-pid)), 'daemon-pid');
+	lei_ok(qw(daemon-pid));
 	chomp(my $new_pid = $lei_out);
 	ok(kill(0, $new_pid), 'new pid is running');
 	ok(-S $sock, 'sock still exists');
 
 	for my $sig (qw(-0 -CHLD)) {
-		ok($lei->('daemon-kill', $sig), "handles $sig");
+		lei_ok('daemon-kill', $sig, \"handles $sig");
 	}
 	is($lei_out.$lei_err, '', 'no output on innocuous signals');
-	ok($lei->('daemon-pid'), 'daemon-pid');
+	lei_ok('daemon-pid');
 	chomp $lei_out;
 	is($lei_out, $new_pid, 'PID unchanged after -0/-CHLD');
 
 	if ('socket inaccessible') {
 		chmod 0000, $sock or BAIL_OUT "chmod 0000: $!";
-		ok($lei->('help'), 'connect fail, one-shot fallback works');
+		lei_ok('help', \'connect fail, one-shot fallback works');
 		like($lei_err, qr/\bconnect\(/, 'connect error noted');
 		like($lei_out, qr/^usage: /, 'help output works');
 		chmod 0700, $sock or BAIL_OUT "chmod 0700: $!";
diff --git a/t/lei-externals.t b/t/lei-externals.t
index 02b15232..edaaa5f8 100644
--- a/t/lei-externals.t
+++ b/t/lei-externals.t
@@ -20,11 +20,11 @@ SKIP: {
 	which('torsocks') or skip 'no torsocks', $nr if $url =~ m!\.onion/!;
 	my $mid = '20140421094015.GA8962@dcvr.yhbt.net';
 	my @cmd = ('q', '--only', $url, '-q', "m:$mid");
-	ok($lei->(@cmd), "query $url");
+	lei_ok(@cmd, \"query $url");
 	is($lei_err, '', "no errors on $url");
 	my $res = json_utf8->decode($lei_out);
 	is($res->[0]->{'m'}, "<$mid>", "got expected mid from $url");
-	ok($lei->(@cmd, 'd:..20101002'), 'no results, no error');
+	lei(@cmd, 'd:..20101002', \'no results, no error');
 	is($lei_err, '', 'no output on 404, matching local FS behavior');
 	is($lei_out, "[null]\n", 'got null results');
 } # /SKIP
@@ -93,27 +93,26 @@ test_lei(sub {
 			https://example https://example. https://example.co
 			https://example.com https://example.com/
 			https://example.com/i https://example.com/ibx)) {
-		ok($lei->(qw(_complete lei forget-external), $u),
-			"partial completion for URL $u");
+		lei_ok(qw(_complete lei forget-external), $u,
+			\"partial completion for URL $u");
 		is($lei_out, "https://example.com/ibx/\n",
 			"completed partial URL $u");
 		for my $qo (qw(-I --include --exclude --only)) {
-			ok($lei->(qw(_complete lei q), $qo, $u),
-				"partial completion for URL q $qo $u");
+			lei_ok(qw(_complete lei q), $qo, $u,
+				\"partial completion for URL q $qo $u");
 			is($lei_out, "https://example.com/ibx/\n",
 				"completed partial URL $u on q $qo");
 		}
 	}
-	ok($lei->(qw(_complete lei add-external), 'https://'),
-		'add-external hostname completion');
+	lei_ok(qw(_complete lei add-external), 'https://',
+		\'add-external hostname completion');
 	is($lei_out, "https://example.com/\n", 'completed up to hostname');
 
-	$lei->('ls-external');
+	lei_ok('ls-external');
 	like($lei_out, qr!https://example\.com/ibx/!s, 'added canonical URL');
 	is($lei_err, '', 'no warnings on ls-external');
-	ok($lei->(qw(forget-external -q https://EXAMPLE.com/ibx)),
-		'forget');
-	$lei->('ls-external');
+	lei_ok(qw(forget-external -q https://EXAMPLE.com/ibx));
+	lei_ok('ls-external');
 	unlike($lei_out, qr!https://example\.com/ibx/!s,
 		'removed canonical URL');
 SKIP: {
@@ -137,14 +136,14 @@ SKIP: {
 	# or use single quotes, it should not matter.  Users only need
 	# to know shell quoting rules, not Xapian quoting rules.
 	# No double-quoting should be imposed on users on the CLI
-	$lei->('q', 's:use boolean prefix');
+	lei_ok('q', 's:use boolean prefix');
 	like($lei_out, qr/search: use boolean prefix/,
 		'phrase search got result');
 	my $res = json_utf8->decode($lei_out);
 	is(scalar(@$res), 2, 'only 2 element array (1 result)');
 	is($res->[1], undef, 'final element is undef'); # XXX should this be?
 	is(ref($res->[0]), 'HASH', 'first element is hashref');
-	$lei->('q', '--pretty', 's:use boolean prefix');
+	lei_ok('q', '--pretty', 's:use boolean prefix');
 	my $pretty = json_utf8->decode($lei_out);
 	is_deeply($res, $pretty, '--pretty is identical after decode');
 
@@ -153,29 +152,29 @@ SKIP: {
 		$fh->autoflush(1);
 		print $fh 's:use d:..5.days.from.now' or BAIL_OUT $!;
 		seek($fh, 0, SEEK_SET) or BAIL_OUT $!;
-		ok($lei->([qw(q -q --stdin)], undef, { %$lei_opt, 0 => $fh }),
-				'--stdin on regular file works');
+		lei_ok([qw(q -q --stdin)], undef, { %$lei_opt, 0 => $fh },
+				\'--stdin on regular file works');
 		like($lei_out, qr/use boolean/, '--stdin on regular file');
 	}
 	{
 		pipe(my ($r, $w)) or BAIL_OUT $!;
 		print $w 's:use' or BAIL_OUT $!;
 		close $w or BAIL_OUT $!;
-		ok($lei->([qw(q -q --stdin)], undef, { %$lei_opt, 0 => $r }),
-				'--stdin on pipe file works');
+		lei_ok([qw(q -q --stdin)], undef, { %$lei_opt, 0 => $r },
+				\'--stdin on pipe file works');
 		like($lei_out, qr/use boolean prefix/, '--stdin on pipe');
 	}
-	ok(!$lei->(qw(q -q --stdin s:use)), "--stdin and argv don't mix");
+	ok(!lei(qw(q -q --stdin s:use)), "--stdin and argv don't mix");
 
 	for my $fmt (qw(ldjson ndjson jsonl)) {
-		$lei->('q', '-f', $fmt, 's:use boolean prefix');
+		lei_ok('q', '-f', $fmt, 's:use boolean prefix');
 		is($lei_out, json_utf8->encode($pretty->[0])."\n", "-f $fmt");
 	}
 
 	require IO::Uncompress::Gunzip;
 	for my $sfx ('', '.gz') {
 		my $f = "$home/mbox$sfx";
-		$lei->('q', '-o', "mboxcl2:$f", 's:use boolean prefix');
+		lei_ok('q', '-o', "mboxcl2:$f", 's:use boolean prefix');
 		my $cat = $sfx eq '' ? sub {
 			open my $mb, '<', $f or fail "no mbox: $!";
 			<$mb>
@@ -185,26 +184,26 @@ SKIP: {
 		};
 		my @s = grep(/^Subject:/, $cat->());
 		is(scalar(@s), 1, "1 result in mbox$sfx");
-		$lei->('q', '-a', '-o', "mboxcl2:$f", 's:see attachment');
+		lei_ok('q', '-a', '-o', "mboxcl2:$f", 's:see attachment');
 		is(grep(!/^#/, $lei_err), 0, 'no errors from augment') or
 			diag $lei_err;
 		@s = grep(/^Subject:/, my @wtf = $cat->());
 		is(scalar(@s), 2, "2 results in mbox$sfx");
 
-		$lei->('q', '-a', '-o', "mboxcl2:$f", 's:nonexistent');
+		lei_ok('q', '-a', '-o', "mboxcl2:$f", 's:nonexistent');
 		is(grep(!/^#/, $lei_err), 0, "no errors on no results ($sfx)");
 
 		my @s2 = grep(/^Subject:/, $cat->());
 		is_deeply(\@s2, \@s,
 			"same 2 old results w/ --augment and bad search $sfx");
 
-		$lei->('q', '-o', "mboxcl2:$f", 's:nonexistent');
+		lei_ok('q', '-o', "mboxcl2:$f", 's:nonexistent');
 		my @res = $cat->();
 		is_deeply(\@res, [], "clobber w/o --augment $sfx");
 	}
-	ok(!$lei->('q', '-o', "$home/mbox", 's:nope'),
+	ok(!lei('q', '-o', "$home/mbox", 's:nope'),
 			'fails if mbox format unspecified');
-	ok(!$lei->(qw(q --no-local s:see)), '--no-local');
+	ok(!lei(qw(q --no-local s:see)), '--no-local');
 	is($? >> 8, 1, 'proper exit code');
 	like($lei_err, qr/no local or remote.+? to search/, 'no inbox');
 	my %e = (
diff --git a/t/lei-import-maildir.t b/t/lei-import-maildir.t
index d2b059ad..a3796491 100644
--- a/t/lei-import-maildir.t
+++ b/t/lei-import-maildir.t
@@ -10,15 +10,15 @@ test_lei(sub {
 	}
 	symlink(abs_path('t/data/0001.patch'), "$md/cur/x:2,S") or
 		BAIL_OUT "symlink $md $!";
-	ok($lei->(qw(import), $md), 'import Maildir');
-	ok($lei->(qw(q s:boolean)), 'lei q');
+	lei_ok(qw(import), $md, \'import Maildir');
+	lei_ok(qw(q s:boolean));
 	my $res = json_utf8->decode($lei_out);
 	like($res->[0]->{'s'}, qr/use boolean/, 'got expected result');
 	is_deeply($res->[0]->{kw}, ['seen'], 'keyword set');
 	is($res->[1], undef, 'only got one result');
 
-	ok($lei->(qw(import), $md), 'import Maildir again');
-	ok($lei->(qw(q -d none s:boolean)), 'lei q w/o dedupe');
+	lei_ok(qw(import), $md, \'import Maildir again');
+	lei_ok(qw(q -d none s:boolean), \'lei q w/o dedupe');
 	my $r2 = json_utf8->decode($lei_out);
 	is_deeply($r2, $res, 'idempotent import');
 
diff --git a/t/lei-import.t b/t/lei-import.t
index b691798a..46747a91 100644
--- a/t/lei-import.t
+++ b/t/lei-import.t
@@ -3,18 +3,18 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict; use v5.10.1; use PublicInbox::TestCommon;
 test_lei(sub {
-ok(!$lei->(qw(import -f bogus), 't/plack-qp.eml'), 'fails with bogus format');
+ok(!lei(qw(import -f bogus), 't/plack-qp.eml'), 'fails with bogus format');
 like($lei_err, qr/\bbogus unrecognized/, 'gave error message');
 
-ok($lei->(qw(q s:boolean)), 'search miss before import');
+lei_ok(qw(q s:boolean), \'search miss before import');
 unlike($lei_out, qr/boolean/i, 'no results, yet');
 open my $fh, '<', 't/data/0001.patch' or BAIL_OUT $!;
-ok($lei->([qw(import -f eml -)], undef, { %$lei_opt, 0 => $fh }),
-	'import single file from stdin') or diag $lei_err;
+lei_ok([qw(import -f eml -)], undef, { %$lei_opt, 0 => $fh },
+	\'import single file from stdin') or diag $lei_err;
 close $fh;
-ok($lei->(qw(q s:boolean)), 'search hit after import');
-ok($lei->(qw(import -f eml), 't/data/message_embed.eml'),
-	'import single file by path');
+lei_ok(qw(q s:boolean), \'search hit after import');
+lei_ok(qw(import -f eml), 't/data/message_embed.eml',
+	\'import single file by path');
 
 my $str = <<'';
 From: a@b
@@ -22,17 +22,17 @@ Message-ID: <x@y>
 Status: RO
 
 my $opt = { %$lei_opt, 0 => \$str };
-ok($lei->([qw(import -f eml -)], undef, $opt),
-	'import single file with keywords from stdin');
-$lei->(qw(q m:x@y));
+lei_ok([qw(import -f eml -)], undef, $opt,
+	\'import single file with keywords from stdin');
+lei_ok(qw(q m:x@y));
 my $res = json_utf8->decode($lei_out);
 is($res->[1], undef, 'only one result');
 is_deeply($res->[0]->{kw}, ['seen'], "message `seen' keyword set");
 
 $str =~ tr/x/v/; # v@y
-ok($lei->([qw(import --no-kw -f eml -)], undef, $opt),
-	'import single file with --no-kw from stdin');
-$lei->(qw(q m:v@y));
+lei_ok([qw(import --no-kw -f eml -)], undef, $opt,
+	\'import single file with --no-kw from stdin');
+lei(qw(q m:v@y));
 $res = json_utf8->decode($lei_out);
 is($res->[1], undef, 'only one result');
 is_deeply($res->[0]->{kw}, [], 'no keywords set');
diff --git a/t/lei-mirror.t b/t/lei-mirror.t
index cbe300da..1d113e3e 100644
--- a/t/lei-mirror.t
+++ b/t/lei-mirror.t
@@ -13,28 +13,28 @@ my $td = start_script($cmd, { PI_CONFIG => $cfg_path }, { 3 => $sock });
 test_lei({ tmpdir => $tmpdir }, sub {
 	my $home = $ENV{HOME};
 	my $t1 = "$home/t1-mirror";
-	ok($lei->('add-external', $t1, '--mirror', "$http/t1/"), '--mirror v1');
+	lei_ok('add-external', $t1, '--mirror', "$http/t1/", \'--mirror v1');
 	ok(-f "$t1/public-inbox/msgmap.sqlite3", 't1-mirror indexed');
 
-	ok($lei->('ls-external'), 'ls-external');
+	lei_ok('ls-external');
 	like($lei_out, qr!\Q$t1\E!, 't1 added to ls-externals');
 
 	my $t2 = "$home/t2-mirror";
-	ok($lei->('add-external', $t2, '--mirror', "$http/t2/"), '--mirror v2');
+	lei_ok('add-external', $t2, '--mirror', "$http/t2/", \'--mirror v2');
 	ok(-f "$t2/msgmap.sqlite3", 't2-mirror indexed');
 
-	ok($lei->('ls-external'), 'ls-external');
+	lei_ok('ls-external');
 	like($lei_out, qr!\Q$t2\E!, 't2 added to ls-externals');
 
-	ok(!$lei->('add-external', $t2, '--mirror', "$http/t2/"),
+	ok(!lei('add-external', $t2, '--mirror', "$http/t2/"),
 		'--mirror fails if reused') or diag "$lei_err.$lei_out = $?";
 
-	ok($lei->('ls-external'), 'ls-external');
+	lei_ok('ls-external');
 	like($lei_out, qr!\Q$t2\E!, 'still in ls-externals');
 
-	ok(!$lei->('add-external', "$t2-fail", '-Lmedium'), '--mirror v2');
+	ok(!lei('add-external', "$t2-fail", '-Lmedium'), '--mirror v2');
 	ok(!-d "$t2-fail", 'destination not created on failure');
-	ok($lei->('ls-external'), 'ls-external');
+	lei_ok('ls-external');
 	unlike($lei_out, qr!\Q$t2-fail\E!, 'not added to ls-external');
 });
 
diff --git a/t/lei.t b/t/lei.t
index 4785acca..2e0b8a1f 100644
--- a/t/lei.t
+++ b/t/lei.t
@@ -13,36 +13,36 @@ my $home_trash = [];
 my $cleanup = sub { rmtree([@$home_trash, @_]) };
 
 my $test_help = sub {
-	ok(!$lei->(), 'no args fails');
+	ok(!lei([]), 'no args fails');
 	is($? >> 8, 1, '$? is 1');
 	is($lei_out, '', 'nothing in stdout');
 	like($lei_err, qr/^usage:/sm, 'usage in stderr');
 
 	for my $arg (['-h'], ['--help'], ['help'], [qw(daemon-pid --help)]) {
-		ok($lei->($arg), "lei @$arg");
+		lei_ok($arg);
 		like($lei_out, qr/^usage:/sm, "usage in stdout (@$arg)");
 		is($lei_err, '', "nothing in stderr (@$arg)");
 	}
 
 	for my $arg ([''], ['--halp'], ['halp'], [qw(daemon-pid --halp)]) {
-		ok(!$lei->($arg), "lei @$arg");
+		ok(!lei($arg), "lei @$arg");
 		is($? >> 8, 1, '$? set correctly');
 		isnt($lei_err, '', 'something in stderr');
 		is($lei_out, '', 'nothing in stdout');
 	}
-	ok($lei->(qw(init -h)), 'init -h');
+	lei_ok(qw(init -h));
 	like($lei_out, qr! \Q$home\E/\.local/share/lei/store\b!,
 		'actual path shown in init -h');
-	ok($lei->(qw(init -h), { XDG_DATA_HOME => '/XDH' }),
-		'init with XDG_DATA_HOME');
+	lei_ok(qw(init -h), { XDG_DATA_HOME => '/XDH' },
+		\'init with XDG_DATA_HOME');
 	like($lei_out, qr! /XDH/lei/store\b!, 'XDG_DATA_HOME in init -h');
 	is($lei_err, '', 'no errors from init -h');
 
-	ok($lei->(qw(config -h)), 'config-h');
+	lei_ok(qw(config -h));
 	like($lei_out, qr! \Q$home\E/\.config/lei/config\b!,
 		'actual path shown in config -h');
-	ok($lei->(qw(config -h), { XDG_CONFIG_HOME => '/XDC' }),
-		'config with XDG_CONFIG_HOME');
+	lei_ok(qw(config -h), { XDG_CONFIG_HOME => '/XDC' },
+		\'config with XDG_CONFIG_HOME');
 	like($lei_out, qr! /XDC/lei/config\b!, 'XDG_CONFIG_HOME in config -h');
 	is($lei_err, '', 'no errors from config -h');
 };
@@ -55,24 +55,24 @@ my $ok_err_info = sub {
 
 my $test_init = sub {
 	$cleanup->();
-	ok($lei->('init'), 'init w/o args');
+	lei_ok('init', \'init w/o args');
 	$ok_err_info->('after init w/o args');
-	ok($lei->('init'), 'idempotent init w/o args');
+	lei_ok('init', \'idempotent init w/o args');
 	$ok_err_info->('after idempotent init w/o args');
 
-	ok(!$lei->('init', "$home/x"), 'init conflict');
+	ok(!lei('init', "$home/x"), 'init conflict');
 	is(grep(/^E:/, split(/^/, $lei_err)), 1, 'got error on conflict');
 	ok(!-e "$home/x", 'nothing created on conflict');
 	$cleanup->();
 
-	ok($lei->('init', "$home/x"), 'init conflict resolved');
+	lei_ok('init', "$home/x", \'init conflict resolved');
 	$ok_err_info->('init w/ arg');
-	ok($lei->('init', "$home/x"), 'init idempotent w/ path');
+	lei_ok('init', "$home/x", \'init idempotent w/ path');
 	$ok_err_info->('init idempotent w/ arg');
 	ok(-d "$home/x", 'created dir');
 	$cleanup->("$home/x");
 
-	ok(!$lei->('init', "$home/x", "$home/2"), 'too many args fails');
+	ok(!lei('init', "$home/x", "$home/2"), 'too many args fails');
 	like($lei_err, qr/too many/, 'noted excessive');
 	ok(!-e "$home/x", 'x not created on excessive');
 	for my $d (@$home_trash) {
@@ -84,24 +84,24 @@ my $test_init = sub {
 
 my $test_config = sub {
 	$cleanup->();
-	ok($lei->(qw(config a.b c)), 'config set var');
+	lei_ok(qw(config a.b c), \'config set var');
 	is($lei_out.$lei_err, '', 'no output on var set');
-	ok($lei->(qw(config -l)), 'config -l');
+	lei_ok(qw(config -l), \'config -l');
 	is($lei_err, '', 'no errors on listing');
 	is($lei_out, "a.b=c\n", 'got expected output');
-	ok(!$lei->(qw(config -f), "$home/.config/f", qw(x.y z)),
+	ok(!lei(qw(config -f), "$home/.config/f", qw(x.y z)),
 			'config set var with -f fails');
 	like($lei_err, qr/not supported/, 'not supported noted');
 	ok(!-f "$home/config/f", 'no file created');
 };
 
 my $test_completion = sub {
-	ok($lei->(qw(_complete lei)), 'no errors on complete');
+	lei_ok(qw(_complete lei), \'no errors on complete');
 	my %out = map { $_ => 1 } split(/\s+/s, $lei_out);
 	ok($out{'q'}, "`lei q' offered as completion");
 	ok($out{'add-external'}, "`lei add-external' offered as completion");
 
-	ok($lei->(qw(_complete lei q)), 'complete q (no args)');
+	lei_ok(qw(_complete lei q), \'complete q (no args)');
 	%out = map { $_ => 1 } split(/\s+/s, $lei_out);
 	for my $sw (qw(-f --format -o --output --mfolder --augment -a
 			--mua --no-local --local --verbose -v
@@ -110,17 +110,17 @@ my $test_completion = sub {
 		ok($out{$sw}, "$sw offered as `lei q' completion");
 	}
 
-	ok($lei->(qw(_complete lei q --form)), 'complete q --format');
+	lei_ok(qw(_complete lei q --form), \'complete q --format');
 	is($lei_out, "--format\n", 'complete lei q --format');
 	for my $sw (qw(-f --format)) {
-		ok($lei->(qw(_complete lei q), $sw), "complete q $sw ARG");
+		lei_ok(qw(_complete lei q), $sw);
 		%out = map { $_ => 1 } split(/\s+/s, $lei_out);
 		for my $f (qw(mboxrd mboxcl2 mboxcl mboxo json jsonl
 				concatjson maildir)) {
 			ok($out{$f}, "got $sw $f as output format");
 		}
 	}
-	ok($lei->(qw(_complete lei import)), 'complete import');
+	lei_ok(qw(_complete lei import));
 	%out = map { $_ => 1 } split(/\s+/s, $lei_out);
 	for my $sw (qw(--flags --no-flags --no-kw --kw --no-keywords
 			--keywords)) {
@@ -131,9 +131,9 @@ my $test_completion = sub {
 my $test_fail = sub {
 SKIP: {
 	skip 'no curl', 3 unless which('curl');
-	$lei->(qw(q --only http://127.0.0.1:99999/bogus/ t:m));
+	lei(qw(q --only http://127.0.0.1:99999/bogus/ t:m));
 	is($? >> 8, 3, 'got curl exit for bogus URL');
-	$lei->(qw(q --only http://127.0.0.1:99999/bogus/ t:m -o), "$home/junk");
+	lei(qw(q --only http://127.0.0.1:99999/bogus/ t:m -o), "$home/junk");
 	is($? >> 8, 3, 'got curl exit for bogus URL with Maildir');
 	is($lei_out, '', 'no output');
 }; # /SKIP

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-21 20:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-21 19:59 [PATCH] t/lei*: drop $lei->(...) sub Eric Wong
2021-02-21 20:42 ` [SQUASH 2/1] t/lei-externals: squash fix Eric Wong

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).