2 test_description="ruby bindings"
3 . $(dirname "$0")/test-lib.sh || exit 1
5 if [ -z "${NOTMUCH_TEST_INSTALLED-}" -a "${NOTMUCH_HAVE_RUBY_DEV-0}" = "0" ]; then
6 test_subtest_missing_external_prereq_["ruby development files"]=t
15 db = Notmuch::Database.new()
18 ) | if [ -n "${NOTMUCH_TEST_INSTALLED-}" ]; then
21 $NOTMUCH_RUBY -I "$NOTMUCH_BUILDDIR/bindings/ruby"
23 test_expect_equal_file EXPECTED OUTPUT
26 test_begin_subtest "compare thread ids"
27 notmuch search --sort=oldest-first --output=threads tag:inbox > EXPECTED
29 q = db.query('tag:inbox')
30 q.sort = Notmuch::SORT_OLDEST_FIRST
31 q.search_threads.each do |t|
32 puts 'thread:%s' % t.thread_id
36 test_begin_subtest "compare message ids"
37 notmuch search --sort=oldest-first --output=messages tag:inbox > EXPECTED
39 q = db.query('tag:inbox')
40 q.sort = Notmuch::SORT_OLDEST_FIRST
41 q.search_messages.each do |m|
42 puts 'id:%s' % m.message_id
46 test_begin_subtest "get non-existent file"
49 p db.find_message_by_filename('i-dont-exist')
52 test_begin_subtest "count messages"
53 notmuch count --output=messages tag:inbox > EXPECTED
55 puts db.query('tag:inbox').count_messages()
58 test_begin_subtest "count threads"
59 notmuch count --output=threads tag:inbox > EXPECTED
61 puts db.query('tag:inbox').count_threads()
64 test_begin_subtest "get all tags"
65 notmuch search --output=tags '*' > EXPECTED
67 db.all_tags.each do |tag|
72 notmuch config set search.exclude_tags deleted
73 generate_message '[subject]="Good"'
74 generate_message '[subject]="Bad"' "[in-reply-to]=\<$gen_msg_id\>"
75 notmuch new > /dev/null
76 notmuch tag +deleted id:$gen_msg_id
78 test_begin_subtest "omit excluded all"
79 notmuch search --output=threads --exclude=all tag:inbox > EXPECTED
81 q = db.query('tag:inbox')
82 q.add_tag_exclude('deleted')
83 q.omit_excluded = Notmuch::EXCLUDE_ALL
84 q.search_threads.each do |t|
85 puts 'thread:%s' % t.thread_id
89 test_begin_subtest "check sort argument"
90 notmuch search --sort=oldest-first --output=threads tag:inbox > EXPECTED
92 q = db.query('tag:inbox', sort: Notmuch::SORT_OLDEST_FIRST)
93 q.search_threads.each do |t|
94 puts 'thread:%s' % t.thread_id
98 test_begin_subtest "check exclude_tags argument"
99 notmuch search --output=threads --exclude=all tag:inbox > EXPECTED
101 q = db.query('tag:inbox', exclude_tags: %w[deleted], omit_excluded: Notmuch::EXCLUDE_ALL)
102 q.search_threads.each do |t|
103 puts 'thread:%s' % t.thread_id