From: David Bremner <david@tethera.net>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: [patch v3 4/4] test: add initial ruby tests
Date: Mon, 1 Jun 2015 09:09:02 +0200 [thread overview]
Message-ID: <1433142542-2307-5-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1433142542-2307-1-git-send-email-david@tethera.net>
This is pretty much a line by line translation of the existing python
tests, with two new tests for the count API.
---
test/T395-ruby.sh | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
test/test-lib.sh | 5 ++++
2 files changed, 91 insertions(+)
create mode 100755 test/T395-ruby.sh
diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh
new file mode 100755
index 0000000..8b8e6d2
--- /dev/null
+++ b/test/T395-ruby.sh
@@ -0,0 +1,86 @@
+#!/usr/bin/env bash
+test_description="ruby bindings"
+. ./test-lib.sh
+
+if [ "${NOTMUCH_HAVE_RUBY_DEV}" = "0" ]; then
+ test_subtest_missing_external_prereq_["ruby development files"]=t
+fi
+
+add_email_corpus
+
+test_begin_subtest "compare thread ids"
+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"
+end
+EOF
+notmuch search --sort=oldest-first --output=threads tag:inbox | sed s/^thread:// > EXPECTED
+test_expect_equal_file OUTPUT EXPECTED
+
+test_begin_subtest "compare message ids"
+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"
+end
+EOF
+notmuch search --sort=oldest-first --output=messages tag:inbox | sed s/^id:// > EXPECTED
+test_expect_equal_file OUTPUT EXPECTED
+
+test_begin_subtest "get non-existent file"
+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)
+EOF
+test_expect_equal "$(cat OUTPUT)" "true"
+
+test_begin_subtest "count messages"
+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"
+EOF
+notmuch count --output=messages tag:inbox > EXPECTED
+test_expect_equal_file OUTPUT EXPECTED
+
+test_begin_subtest "count threads"
+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"
+EOF
+notmuch count --output=threads tag:inbox > EXPECTED
+test_expect_equal_file OUTPUT EXPECTED
+
+test_done
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 23085e7..3466e9c 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -1163,6 +1163,11 @@ test_python() {
| $cmd -
}
+test_ruby() {
+ export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib
+ MAIL_DIR=$MAIL_DIR ruby -I $TEST_DIRECTORY/../bindings/ruby> OUTPUT
+}
+
test_C () {
exec_file="test${test_count}"
test_file="${exec_file}.c"
--
2.1.4
prev parent reply other threads:[~2015-06-01 7:11 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-01 12:16 Build and test ruby bindings David Bremner
2015-01-01 12:16 ` [PATCH 1/5] build: integrate building ruby bindings into notmuch build process David Bremner
2015-01-01 12:16 ` [PATCH 2/5] build/ruby: make use of -Wl,--no-undefined configurable David Bremner
2015-01-01 12:16 ` [PATCH 3/5] bindings/ruby: gitignore *.o David Bremner
2015-01-01 15:53 ` David Bremner
2015-01-01 12:16 ` [PATCH 4/5] build/ruby: use notmuch configure script values for shared lib David Bremner
2015-01-01 12:16 ` [PATCH 5/5] test: add initial ruby tests David Bremner
2015-03-06 21:57 ` integrate ruby into build and test v2 David Bremner
2015-03-06 21:57 ` [Patch v2 1/4] build: integrate building ruby bindings into notmuch build process David Bremner
2015-03-06 21:57 ` [Patch v2 2/4] build/ruby: make use of -Wl,--no-undefined configurable David Bremner
2015-03-06 21:57 ` [Patch v2 3/4] build/ruby: use notmuch configure script values for shared lib David Bremner
2015-03-06 21:57 ` [Patch v2 4/4] test: add initial ruby tests David Bremner
2015-06-01 7:08 ` Build ruby bindings: round 3 David Bremner
2015-06-01 7:08 ` [patch v3 1/4] build: integrate building ruby bindings into notmuch build process David Bremner
2015-06-13 6:37 ` David Bremner
2015-06-13 19:59 ` Jinwoo Lee
2015-06-13 20:46 ` Jinwoo Lee
2015-06-13 20:51 ` Jinwoo Lee
2015-06-13 21:11 ` David Bremner
2015-06-13 21:22 ` Jinwoo Lee
2015-06-13 21:24 ` Jinwoo Lee
2015-06-13 21:34 ` Jinwoo Lee
2015-06-14 5:49 ` David Bremner
2015-06-15 6:35 ` David Bremner
2015-06-01 7:09 ` [patch v3 2/4] build/ruby: make use of -Wl,--no-undefined configurable David Bremner
2015-06-14 5:58 ` [PATCH] lib, ruby: " David Bremner
2015-06-14 6:20 ` Jinwoo Lee
2015-06-14 6:53 ` David Bremner
2015-06-14 15:16 ` Jinwoo Lee
2015-06-14 18:34 ` David Bremner
2015-06-15 3:56 ` Jinwoo Lee
2015-06-15 9:20 ` Tomi Ollila
2015-06-15 21:49 ` Jinwoo Lee
2015-06-16 18:20 ` Tomi Ollila
2015-06-16 23:43 ` Jinwoo Lee
2015-06-17 0:15 ` Jinwoo Lee
2015-06-17 6:23 ` David Bremner
2015-06-17 6:39 ` Jinwoo Lee
2015-06-17 11:16 ` Tomi Ollila
2015-06-01 7:09 ` [patch v3 3/4] build/ruby: use notmuch configure script values for shared lib David Bremner
2015-06-14 6:26 ` [PATCH] " David Bremner
2015-06-01 7:09 ` David Bremner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433142542-2307-5-git-send-email-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).