]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: cleanup SQLite handles on --xapian-only
authorEric Wong <e@80x24.org>
Wed, 24 Mar 2021 09:23:33 +0000 (14:23 +0500)
committerEric Wong <e@80x24.org>
Wed, 24 Mar 2021 23:01:20 +0000 (23:01 +0000)
I'm not sure exactly why this is needed with run_script
localizing %SIG and everything else, but explictly cleaning up
seems to fix the occasional test failures I see.

Followup-to: 4c6c853494b49368 ("tests: show lsof output on deleted-file-check failures")
lib/PublicInbox/V2Writable.pm
t/v2reindex.t

index 03590850973e0589000b29884d2f812759d128ae..4130a4728feff01314166d9a7528fc96d4e6fe4b 100644 (file)
@@ -1323,6 +1323,7 @@ sub xapian_only {
                }
        }
        $self->git->cat_async_wait;
+       $self->{ibx}->cleanup;
        $self->done;
 }
 
index 1145e31b414e7118b49a66766c4c358f7f6453ed..e9f2b73b2b9083060359a45300c2fc286f173853 100644 (file)
@@ -549,5 +549,13 @@ my $env = { PI_CONFIG => '/dev/null' };
 ok(run_script([qw(-index --reindex --xapian-only), $inboxdir], $env, $rdr),
        '--xapian-only works');
 is($err, '', 'no errors from --xapian-only');
-
+undef $for_destroy;
+SKIP: {
+       use PublicInbox::Spawn qw(which);
+       skip 'only testing lsof(8) output on Linux', 1 if $^O ne 'linux';
+       my $lsof = which('lsof') or skip 'no lsof in PATH', 1;
+       my $rdr = { 2 => \(my $null_err) };
+       my @d = grep(m!/xap[0-9]+/!, xqx([$lsof, '-p', $$], undef, $rdr));
+       is_deeply(\@d, [], 'no deleted index files') or diag explain(\@d);
+}
 done_testing();