--- /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 9DC76431FC0\r
+ for <notmuch@notmuchmail.org>; Fri, 6 Mar 2015 13:59:14 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.438\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
+ tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 8zi1uLgBM4LN for <notmuch@notmuchmail.org>;\r
+ Fri, 6 Mar 2015 13:59:11 -0800 (PST)\r
+Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
+ [87.98.215.224])\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 09B21431FC3\r
+ for <notmuch@notmuchmail.org>; Fri, 6 Mar 2015 13:59:08 -0800 (PST)\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 1YU0GF-0000RF-N7; Fri, 06 Mar 2015 21:58:23 +0000\r
+Received: (nullmailer pid 30541 invoked by uid 1000); Fri, 06 Mar 2015\r
+ 21:57:57 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v2 4/4] test: add initial ruby tests\r
+Date: Fri, 6 Mar 2015 22:57:53 +0100\r
+Message-Id: <1425679073-30439-5-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1425679073-30439-1-git-send-email-david@tethera.net>\r
+References: <1420114600-28396-6-git-send-email-david@tethera.net>\r
+ <1425679073-30439-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: Fri, 06 Mar 2015 21:59:14 -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 133fbe4..92c6d28 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -1161,6 +1161,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.4\r
+\r