diff options
author | Eric Wong <e@80x24.org> | 2021-02-22 01:59:06 +0600 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-02-22 00:52:32 +0000 |
commit | 2ee341027929f716636aa7f03057a961d3a02d1c (patch) | |
tree | a85fe13baaeab9ae5740f8d06d56cf56bd131212 /lib/PublicInbox/TestCommon.pm | |
parent | 4f4fa052e6caf470632a2e8a8ea5113c97f0ba21 (diff) | |
download | public-inbox-2ee341027929f716636aa7f03057a961d3a02d1c.tar.gz |
t/lei*: drop $lei->(...) sub
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.
Diffstat (limited to 'lib/PublicInbox/TestCommon.pm')
-rw-r--r-- | lib/PublicInbox/TestCommon.pm | 13 |
1 files changed, 6 insertions, 7 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->(); } |