unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: notmuch@notmuchmail.org
Cc: Ali Polatel <alip@exherbo.org>
Subject: [PATCH 3/3] test: add tests for Ruby bindings
Date: Fri, 23 May 2014 05:34:27 -0500	[thread overview]
Message-ID: <1400841267-12807-4-git-send-email-felipe.contreras@gmail.com> (raw)
In-Reply-To: <1400841267-12807-1-git-send-email-felipe.contreras@gmail.com>

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 test/T540-ruby.sh | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 test/test-lib.sh  |  1 +
 2 files changed, 99 insertions(+)
 create mode 100755 test/T540-ruby.sh

diff --git a/test/T540-ruby.sh b/test/T540-ruby.sh
new file mode 100755
index 0000000..a9f6ac5
--- /dev/null
+++ b/test/T540-ruby.sh
@@ -0,0 +1,98 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2014 Felipe Contreras
+#
+
+test_description="Ruby bindings"
+
+. ./test-lib.sh
+
+export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib
+export RUBYLIB=$TEST_DIRECTORY/../bindings/ruby
+
+if ! test_have_prereq RUBY
+then
+	skip_all='skipping ruby tests'
+	test_done
+fi
+
+test_ruby () {
+	cat > test.rb <<-\EOF &&
+	#!/usr/bin/env ruby
+
+	require 'notmuch'
+
+	$MAIL_DIR = ENV['MAIL_DIR']
+	EOF
+	cat >> test.rb &&
+	ruby test.rb
+}
+
+test_expect_success 'setup' '
+	add_email_corpus &&
+	notmuch new --quiet &&
+	export MAIL_DIR
+'
+
+test_expect_success 'new and close' '
+	test_ruby <<-\EOF
+	db = Notmuch::Database.new($MAIL_DIR)
+	db.close
+	EOF
+'
+
+test_expect_success 'open' '
+	test_ruby <<-\EOF
+	Notmuch::Database.open($MAIL_DIR) do |db|
+	end
+	EOF
+'
+
+test_expect_success 'path' '
+	echo $MAIL_DIR > expected &&
+	test_ruby > actual <<-\EOF &&
+	Notmuch::Database.open($MAIL_DIR) do |db|
+		puts db.path
+	end
+	EOF
+	test_cmp expected actual
+'
+
+test_expect_success 'query' '
+	notmuch count "tag:inbox" > expected &&
+	test_ruby > actual <<-\EOF &&
+	Notmuch::Database.open($MAIL_DIR) do |db|
+		query = db.query("tag:inbox")
+		puts query.count_messages
+	end
+	EOF
+	test_cmp expected actual
+'
+
+test_expect_success 'query threads' '
+	notmuch search --output=threads "tag:inbox" > expected &&
+	test_ruby > actual <<-\EOF &&
+	Notmuch::Database.open($MAIL_DIR) do |db|
+		query = db.query("tag:inbox")
+		query.search_threads.each do |thread|
+			puts "thread:" + thread.thread_id
+		end
+	end
+	EOF
+	test_cmp expected actual
+'
+
+test_expect_success 'query messages' '
+	notmuch search --output=messages "tag:inbox" > expected &&
+	test_ruby > actual <<-\EOF &&
+	Notmuch::Database.open($MAIL_DIR) do |db|
+		query = db.query("tag:inbox")
+		query.search_messages.each do |message|
+			puts "id:" + message.message_id
+		end
+	end
+	EOF
+	test_cmp expected actual
+'
+
+test_done
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 8697d6a..1f9dd1f 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -1208,6 +1208,7 @@ test_init_ () {
 
 emacs_generate_script
 
+grep -q "WITH_RUBY = 1" ../Makefile.config && test_set_prereq RUBY
 
 # Use -P to resolve symlinks in our working directory so that the cwd
 # in subprocesses like git equals our $PWD (for pathname comparisons).
-- 
1.9.3+fc1~5~gfaddd51

  parent reply	other threads:[~2014-05-23 10:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23 10:34 [PATCH 0/3] Build and test Ruby bindings Felipe Contreras
2014-05-23 10:34 ` [PATCH 1/3] build: don't add sub Makefiles to the global deps Felipe Contreras
2014-05-25  7:58   ` Jani Nikula
2014-05-25  7:53     ` Felipe Contreras
2014-05-25  9:17       ` Jani Nikula
2014-05-25 15:47         ` Felipe Contreras
2014-05-25 17:01           ` Jani Nikula
2014-05-23 10:34 ` [PATCH 2/3] build: add support to build Ruby bindings Felipe Contreras
2014-05-23 15:04   ` Wael Nasreddine
2014-07-13 14:28   ` David Bremner
2014-05-23 10:34 ` Felipe Contreras [this message]
2014-07-13 13:11   ` [PATCH 3/3] test: add tests for " David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1400841267-12807-4-git-send-email-felipe.contreras@gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=alip@exherbo.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).