unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob a9f6ac57c927ceab9bdbd4170a85a0b8d7d11155 1847 bytes (raw)
name: test/T540-ruby.sh 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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

debug log:

solving a9f6ac5 ...
found a9f6ac5 in https://yhetil.org/notmuch/1400841267-12807-4-git-send-email-felipe.contreras@gmail.com/

applying [1/1] https://yhetil.org/notmuch/1400841267-12807-4-git-send-email-felipe.contreras@gmail.com/
diff --git a/test/T540-ruby.sh b/test/T540-ruby.sh
new file mode 100755
index 0000000..a9f6ac5

Checking patch test/T540-ruby.sh...
Applied patch test/T540-ruby.sh cleanly.

index at:
100755 a9f6ac57c927ceab9bdbd4170a85a0b8d7d11155	test/T540-ruby.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

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).