test_description="ruby bindings"
. $(dirname "$0")/test-lib.sh || exit 1
-if [ "${NOTMUCH_HAVE_RUBY_DEV}" = "0" ]; then
+if [ -z "${NOTMUCH_TEST_INSTALLED-}" -a "${NOTMUCH_HAVE_RUBY_DEV-0}" = "0" ]; then
test_subtest_missing_external_prereq_["ruby development files"]=t
fi
(
cat <<-EOF
require 'notmuch'
- db = Notmuch::Database.new('$MAIL_DIR')
+ db = Notmuch::Database.new()
EOF
cat
- ) | $NOTMUCH_RUBY -I "$NOTMUCH_BUILDDIR/bindings/ruby"> OUTPUT
+ ) | if [ -n "${NOTMUCH_TEST_INSTALLED-}" ]; then
+ ruby
+ else
+ $NOTMUCH_RUBY -I "$NOTMUCH_BUILDDIR/bindings/ruby"
+ fi> OUTPUT
test_expect_equal_file EXPECTED OUTPUT
}
end
EOF
+notmuch config set search.exclude_tags deleted
+generate_message '[subject]="Good"'
+generate_message '[subject]="Bad"' "[in-reply-to]=\<$gen_msg_id\>"
+notmuch new > /dev/null
+notmuch tag +deleted id:$gen_msg_id
+
+test_begin_subtest "omit excluded all"
+notmuch search --output=threads --exclude=all tag:inbox > EXPECTED
+test_ruby <<"EOF"
+q = db.query('tag:inbox')
+q.add_tag_exclude('deleted')
+q.omit_excluded = Notmuch::EXCLUDE_ALL
+q.search_threads.each do |t|
+ puts 'thread:%s' % t.thread_id
+end
+EOF
+
+test_begin_subtest "check sort argument"
+notmuch search --sort=oldest-first --output=threads tag:inbox > EXPECTED
+test_ruby <<"EOF"
+q = db.query('tag:inbox', sort: Notmuch::SORT_OLDEST_FIRST)
+q.search_threads.each do |t|
+ puts 'thread:%s' % t.thread_id
+end
+EOF
+
+test_begin_subtest "check exclude_tags argument"
+notmuch search --output=threads --exclude=all tag:inbox > EXPECTED
+test_ruby <<"EOF"
+q = db.query('tag:inbox', exclude_tags: %w[deleted], omit_excluded: Notmuch::EXCLUDE_ALL)
+q.search_threads.each do |t|
+ puts 'thread:%s' % t.thread_id
+end
+EOF
+
test_done