[PATCH 3/3] test: add tests for Ruby bindings

2014-07-13 Thread David Bremner
Felipe Contreras  writes:

>  2 files changed, 99 insertions(+)
>  create mode 100755 test/T540-ruby.sh
> +# Copyright (c) 2014 Felipe Contreras

Thanks for writing these; lack of tests bindings has been a long time
irritant for me.  Can you put in a brief license statement as well as
the copyright line?  Something like "same as notmuch" or "GPL 3+" is ok
for me.

>  
> +grep -q "WITH_RUBY = 1" ../Makefile.config && test_set_prereq RUBY

This looks a bit fragile. Somewhere in the patch queue is something to
create a config.sh snippet which would help here.

d




Re: [PATCH 3/3] test: add tests for Ruby bindings

2014-07-13 Thread David Bremner
Felipe Contreras felipe.contre...@gmail.com writes:

  2 files changed, 99 insertions(+)
  create mode 100755 test/T540-ruby.sh
 +# Copyright (c) 2014 Felipe Contreras

Thanks for writing these; lack of tests bindings has been a long time
irritant for me.  Can you put in a brief license statement as well as
the copyright line?  Something like same as notmuch or GPL 3+ is ok
for me.

  
 +grep -q WITH_RUBY = 1 ../Makefile.config  test_set_prereq RUBY

This looks a bit fragile. Somewhere in the patch queue is something to
create a config.sh snippet which would help here.

d


___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 3/3] test: add tests for Ruby bindings

2014-05-23 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 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 000..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



[PATCH 3/3] test: add tests for Ruby bindings

2014-05-23 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@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 000..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

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch