grntest 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ # -*- mode: ruby; coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ source "http://rubygems.org/"
19
+
20
+ gemspec
data/README.md ADDED
@@ -0,0 +1,208 @@
1
+ # README
2
+
3
+ ## Name
4
+
5
+ grntest
6
+
7
+ ## Description
8
+
9
+ Grntest is a testing framework for groonga. You can write a test for groonga by writing groonga commands and expected result.
10
+
11
+ ## Install
12
+
13
+ ```
14
+ % gem install grntest
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ### Basic usage
20
+
21
+ Write a test script that extension is `.test`. Here is a sample test
22
+ script `select.test`:
23
+
24
+ ```
25
+ table_create Users TABLE_HASH_KEY ShortText
26
+
27
+ load --table Users
28
+ [
29
+ {"_key": "Alice"},
30
+ {"_key": "Bob"}
31
+ ]
32
+
33
+ select Users --query '_key:Alice'
34
+ ```
35
+
36
+ Run `grntest` with `select.test` as command line argument:
37
+
38
+ ```
39
+ % grntest select.test
40
+ N
41
+ ================================================================================
42
+ .
43
+ select 0.1667s [not checked]
44
+ ================================================================================
45
+ table_create Users TABLE_HASH_KEY ShortText
46
+ [[0,0.0,0.0],true]
47
+ load --table Users
48
+ [
49
+ {"_key": "Alice"},
50
+ {"_key": "Bob"}
51
+ ]
52
+ [[0,0.0,0.0],2]
53
+ select Users --query '_key:Alice'
54
+ [[0,0.0,0.0],[[[1],[["_id","UInt32"],["_key","ShortText"]],[1,"Alice"]]]]
55
+ ================================================================================
56
+
57
+
58
+ 5.96 tests/sec: 1 tests, 0 passes, 0 failures, 1 not checked_tests
59
+ 0% passed in 0.1678s.
60
+ ```
61
+
62
+ It generates `select.actual` file that contains actual result. If it
63
+ is expected result, rename it to `select.expected`:
64
+
65
+ ```
66
+ % mv select.actual select.expected
67
+ ```
68
+
69
+ Run `grntest` again:
70
+
71
+ ```
72
+ % grntest select.test
73
+ .
74
+
75
+ 6.12 tests/sec: 1 tests, 1 passes, 0 failures, 0 not checked_tests
76
+ 100% passed in 0.1635s.
77
+ ```
78
+
79
+ It compares actual result and content of `select.expected` and
80
+ reporots compared result. If they are the same contnet, `grntest`
81
+ reports success. If they are not the same content, `grntest` reports
82
+ failure and show diff of them.
83
+
84
+ Change `--query '_key:Alice'` to `--query '_key:Bob`' in
85
+ `select.test`:
86
+
87
+ ```
88
+ table_create Users TABLE_HASH_KEY ShortText
89
+
90
+ load --table Users
91
+ [
92
+ {"_key": "Alice"},
93
+ {"_key": "Bob"}
94
+ ]
95
+
96
+ select Users --query '_key:Bob'
97
+ ```
98
+
99
+ Run `grntest` again:
100
+
101
+ ```
102
+ % grntest select.test
103
+ F
104
+ ================================================================================
105
+ .
106
+ select 0.1445s [failed]
107
+ ================================================================================
108
+ --- (actual)
109
+ +++ (expected)
110
+ @@ -6,5 +6,5 @@
111
+ {"_key": "Bob"}
112
+ ]
113
+ [[0,0.0,0.0],2]
114
+ -select Users --query '_key:Bob'
115
+ -[[0,0.0,0.0],[[[1],[["_id","UInt32"],["_key","ShortText"]],[2,"Bob"]]]]
116
+ +select Users --query '_key:Alice'
117
+ +[[0,0.0,0.0],[[[1],[["_id","UInt32"],["_key","ShortText"]],[1,"Alice"]]]]
118
+ ================================================================================
119
+
120
+
121
+ 6.68 tests/sec: 1 tests, 0 passes, 1 failures, 0 not checked_tests
122
+ 0% passed in 0.1497s.
123
+ ```
124
+
125
+ It says the expected result that is read from `select.expected` and
126
+ the actual result are not same. And the difference of them is shown in
127
+ unified diff format. It is helpful to debug the test.
128
+
129
+ `select.reject` file is generated on failure. It contains the actual
130
+ result. If the actual result is the expected result, rename it to
131
+ `select.expected`.
132
+
133
+ ```
134
+ % mv select.reject select.expected
135
+ ```
136
+
137
+ Run `grntest` again:
138
+
139
+ ```
140
+ % grntest select.test
141
+ .
142
+
143
+ 6.97 tests/sec: 1 tests, 1 passes, 0 failures, 0 not checked_tests
144
+ 100% passed in 0.1434s.
145
+ ```
146
+
147
+ The test is succeeded again.
148
+
149
+ ### Advanced usage
150
+
151
+ See `grntest --help`. It contains many usuful features.
152
+
153
+ Some important features are described in this section.
154
+
155
+ #### `--n-workers`
156
+
157
+ `--n-workers` option is very useful. You can run many test scripts at
158
+ once. Tests are finished quickly. You should specify one or more
159
+ directories that contain many test scripts. If you have only a test
160
+ script, `--n-workers` is not effective.
161
+
162
+ Here is a sample command line to use `--n-workers`:
163
+
164
+ ```
165
+ % grntest --n-workers 4 test/function/suite/suggest
166
+ [0] [finished]
167
+ 8.60 tests/sec: 4 tests, 4 passes, 0 failures, 0 not checked_tests
168
+ [1] [finished]
169
+ 9.85 tests/sec: 5 tests, 5 passes, 0 failures, 0 not checked_tests
170
+ [2] [finished]
171
+ 8.63 tests/sec: 4 tests, 4 passes, 0 failures, 0 not checked_tests
172
+ [3] [finished]
173
+ 9.68 tests/sec: 5 tests, 5 passes, 0 failures, 0 not checked_tests
174
+ |-----------------------------------------------------------------------| [100%]
175
+
176
+ 34.43 tests/sec: 18 tests, 18 passes, 0 failures, 0 not checked_tests
177
+ 100% passed in 0.5228s.
178
+ ```
179
+
180
+ ### Examples
181
+
182
+ See [test/function/ directory in groonga's
183
+ source](https://github.com/groonga/groonga/tree/master/test/function). It
184
+ has many test scripts and uses many useful features. They will help you.
185
+
186
+ ## Dependencies
187
+
188
+ * Ruby 1.9.3
189
+
190
+ ### Mailing list
191
+
192
+ * English: [groonga-talk@lists.sourceforge.net](https://lists.sourceforge.net/lists/listinfo/groonga-talk)
193
+ * Japanese: [groonga-dev@lists.sourceforge.jp](http://lists.sourceforge.jp/mailman/listinfo/groonga-dev)
194
+
195
+ ## Thanks
196
+
197
+ * ...
198
+
199
+ ## Authors
200
+
201
+ * Kouhei Sutou \<kou@clear-code.com\>
202
+ * Haruka Yoshihara \<yoshihara@clear-code.com\>
203
+
204
+ ## License
205
+
206
+ GPLv3 or later. See doc/text/gpl-3.0.txt for details.
207
+
208
+ (Kouhei Sutou has a right to change the license including contributed patches.)
data/Rakefile ADDED
@@ -0,0 +1,43 @@
1
+ # -*- mode: ruby; coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ task :default => :test
19
+
20
+ require "rubygems"
21
+ require "bundler/gem_helper"
22
+ require "packnga"
23
+
24
+ base_dir = File.join(File.dirname(__FILE__))
25
+
26
+ helper = Bundler::GemHelper.new(base_dir)
27
+ def helper.version_tag
28
+ version
29
+ end
30
+
31
+ helper.install
32
+ spec = helper.gemspec
33
+
34
+ Packnga::DocumentTask.new(spec) do
35
+ end
36
+
37
+ Packnga::ReleaseTask.new(spec) do
38
+ end
39
+
40
+ desc "Run tests"
41
+ task :test do
42
+ ruby("test/run-test.rb")
43
+ end
data/bin/grntest ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require "grntest/tester"
19
+
20
+ exit(Grntest::Tester.run)