--- /dev/null
+Return-Path: <bremner@tesseract.cs.unb.ca>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id B3322431FDA\r
+ for <notmuch@notmuchmail.org>; Tue, 30 Dec 2014 12:30:50 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id fkWVumuvjaeQ for <notmuch@notmuchmail.org>;\r
+ Tue, 30 Dec 2014 12:30:47 -0800 (PST)\r
+Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
+ (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 7228E431FCB\r
+ for <notmuch@notmuchmail.org>; Tue, 30 Dec 2014 12:30:47 -0800 (PST)\r
+Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1Y63RH-00010Q-7B; Tue, 30 Dec 2014 16:30:47 -0400\r
+Received: (nullmailer pid 10595 invoked by uid 1000); Tue, 30 Dec 2014\r
+ 20:29:44 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v2 3/5] test: port existing python tests to ruby\r
+Date: Tue, 30 Dec 2014 21:29:38 +0100\r
+Message-Id: <1419971380-10307-4-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.3\r
+In-Reply-To: <1419971380-10307-1-git-send-email-david@tethera.net>\r
+References: <1419971380-10307-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 30 Dec 2014 20:30:51 -0000\r
+\r
+This is pretty much a line by line translation. Add a dependency of\r
+the test suite on the ruby bindings, as these are currently not built\r
+by default.\r
+---\r
+ test/Makefile.local | 2 +-\r
+ test/T395-ruby.sh | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ test/test-lib.sh | 5 ++++\r
+ 3 files changed, 92 insertions(+), 1 deletion(-)\r
+ create mode 100755 test/T395-ruby.sh\r
+\r
+diff --git a/test/Makefile.local b/test/Makefile.local\r
+index 2331ceb..9423680 100644\r
+--- a/test/Makefile.local\r
++++ b/test/Makefile.local\r
+@@ -55,7 +55,7 @@ TEST_BINARIES := $(TEST_BINARIES:.cc=)\r
+ \r
+ test-binaries: $(TEST_BINARIES)\r
+ \r
+-test: all test-binaries\r
++test: all test-binaries ruby-bindings\r
+ @${test_src_dir}/notmuch-test $(OPTIONS)\r
+ \r
+ check: test\r
+diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh\r
+new file mode 100755\r
+index 0000000..6b89a5d\r
+--- /dev/null\r
++++ b/test/T395-ruby.sh\r
+@@ -0,0 +1,86 @@\r
++#!/usr/bin/env bash\r
++test_description="ruby bindings"\r
++. ./test-lib.sh\r
++\r
++if [ "${NOTMUCH_HAVE_RUBY_DEV}" = "0" ]; then\r
++ test_subtest_missing_external_prereq_["ruby development files"]=t\r
++fi\r
++\r
++add_email_corpus\r
++\r
++test_begin_subtest "compare thread ids"\r
++test_ruby <<"EOF"\r
++require 'notmuch'\r
++$maildir = ENV['MAIL_DIR']\r
++if not $maildir then\r
++ abort('environment variable MAIL_DIR must be set')\r
++end\r
++@db = Notmuch::Database.new($maildir)\r
++@q = @db.query('tag:inbox')\r
++@q.sort = Notmuch::SORT_OLDEST_FIRST\r
++for t in @q.search_threads do\r
++ print t.thread_id, "\n"\r
++end\r
++EOF\r
++notmuch search --sort=oldest-first --output=threads tag:inbox | sed s/^thread:// > EXPECTED\r
++test_expect_equal_file OUTPUT EXPECTED\r
++\r
++test_begin_subtest "compare message ids"\r
++test_ruby <<"EOF"\r
++require 'notmuch'\r
++$maildir = ENV['MAIL_DIR']\r
++if not $maildir then\r
++ abort('environment variable MAIL_DIR must be set')\r
++end\r
++@db = Notmuch::Database.new($maildir)\r
++@q = @db.query('tag:inbox')\r
++@q.sort = Notmuch::SORT_OLDEST_FIRST\r
++for m in @q.search_messages do\r
++ print m.message_id, "\n"\r
++end\r
++EOF\r
++notmuch search --sort=oldest-first --output=messages tag:inbox | sed s/^id:// > EXPECTED\r
++test_expect_equal_file OUTPUT EXPECTED\r
++\r
++test_begin_subtest "get non-existent file"\r
++test_ruby <<"EOF"\r
++require 'notmuch'\r
++$maildir = ENV['MAIL_DIR']\r
++if not $maildir then\r
++ abort('environment variable MAIL_DIR must be set')\r
++end\r
++@db = Notmuch::Database.new($maildir)\r
++result = @db.find_message_by_filename('i-dont-exist')\r
++print (result == nil)\r
++EOF\r
++test_expect_equal "$(cat OUTPUT)" "true"\r
++\r
++test_begin_subtest "count messages"\r
++test_ruby <<"EOF"\r
++require 'notmuch'\r
++$maildir = ENV['MAIL_DIR']\r
++if not $maildir then\r
++ abort('environment variable MAIL_DIR must be set')\r
++end\r
++@db = Notmuch::Database.new($maildir)\r
++@q = @db.query('tag:inbox')\r
++print @q.count_messages(),"\n"\r
++EOF\r
++notmuch count --output=messages tag:inbox > EXPECTED\r
++test_expect_equal_file OUTPUT EXPECTED\r
++\r
++test_begin_subtest "count messages"\r
++test_ruby <<"EOF"\r
++require 'notmuch'\r
++$maildir = ENV['MAIL_DIR']\r
++if not $maildir then\r
++ abort('environment variable MAIL_DIR must be set')\r
++end\r
++@db = Notmuch::Database.new($maildir)\r
++@q = @db.query('tag:inbox')\r
++print @q.count_threads(),"\n"\r
++EOF\r
++notmuch count --output=threads tag:inbox > EXPECTED\r
++test_expect_equal_file OUTPUT EXPECTED\r
++\r
++test_done\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index 53db9ca..3bbdc03 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -1156,6 +1156,11 @@ test_python() {\r
+ | $cmd -\r
+ }\r
+ \r
++test_ruby() {\r
++ export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib\r
++ MAIL_DIR=$MAIL_DIR ruby -I $TEST_DIRECTORY/../bindings/ruby> OUTPUT\r
++}\r
++\r
+ # Creates a script that counts how much time it is executed and calls\r
+ # notmuch. $notmuch_counter_command is set to the path to the\r
+ # generated script. Use notmuch_counter_value() function to get the\r
+-- \r
+2.1.3\r
+\r