aboutsummaryrefslogtreecommitdiffstats
path: root/spec/spec_helper.rb
diff options
context:
space:
mode:
authorDavid Cabo <david@calibea.com>2011-08-19 02:03:19 +0200
committerDavid Cabo <david@calibea.com>2011-08-19 02:03:19 +0200
commitd473fce1d0451c913d3ef697d3b45bd58c6fff54 (patch)
tree9ebfde4d7452354f9683c1760748d28c40a9b71f /spec/spec_helper.rb
parent9245dbb67b74aff75d4ad1c7a8c5716614541342 (diff)
Make Xapian index rebuilds run in-process (while running tests only!) for performance reasons
This was previously not supported by acts_as_xapian, since the update/rebuild process didnt unlock the database when finihed. The bindings for the latest Xapian bindings support closing the database, so we take advantage of that.
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r--spec/spec_helper.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 42c5ff6bf..b4471afc1 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -81,11 +81,11 @@ def load_file_fixture(file_name)
end
def rebuild_xapian_index
- # XXX could for speed call ActsAsXapian.rebuild_index directly, but would
- # need model name list, and would need to fix acts_as_xapian so can call writes
- # and reads mixed up (it asserts where it thinks it can't do this)
- rebuild_name = File.dirname(__FILE__) + '/../script/rebuild-xapian-index'
- Kernel.system(rebuild_name) or raise "failed to launch #{rebuild_name}, error bitcode #{$?}, exit status: #{$?.exitstatus}"
+ verbose = false
+ # safe_rebuild=true, which involves forking to avoid memory leaks, doesn't work well with rspec.
+ # unsafe is significantly faster, and we can afford possible memory leaks while testing.
+ safe_rebuild = false
+ ActsAsXapian.rebuild_index(["PublicBody", "User", "InfoRequestEvent"].map{|m| m.constantize}, verbose, safe_rebuild)
end
def update_xapian_index