--- /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 7B594429E30\r
+ for <notmuch@notmuchmail.org>; Thu, 1 Jan 2015 04:17:18 -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 3zaPl-ghD6wt for <notmuch@notmuchmail.org>;\r
+ Thu, 1 Jan 2015 04:17:16 -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 CEFF5431FCB\r
+ for <notmuch@notmuchmail.org>; Thu, 1 Jan 2015 04:17:06 -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 1Y6egc-00053k-EP; Thu, 01 Jan 2015 08:17:06 -0400\r
+Received: (nullmailer pid 28823 invoked by uid 1000); Thu, 01 Jan 2015\r
+ 12:16:50 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 5/5] test: add initial ruby tests\r
+Date: Thu, 1 Jan 2015 13:16:40 +0100\r
+Message-Id: <1420114600-28396-6-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.3\r
+In-Reply-To: <1420114600-28396-1-git-send-email-david@tethera.net>\r
+References: <1420114600-28396-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: Thu, 01 Jan 2015 12:17:18 -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..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