commit 41afb3f131171fd680b6249d9f33313dce59a27e
parent 6bced04a5d2f68bec16d72b0ac6e5720ceb072cf
Author: Dan Callaghan <djc@djc.id.au>
Date: Sun, 5 Apr 2026 20:41:18 +1000
tests: try to avoid index writing race on teardown
In one run through the tests, TestMbox#teardown failed with ENOTEMPTY
from rmdir. It didn't reproduce. My best guess is that Xapian was not
finished writing its index updates to disk when the teardown ran.
Call Index.save_index in all tests that write an index to disk, to try
and avoid the race. This also requires removing the $stderr logging sink
in these tests to avoid having the info message from Index.save_index
mingled in with the test output.
Diffstat:
3 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/test/integration/test_draft.rb b/test/integration/test_draft.rb
@@ -7,6 +7,7 @@ class TestDraft < Minitest::Test
def setup
@path = Dir.mktmpdir
start
+ Logger.remove_sink $stderr
@draft_dir = File.join @path, "drafts"
@test_message_1 = <<EOS
From: Some Person <someone@example.invalid>
@@ -28,6 +29,7 @@ EOS
end
def teardown
+ Index.save_index
ObjectSpace.each_object(Class).select {|a| a < Redwood::Singleton}.each do |klass|
klass.deinstantiate! unless klass == Redwood::Logger
end
diff --git a/test/integration/test_maildir.rb b/test/integration/test_maildir.rb
@@ -41,11 +41,13 @@ EOS
def start_sup_and_add_source(source)
start
+ Logger.remove_sink $stderr
Index.init @path
Index.load
SourceManager.instance.instance_eval '@sources = {}'
SourceManager.instance.add_source source
PollManager.poll_from source
+ Index.save_index
end
# and now, let the tests begin!
diff --git a/test/integration/test_mbox.rb b/test/integration/test_mbox.rb
@@ -34,11 +34,13 @@ EOS
def start_sup_and_add_source(source)
start
+ Logger.remove_sink $stderr
Index.init @path
Index.load
SourceManager.instance.instance_eval '@sources = {}'
SourceManager.instance.add_source source
PollManager.poll_from source
+ Index.save_index
end
# and now, let the tests begin!