--- /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 arlo.cworth.org (Postfix) with ESMTP id 84DBD6DE1833\r
+ for <notmuch@notmuchmail.org>; Mon, 1 Jun 2015 00:11:09 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.262\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.262 tagged_above=-999 required=5 tests=[AWL=0.252, \r
+ T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id WTe3AE9n7A-v for <notmuch@notmuchmail.org>;\r
+ Mon, 1 Jun 2015 00:11:07 -0700 (PDT)\r
+Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
+ [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id B84D46DE1640\r
+ for <notmuch@notmuchmail.org>; Mon, 1 Jun 2015 00:11:07 -0700 (PDT)\r
+Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
+ 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1YzJre-0007OQ-6u; Mon, 01 Jun 2015 07:10:26 +0000\r
+Received: (nullmailer pid 2455 invoked by uid 1000); Mon, 01 Jun 2015\r
+ 07:09:06 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: [patch v3 4/4] test: add initial ruby tests\r
+Date: Mon, 1 Jun 2015 09:09:02 +0200\r
+Message-Id: <1433142542-2307-5-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1433142542-2307-1-git-send-email-david@tethera.net>\r
+References: <1425679073-30439-5-git-send-email-david@tethera.net>\r
+ <1433142542-2307-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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: Mon, 01 Jun 2015 07:11:09 -0000\r
+\r
+This is pretty much a line by line translation of the existing python\r
+tests, with two new tests for the count API.\r
+---\r
+ test/T395-ruby.sh | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ test/test-lib.sh | 5 ++++\r
+ 2 files changed, 91 insertions(+)\r
+ create mode 100755 test/T395-ruby.sh\r
+\r
+diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh\r
+new file mode 100755\r
+index 0000000..8b8e6d2\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 threads"\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 23085e7..3466e9c 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -1163,6 +1163,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
+ test_C () {\r
+ exec_file="test${test_count}"\r
+ test_file="${exec_file}.c"\r
+-- \r
+2.1.4\r
+\r