From ea4eee9f80e4a38ae73781aedc8438f7a9d526df Mon Sep 17 00:00:00 2001 From: David Bremner Date: Mon, 1 Jun 2015 09:09:02 +0200 Subject: [PATCH] [patch v3 4/4] test: add initial ruby tests --- d6/2af0656511fe224804765882bceac3a34981df | 167 ++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 d6/2af0656511fe224804765882bceac3a34981df diff --git a/d6/2af0656511fe224804765882bceac3a34981df b/d6/2af0656511fe224804765882bceac3a34981df new file mode 100644 index 000000000..43b2a3912 --- /dev/null +++ b/d6/2af0656511fe224804765882bceac3a34981df @@ -0,0 +1,167 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 84DBD6DE1833 + for ; Mon, 1 Jun 2015 00:11:09 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.262 +X-Spam-Level: +X-Spam-Status: No, score=0.262 tagged_above=-999 required=5 tests=[AWL=0.252, + T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id WTe3AE9n7A-v for ; + Mon, 1 Jun 2015 00:11:07 -0700 (PDT) +Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net + [87.98.215.224]) + by arlo.cworth.org (Postfix) with ESMTPS id B84D46DE1640 + for ; Mon, 1 Jun 2015 00:11:07 -0700 (PDT) +Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim + 4.80) (envelope-from ) + id 1YzJre-0007OQ-6u; Mon, 01 Jun 2015 07:10:26 +0000 +Received: (nullmailer pid 2455 invoked by uid 1000); Mon, 01 Jun 2015 + 07:09:06 -0000 +From: David Bremner +To: David Bremner , notmuch@notmuchmail.org +Subject: [patch v3 4/4] test: add initial ruby tests +Date: Mon, 1 Jun 2015 09:09:02 +0200 +Message-Id: <1433142542-2307-5-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1433142542-2307-1-git-send-email-david@tethera.net> +References: <1425679073-30439-5-git-send-email-david@tethera.net> + <1433142542-2307-1-git-send-email-david@tethera.net> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 01 Jun 2015 07:11:09 -0000 + +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 + -- 2.26.2