* [PATCH 0/4] TEST_RUN_MODE=0 fixes
@ 2021-01-01 5:47 Eric Wong
2021-01-01 5:47 ` [PATCH 1/4] search: do not use $QP_FLAGS until Xapian is loaded Eric Wong
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Eric Wong @ 2021-01-01 5:47 UTC (permalink / raw)
To: meta
Oops :x I should use TEST_RUN_MODE more often to give
my hands a rest. None of these surface with the quick
"check-run" target
Eric Wong (4):
search: do not use $QP_FLAGS until Xapian is loaded
t/lei: fix TEST_RUN_MODE=0, simplify oneshot fallback test
import: unset GIT_CONFIG with `git config --global'
treewide: reduce load_xapian* callsites
lib/PublicInbox/Import.pm | 1 +
lib/PublicInbox/LEI.pm | 1 -
lib/PublicInbox/LeiStore.pm | 5 +----
lib/PublicInbox/Search.pm | 2 +-
t/indexlevels-mirror.t | 4 +---
t/lei-oneshot.t | 17 -----------------
t/lei.t | 29 +++++++++++++++++------------
t/replace.t | 3 +--
8 files changed, 22 insertions(+), 40 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] search: do not use $QP_FLAGS until Xapian is loaded
2021-01-01 5:47 [PATCH 0/4] TEST_RUN_MODE=0 fixes Eric Wong
@ 2021-01-01 5:47 ` Eric Wong
2021-01-01 5:47 ` [PATCH 2/4] t/lei: fix TEST_RUN_MODE=0, simplify oneshot fallback Eric Wong
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2021-01-01 5:47 UTC (permalink / raw)
To: meta
The default $QP_FLAGS won't be set until after Xapian is
loaded, duh...
This fixes t/imapd.t with TEST_RUN_MODE=0
---
lib/PublicInbox/Search.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 547b6fbe..0bdf6fc6 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -196,6 +196,7 @@ sub xdb_shards_flat ($) {
my $xpfx = $self->{xpfx};
my (@xdb, $slow_phrase);
load_xapian();
+ $self->{qp_flags} //= $QP_FLAGS;
if ($xpfx =~ m/xapian${\SCHEMA_VERSION}\z/) {
@xdb = ($X{Database}->new($xpfx));
$self->{qp_flags} |= FLAG_PHRASE() if !-f "$xpfx/iamchert";
@@ -232,7 +233,6 @@ sub mset_to_artnums {
sub xdb ($) {
my ($self) = @_;
$self->{xdb} //= do {
- $self->{qp_flags} //= $QP_FLAGS;
my @xdb = $self->xdb_shards_flat or return;
$self->{nshard} = scalar(@xdb);
my $xdb = shift @xdb;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] t/lei: fix TEST_RUN_MODE=0, simplify oneshot fallback
2021-01-01 5:47 [PATCH 0/4] TEST_RUN_MODE=0 fixes Eric Wong
2021-01-01 5:47 ` [PATCH 1/4] search: do not use $QP_FLAGS until Xapian is loaded Eric Wong
@ 2021-01-01 5:47 ` Eric Wong
2021-01-01 5:47 ` [PATCH 3/4] import: unset GIT_CONFIG with `git config --global' Eric Wong
2021-01-01 5:47 ` [PATCH 4/4] treewide: reduce load_xapian* callsites Eric Wong
3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2021-01-01 5:47 UTC (permalink / raw)
To: meta
We need to use an absolute path after chdir in run modes
where scripts aren't loaded into in-memory subs.
The oneshot test was also failing under TEST_RUN_MODE=0 due to
no "lei-oneshot" command existing on the FS. So we force a
socket failure by making XDG_RUNTIME_DIR too large to fit into
the 108-byte .sun_path field of "struct sockaddr_un". This
even lets us simplify lei-oneshot significantly.
---
t/lei-oneshot.t | 17 -----------------
t/lei.t | 29 +++++++++++++++++------------
2 files changed, 17 insertions(+), 29 deletions(-)
diff --git a/t/lei-oneshot.t b/t/lei-oneshot.t
index 2b34f982..7688da5b 100644
--- a/t/lei-oneshot.t
+++ b/t/lei-oneshot.t
@@ -4,22 +4,5 @@
use strict;
use v5.10.1;
use PublicInbox::TestCommon;
-$PublicInbox::TestCommon::cached_scripts{'lei-oneshot'} //= do {
- eval <<'EOF';
-package LeiOneshot;
-use strict;
-use subs qw(exit);
-*exit = \&PublicInbox::TestCommon::run_script_exit;
-sub main {
-# the below "line" directive is a magic comment, see perlsyn(1) manpage
-# line 1 "lei-oneshot"
- require PublicInbox::LEI;
- PublicInbox::LEI::oneshot(__PACKAGE__);
- 0;
-}
-1;
-EOF
- LeiOneshot->can('main');
-};
local $ENV{TEST_LEI_ONESHOT} = '1';
require './t/lei.t';
diff --git a/t/lei.t b/t/lei.t
index 690878ce..41638950 100644
--- a/t/lei.t
+++ b/t/lei.t
@@ -9,7 +9,6 @@ use PublicInbox::Config;
use File::Path qw(rmtree);
require_git 2.6;
require_mods(qw(json DBD::SQLite Search::Xapian));
-my $LEI = 'lei';
my $opt = { 1 => \(my $out = ''), 2 => \(my $err = '') };
my $lei = sub {
my ($cmd, $env, $xopt) = @_;
@@ -18,13 +17,12 @@ my $lei = sub {
($env, $xopt) = grep { (!defined) || ref } @_;
$cmd = [ grep { defined && !ref } @_ ];
}
- run_script([$LEI, @$cmd], $env, $xopt // $opt);
+ run_script(['lei', @$cmd], $env, $xopt // $opt);
};
my ($home, $for_destroy) = tmpdir();
delete local $ENV{XDG_DATA_HOME};
delete local $ENV{XDG_CONFIG_HOME};
-local $ENV{XDG_RUNTIME_DIR} = "$home/xdg_run";
local $ENV{HOME} = $home;
local $ENV{FOO} = 'BAR';
mkdir "$home/xdg_run", 0700 or BAIL_OUT "mkdir: $!";
@@ -188,10 +186,16 @@ my $test_lei_common = sub {
$test_external->();
};
-my $test_lei_oneshot = $ENV{TEST_LEI_ONESHOT};
-SKIP: {
- last SKIP if $test_lei_oneshot;
+if ($ENV{TEST_LEI_ONESHOT}) {
+ require_ok 'PublicInbox::LEI';
+ # force sun_path[108] overflow, "IO::FDPass" avoids warning
+ local $ENV{XDG_RUNTIME_DIR} = "$home/IO::FDPass".('.sun_path' x 108);
+ $test_lei_common->();
+}
+
+SKIP: { # real socket
require_mods(qw(IO::FDPass Cwd), 46);
+ local $ENV{XDG_RUNTIME_DIR} = "$home/xdg_run";
my $sock = "$ENV{XDG_RUNTIME_DIR}/lei/sock";
ok(run_script([qw(lei daemon-pid)], undef, $opt), 'daemon-pid');
@@ -275,11 +279,17 @@ SKIP: {
if ('oneshot on cwd gone') {
my $cwd = Cwd::fastcwd() or BAIL_OUT "fastcwd: $!";
my $d = "$home/to-be-removed";
+ my $lei_path = 'lei';
+ # we chdir, so we need an abs_path fur run_script
+ if (($ENV{TEST_RUN_MODE}//2) != 2) {
+ $lei_path = PublicInbox::TestCommon::key2script('lei');
+ $lei_path = Cwd::abs_path($lei_path);
+ }
mkdir $d or BAIL_OUT "mkdir($d) $!";
chdir $d or BAIL_OUT "chdir($d) $!";
if (rmdir($d)) {
$out = $err = '';
- ok(run_script([qw(lei help)], undef, $opt),
+ ok(run_script([$lei_path, 'help'], undef, $opt),
'cwd fail, one-shot fallback works');
} else {
$err = "rmdir=$!";
@@ -296,11 +306,6 @@ SKIP: {
}
ok(!kill(0, $new_pid), 'daemon exits after unlink');
# success over socket, can't test without
- $test_lei_common = undef;
};
-require_ok 'PublicInbox::LEI';
-$LEI = 'lei-oneshot' if $test_lei_oneshot;
-$test_lei_common->() if $test_lei_common;
-
done_testing;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] import: unset GIT_CONFIG with `git config --global'
2021-01-01 5:47 [PATCH 0/4] TEST_RUN_MODE=0 fixes Eric Wong
2021-01-01 5:47 ` [PATCH 1/4] search: do not use $QP_FLAGS until Xapian is loaded Eric Wong
2021-01-01 5:47 ` [PATCH 2/4] t/lei: fix TEST_RUN_MODE=0, simplify oneshot fallback Eric Wong
@ 2021-01-01 5:47 ` Eric Wong
2021-01-01 5:47 ` [PATCH 4/4] treewide: reduce load_xapian* callsites Eric Wong
3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2021-01-01 5:47 UTC (permalink / raw)
To: meta
GIT_CONFIG is set by -convert, and user may have it set
for other reasons. In either case, it conflicts with
any any attempt to use `git config --global` so we have
to unset it.
This fixes t/multi-mid.t under TEST_RUN_MODE=0
---
lib/PublicInbox/Import.pm | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 47a529ff..0aff0e9d 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -21,6 +21,7 @@ use POSIX qw(strftime);
sub default_branch () {
state $default_branch = do {
+ delete local $ENV{GIT_CONFIG};
my $r = popen_rd([qw(git config --global init.defaultBranch)]);
chomp(my $h = <$r> // '');
$h eq '' ? 'refs/heads/master' : $h;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] treewide: reduce load_xapian* callsites
2021-01-01 5:47 [PATCH 0/4] TEST_RUN_MODE=0 fixes Eric Wong
` (2 preceding siblings ...)
2021-01-01 5:47 ` [PATCH 3/4] import: unset GIT_CONFIG with `git config --global' Eric Wong
@ 2021-01-01 5:47 ` Eric Wong
3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2021-01-01 5:47 UTC (permalink / raw)
To: meta
Hopefully this will make it easier to spot dependency
bugs in the future.
---
lib/PublicInbox/LEI.pm | 1 -
lib/PublicInbox/LeiStore.pm | 5 +----
t/indexlevels-mirror.t | 4 +---
t/replace.t | 3 +--
4 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 320a2bfc..2bc4a916 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -453,7 +453,6 @@ sub _lei_store ($;$) {
my $cfg = _lei_cfg($self, $creat);
$cfg->{-lei_store} //= do {
require PublicInbox::LeiStore;
- PublicInbox::SearchIdx::load_xapian_writable();
my $dir = $cfg->{'leistore.dir'};
$dir //= _store_path($self->{env}) if $creat;
return unless $dir;
diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm
index a23efed5..07a3198a 100644
--- a/lib/PublicInbox/LeiStore.pm
+++ b/lib/PublicInbox/LeiStore.pm
@@ -24,10 +24,7 @@ sub new {
my (undef, $dir, $opt) = @_;
my $eidx = PublicInbox::ExtSearchIdx->new($dir, $opt);
my $self = bless { priv_eidx => $eidx }, __PACKAGE__;
- if ($opt->{creat}) {
- PublicInbox::SearchIdx::load_xapian_writable();
- eidx_init($self);
- }
+ eidx_init($self) if $opt->{creat};
$self;
}
diff --git a/t/indexlevels-mirror.t b/t/indexlevels-mirror.t
index a2afbd74..53826aef 100644
--- a/t/indexlevels-mirror.t
+++ b/t/indexlevels-mirror.t
@@ -172,9 +172,7 @@ my $import_index_incremental = sub {
$import_index_incremental->($PI_TEST_VERSION, 'basic', $mime);
SKIP: {
- require PublicInbox::Search;
- PublicInbox::Search::load_xapian() or
- skip('Xapian perl binding missing', 2);
+ require_mods(qw(Search::Xapian), 2);
foreach my $l (qw(medium full)) {
$import_index_incremental->($PI_TEST_VERSION, $l, $mime);
}
diff --git a/t/replace.t b/t/replace.t
index 7135c863..51bdb964 100644
--- a/t/replace.t
+++ b/t/replace.t
@@ -186,8 +186,7 @@ test_replace(2, 'basic', $opt = { %$opt, post => \&pad_msgs });
test_replace(2, 'basic', $opt = { %$opt, rotate_bytes => 1 });
SKIP: {
- require PublicInbox::Search;
- PublicInbox::Search::load_xapian() or skip 'Search::Xapian missing', 8;
+ require_mods(qw(Search::Xapian), 8);
for my $l (qw(medium)) {
test_replace(2, $l, {});
$opt = { pre => \&pad_msgs };
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-01 5:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-01 5:47 [PATCH 0/4] TEST_RUN_MODE=0 fixes Eric Wong
2021-01-01 5:47 ` [PATCH 1/4] search: do not use $QP_FLAGS until Xapian is loaded Eric Wong
2021-01-01 5:47 ` [PATCH 2/4] t/lei: fix TEST_RUN_MODE=0, simplify oneshot fallback Eric Wong
2021-01-01 5:47 ` [PATCH 3/4] import: unset GIT_CONFIG with `git config --global' Eric Wong
2021-01-01 5:47 ` [PATCH 4/4] treewide: reduce load_xapian* callsites 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).