X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=test%2FT395-ruby.sh;h=f871ddd9b3cf8aea864a21d9e26ab9d5cef29ff8;hb=63413a5563450bdedee4c077f2f998578e75083a;hp=52f9fe0f8bfd7e8ee224f50b4b3785c6888a1c69;hpb=ab022657776af0bb47e72caf2517464ca59e7d48;p=notmuch diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh index 52f9fe0f..f871ddd9 100755 --- a/test/T395-ruby.sh +++ b/test/T395-ruby.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash test_description="ruby bindings" -. ./test-lib.sh || exit 1 +. $(dirname "$0")/test-lib.sh || exit 1 if [ "${NOTMUCH_HAVE_RUBY_DEV}" = "0" ]; then test_subtest_missing_external_prereq_["ruby development files"]=t @@ -8,95 +8,65 @@ fi add_email_corpus +test_ruby() { + ( + cat <<-EOF + require 'notmuch' + @db = Notmuch::Database.new('$MAIL_DIR') + 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" -require 'notmuch' -$maildir = ENV['MAIL_DIR'] -if not $maildir then - abort('environment variable MAIL_DIR must be set') -end -@db = Notmuch::Database.new($maildir) @q = @db.query('tag:inbox') @q.sort = Notmuch::SORT_OLDEST_FIRST for t in @q.search_threads do - print t.thread_id, "\n" + puts t.thread_id 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" -require 'notmuch' -$maildir = ENV['MAIL_DIR'] -if not $maildir then - abort('environment variable MAIL_DIR must be set') -end -@db = Notmuch::Database.new($maildir) @q = @db.query('tag:inbox') @q.sort = Notmuch::SORT_OLDEST_FIRST for m in @q.search_messages do - print m.message_id, "\n" + puts m.message_id 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 true > EXPECTED test_ruby <<"EOF" -require 'notmuch' -$maildir = ENV['MAIL_DIR'] -if not $maildir then - abort('environment variable MAIL_DIR must be set') -end -@db = Notmuch::Database.new($maildir) result = @db.find_message_by_filename('i-dont-exist') -print (result == nil) +puts (result == nil) EOF -test_expect_equal "$(cat OUTPUT)" "true" test_begin_subtest "count messages" +notmuch count --output=messages tag:inbox > EXPECTED test_ruby <<"EOF" -require 'notmuch' -$maildir = ENV['MAIL_DIR'] -if not $maildir then - abort('environment variable MAIL_DIR must be set') -end -@db = Notmuch::Database.new($maildir) @q = @db.query('tag:inbox') -print @q.count_messages(),"\n" +puts @q.count_messages() 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" -require 'notmuch' -$maildir = ENV['MAIL_DIR'] -if not $maildir then - abort('environment variable MAIL_DIR must be set') -end -@db = Notmuch::Database.new($maildir) @q = @db.query('tag:inbox') -print @q.count_threads(),"\n" +puts @q.count_threads() 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" -require 'notmuch' -$maildir = ENV['MAIL_DIR'] -if not $maildir then - abort('environment variable MAIL_DIR must be set') -end -@db = Notmuch::Database.new($maildir) @t = @db.all_tags() for tag in @t do - print tag,"\n" + puts tag end EOF -notmuch search --output=tags '*' > EXPECTED -test_expect_equal_file EXPECTED OUTPUT test_done