test: ruby: simplify test_ruby()

We always do test_expect_equal_file, so do it in test_ruby() directly.

The only subtest where we don't (get non-existent file) can be easily
modified.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
This commit is contained in:
Felipe Contreras 2021-05-01 06:59:19 -05:00 committed by David Bremner
parent 9f6bc01824
commit 2dbc5fdf5a

View file

@ -16,9 +16,11 @@ test_ruby() {
EOF
cat
) | $NOTMUCH_RUBY -I "$NOTMUCH_BUILDDIR/bindings/ruby"> OUTPUT
test_expect_equal_file EXPECTED OUTPUT
}
test_begin_subtest "compare thread ids"
notmuch search --sort=oldest-first --output=threads tag:inbox | sed s/^thread:// > EXPECTED
test_ruby <<"EOF"
@q = @db.query('tag:inbox')
@q.sort = Notmuch::SORT_OLDEST_FIRST
@ -26,10 +28,9 @@ for t in @q.search_threads do
print t.thread_id, "\n"
end
EOF
notmuch search --sort=oldest-first --output=threads tag:inbox | sed s/^thread:// > EXPECTED
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "compare message ids"
notmuch search --sort=oldest-first --output=messages tag:inbox | sed s/^id:// > EXPECTED
test_ruby <<"EOF"
@q = @db.query('tag:inbox')
@q.sort = Notmuch::SORT_OLDEST_FIRST
@ -37,40 +38,35 @@ for m in @q.search_messages do
print m.message_id, "\n"
end
EOF
notmuch search --sort=oldest-first --output=messages tag:inbox | sed s/^id:// > EXPECTED
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "get non-existent file"
echo -n true > EXPECTED
test_ruby <<"EOF"
result = @db.find_message_by_filename('i-dont-exist')
print (result == nil)
EOF
test_expect_equal "$(cat OUTPUT)" "true"
test_begin_subtest "count messages"
notmuch count --output=messages tag:inbox > EXPECTED
test_ruby <<"EOF"
@q = @db.query('tag:inbox')
print @q.count_messages(),"\n"
EOF
notmuch count --output=messages tag:inbox > EXPECTED
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "count threads"
notmuch count --output=threads tag:inbox > EXPECTED
test_ruby <<"EOF"
@q = @db.query('tag:inbox')
print @q.count_threads(),"\n"
EOF
notmuch count --output=threads tag:inbox > EXPECTED
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "get all tags"
notmuch search --output=tags '*' > EXPECTED
test_ruby <<"EOF"
@t = @db.all_tags()
for tag in @t do
print tag,"\n"
end
EOF
notmuch search --output=tags '*' > EXPECTED
test_expect_equal_file EXPECTED OUTPUT
test_done